/** * Created by zhouy on 2018/10/18. */ Ext.define('KitchenSink.view.binding.ChildForm', { extend: 'Ext.window.Window', xtype: 'document-kind-childwin', layout: 'fit', modal: true, width: 500, //工具类 FormUtil: Ext.create('saas.util.FormUtil'), BaseUtil: Ext.create('saas.util.BaseUtil'), height: 260, listeners:{ show:function(w){ if(w.record){ w.down('form').loadRecord(w.record); } } }, initComponent:function(){ var me=this; Ext.apply(me,{ items:me.setFormItems() }); me.callParent(); }, etc:{ customerkind:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'ck_name', allowBlank:false, fieldLabel:'类型' }] }, vendorkind:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'vk_name', allowBlank:false, fieldLabel:'类型' }] }, productkind:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'pt_name', allowBlank:false, fieldLabel:'类型' }] }, bankinformation:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'bk_bankname', allowBlank:false, fieldLabel:'账户名称' },{ xtype:'textfield', name:'bk_bankcode', allowBlank:false, fieldLabel:'账户编号' },{ xtype:'numberfield', name:'bk_beginamount', allowBlank:false, fieldLabel:'期初金额' },{ xtype:'numberfield', name:'bk_thisamount', allowBlank:false, fieldLabel:'当前金额' }] }, productbrand:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'pb_name', allowBlank:false, fieldLabel:'类型' }] }, inoutkind:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', name:'ft_name', allowBlank:false, fieldLabel:'类型' }] }, storeinformation:{ items:[{ xtype:'hidden', name:'id' },{ xtype:'textfield', fieldLabel: '仓库编号', name: 'wh_code' },{ xtype:'textfield', fieldLabel: '仓库名称', name: 'wh_description' },{ readOnly:true, xtype:'textfield', fieldLabel: '仓库状态', name: 'wh_status', value:'已开启' },{ xtype:'hidden', fieldLabel: '仓库状态码', name: 'wh_statuscode', value:'OPEN' }] } }, setFormItems:function() { var me = this, kind = me.dataKind; var conf = { xtype: 'form', bodyPadding: 10, border: false, autoScroll:true, modelValidation: true, layout: { type: 'vbox', align: 'stretch' }, defaults: { xtype: 'textfield' }, buttons: [{ text: '保存', formBind:true, handler: me.onSave, scope:me }, { text: '取消', handler: me.onCancel, scope:me }] }; return Ext.apply(conf, me.etc[kind]); }, onSave:function(){ var belong = this.belong; var form=this.down('form'); var params = {}; var names = belong.columns.map(column => column.dataIndex); Ext.Array.each(names,function(name) { if(name){ var dataField = form.down('[name='+name+']'); if(dataField&&dataField.value){ params[name] = dataField.value; } } }); var idField = form.down('[name='+belong.keyField+']'); params[belong.keyField] = idField.value || 0; //保存接口 this.BaseUtil.request({ url: belong.reqUrl, params: JSON.stringify(params), method: 'POST', }) .then(function(localJson) { if(localJson.success){ showToast('保存成功'); var grid = form.ownerCt._parent.lookup('document-kind-Grid'); if(grid){ grid.store.load(); } form.ownerCt.close(); } }) .catch(function(res) { console.error(res); showToast('保存失败: ' + res.message); }); }, onCancel:function(){ this.hide(); } });