| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- /**
- * 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();
- }
- });
|