主界面js 代码:
Ext.define("Eveimi.view.productMgr.TableDefView",{
extend:'Ext.grid.Panel',
title:'字段组和库表定义',layout:'fit',
alias : 'widget.tableDefView',
border:false,
selModel: {
selType:'checkboxmodel',
mode:'SINGLE'
},
initComponent: function() {
var me = this;
me.initStore();
Ext.apply(me,{
forceFit:true,autoScroll:true,columnLines:true,
store:me.proStore,
columns:[
{text:'表/字段组名称',dataIndex:'name',align:'center',width:200},
{text:'说明',dataIndex:'remark',align:'center',width:100},
{text:'前缀名',dataIndex:'prefix',align:'center',width:100},
{text:'是否字段组',dataIndex:'groupflag',align:'center',width:100,
renderer:function(val){
if(val=='0 '){return '否';}
if(val=='1 '){return '是';}
return val;
}
}
],
dockedItems:{dock: 'top',
xtype:'searchPanel',name:'_searchPanel',layout:'anchor',
items:[
{xtype:'container',anchor:'100%',style:{marginTop:3,marginBottom:3},width:300,labelWidth:80,
layout:'column',
items:[
{xtype:'combo',fieldLabel:'产品',name:'product',width:300,labelWidth:80,labelAlign:'right',
store: Ext.create('Ext.data.Store',{
fields:['productid','name'],
proxy: {
url: ctx+'/productDef/findProductDefLists.action',
type: 'ajax',
reader: {
type: 'json',
successProperty: 'success',
rootProperty: 'results',
totalProperty : 'totalCount'
}
},
autoLoad: true
}),editable:false,
queryMode: 'local',displayField: 'name',columnWidth:.3,
valueField: 'productid',emptyText:'请选择产品',
listConfig:{maxHeight:150},
listeners:{
select:function(combo, record, index){
var productid = record.get('productid');
var combo_ = me.down('combo[name=version]');
var store_ = combo_.getStore();
store_.load({
params: {
productId:productid
}, //参数
callback: function(records, options, success){
// Ext.Msg.alert('info', '加载完毕');
},
scope: store_,
add:false
});
}
}
},
{xtype:'combo',fieldLabel:'版本',name:'version',width:300,labelWidth:80,labelAlign:'right',
store: Ext.create('Ext.data.Store',{
fields:['pvid','version'],
proxy: {
url: ctx+'/productDef/getVersionsByProductId.action',
type: 'ajax',
reader: {
type: 'json',
successProperty: 'success',
rootProperty: 'results',
totalProperty : 'totalCount'
}
},
autoLoad: true
}),editable:false,
queryMode: 'local',displayField: 'version',columnWidth:.3,
valueField: 'pvid',emptyText:'请选择版本',
listConfig:{maxHeight:150}
},
{xtype:'combo',fieldLabel:'库表',name:'category',width:300,labelWidth:80,labelAlign:'right',
store:Ext.create('Ext.data.Store',{
fields:['value','category'],
data:[{'value':'0','category':'库表'},
{'value':'1','category':'字段组'}
],
autoLoad:true
}),editable:false,
value:'0',
queryMode:'local',displayField:'category',columnWidth:.3,
valueField:'value',emptyText:'请选择类别',
listConfig:{maxHeight:150}
}
]
}
]
},
tbar:{
items:[
'->',
{text:'新增',iconCls:'note_add',action:'defAddBtn'},
{text:'编辑',iconCls:'note_edit',action:'defEditBtn'}
]
},
bbar:Ext.create('Ext.toolbar.Paging',{
store:me.proStore,
pageSize :25,
displayInfo : true,
displayMsg : '当前记录 {0} -- {1} 条 共 {2} 条记录',
emptyMsg : "没有记录可显示",
prevText : "上一页",
nextText : "下一页",
refreshText : "刷新",
lastText : "最后页",
firstText : "第一页",
beforePageText : "当前页",
afterPageText : "共{0}页"
})
});
me.callParent(arguments);
},
initStore:function(){
var me = this;
me.proStore = Ext.create('Ext.data.Store',{
fields:["id","pvid","name","groupflag","prefix","remark","createuser","createdate","versionName","productId","productName"],
proxy: {
url: ctx+'/tableGroup/getHomePage.action',
type: 'ajax',
reader: {
type: 'json',
successProperty: 'success',
rootProperty: 'results',
totalProperty : 'totalCount'
}
},
autoLoad: true
});
}
});
编辑界面对应的js代码:
Ext.define("Eveimi.view.productMgr.TableDefEditWin",{
extend:'Ext.window.Window',
title:'字段组和库表定义编辑',layout:'fit',
width:450,height:320,modal:true,resizable:false,
alias : 'widget.tableDefEditWin',
border:false,passedObj:null,
initComponent: function() {
var me = this;
Ext.apply(me,{
items:{
xtype:'form',
items:[
{xtype:'textfield',name:"id",hidden:true},
{xtype:'textfield',name:"pvid",hidden:true},
{xtype:'combo',anchor:'95%',fieldLabel:'<span style="color:red;">*</span>选择产品',name:'productId',maxLength:'100',
allowBlank:false,margin:'10 5 0 10',readOnly:true,
store: Ext.create('Ext.data.Store',{
fields:['productid','name'],
proxy: {
url: ctx+'/productDef/findProductDefLists.action',
type: 'ajax',
reader: {
type: 'json',
successProperty: 'success',
rootProperty: 'results',
totalProperty : 'totalCount'
}
},
autoLoad: true
}),editable:false,
queryMode: 'local',displayField: 'name',columnWidth:.3,
valueField: 'productid',emptyText:'请选择产品',
listConfig:{maxHeight:150}
},
{xtype:'combo',anchor:'95%',fieldLabel:'<span style="color:red;">*</span>选择版本',name:'version',maxLength:'100',
allowBlank:false,margin:'10 5 0 10',readOnly:true,
store: Ext.create('Ext.data.Store',{
fields:['pvid','version'],
proxy: {
url:ctx+'/productDef/getVersionsByProductId.action?productId='+me.passedObj.data.productId,
type: 'ajax',
reader: {
type: 'json',
successProperty: 'success',
rootProperty: 'results',
totalProperty : 'totalCount'
}
},
autoLoad: true
}),editable:false,
queryMode: 'local',displayField: 'version',columnWidth:.3,
valueField: 'pvid',emptyText:'请选择版本',
listConfig:{maxHeight:150}
},
{xtype:'textfield',anchor:'95%',fieldLabel:'<span style="color:red;">*</span>前缀名',name:'prefix',
maxLength:'100',allowBlank:false,margin:'10 5 0 10'
},
{xtype:'textfield',anchor:'95%',fieldLabel:'<span style="color:red;">*</span>表/字段组名',name:'name',
maxLength:'100',allowBlank:false,margin:'10 5 0 10'
},
{xtype:'textarea',anchor:'95%',fieldLabel:'<span style="color:red;">*</span>说明',name:'remark',
maxLength:'100',allowBlank:false,margin:'10 5 0 10'
},
{xtype: 'radiogroup',fieldLabel:'<span style="color:red;">*</span>是否字段组',name:'groupflag',allowBlank:false,margin:'10 5 0 10',
items:[
{
boxLabel:'是',
name:'groupflag',
inputValue:"1"
},
{
boxLabel:'否',
name:'groupflag',
inputValue:"0"
}
]
}
],
buttons:[
{text:'保存',action:'add',formBind:true},
{text:'取消',action:'cancel',handler:function(){me.close();}}
],
buttonAlign:'center'
},
listeners:{
afterrender:function(this1,op){
try{
this1.down('textfield[name=id]').setValue(me.passedObj.data.id);
this1.down('textfield[name=pvid]').setValue(me.passedObj.data.pvid);
this1.down('combo[name=productId]').setValue(me.passedObj.data.productId);
this1.down('combo[name=version]').setValue(me.passedObj.data.versionName);
this1.down('textfield[name=prefix]').setValue(me.passedObj.data.prefix);
this1.down('textfield[name=name]').setValue(me.passedObj.data.name);
this1.down('textarea[name=remark]').setValue(me.passedObj.data.remark);
this1.down('radiogroup[name=groupflag]').setValue(me.passedObj.data.groupflag);
console.log(me.passedObj.data.groupflag);
}catch(e){}
}
}
});
me.callParent(arguments);
}
});