Ext.define('saas.view.money.payBalance.FormPanelController', { extend: 'saas.view.core.form.FormPanelController', alias: 'controller.money-paybalance-formpanel', init: function (form) { var me = this; this.control({ // 供应商名称 'dbfindtrigger[name=pb_vendname]':{ beforerender: function (f) { Ext.apply(f, { dataUrl: '/api/document/vendor/list', addXtype: 'document-vendor-formpanel', addTitle: '供应商资料', dbfinds: [{ from: 've_code', to: 'pb_vendcode' }, { from: 've_name', to: 'pb_vendname' },{ from: 've_leftamount', to: 've_leftamount' },{ from: 'id', to: 'pb_vendid' }], dbtpls: [{ field: 've_code', width: 100 }, { field: 've_name', width: 100 },{ field:'ve_leftamount', width: 100 }], defaultCondition: "ve_statuscode='OPEN'", dbSearchFields:[{ emptyText:'输入供应商编号或名称', xtype : "textfield", name : "search", getCondition: function(v) { return "(upper(ve_code) like '%"+v.toUpperCase()+"%' or upper(ve_name) like '%"+v.toUpperCase()+"%')"; }, allowBlank : true, columnWidth : 0.25 }], dbColumns:[{ "text": "供应商ID", "hidden": true, "dataIndex": "id", "width": 100, "xtype": "numbercolumn" },{ "text": "供应商编号", "dataIndex": "ve_code", "width": 200 }, { "text": "供应商名称", "dataIndex": "ve_name", "width": 200 }, { "text": "供应商类型", "dataIndex": "ve_type", "width": 180, "items": null }, { "text": "税率", "dataIndex": "ve_taxrate", "width": 100 }, { "text": "承付天数", "dataIndex": "ve_promisedays", "width": 100, renderer : function(v) { return Ext.util.Format.number(v, '0'); } }, { "text": "纳税人识别号", "dataIndex": "ve_bankaccount", "width": 150 }, { "text": "开户银行", "dataIndex": "ve_bankaccount", "width": 100 }, { "text": "银行账户", "dataIndex": "ve_bankcode", "width": 100 }] }); } }, 'multidbfindtrigger[name=pbd_slcode]': { beforerender: function (f) { Ext.apply(f, { dataUrl: '/api/money/subledger/list', addTitle: '源单资料', dbfinds: [{ from: 'id', to: 'pbd_slid' }, { from: 'sl_code', to: 'pbd_slcode' },{ from: 'sl_orderamount', to: 'pbd_amount' },{ from: 'sl_yamount', to: 'sl_yamount' },{ from: 'sl_namount', to: 'sl_namount' },{ from:'sl_date', to:'pbd_sldate' },{ from:'sl_kind', to:'pbd_slkind' },{ from:'sl_namount', to:'pbd_nowbalance' }], dbtpls: [{ field: 'sl_code', width: 100 }], defaultCondition: "sl_vendid<>0 and sl_kind in ('期初余额','采购验收单','采购验退单') and sl_namount<>0" , dbSearchFields:[{ emptyText:'输入源单编号', xtype : "textfield", name : "search", getCondition: function(v) { return "(upper(sl_code) like '%"+v.toUpperCase()+"%')"; }, allowBlank : true, columnWidth : 0.25 }], dbColumns:[{ "text": "源单id", "hidden": true, "dataIndex": "id", "width": 100, "xtype": "numbercolumn" },{ "text": "源单编号", "flex": 1, "dataIndex": "sl_code", "width": 100 },{ "text": "源单类型", "flex": 1, "dataIndex": "sl_kind", "width": 100 }, { "text": "单据金额", "flex": 1, "dataIndex": "sl_orderamount", "width": 100, xtype: 'numbercolumn', align:'end' }, { "text": "已核销金额", "flex": 1, "dataIndex": "sl_yamount", "width": 150, xtype: 'numbercolumn', align:'end', "items": null }, { "text": "未核销金额", "flex": 1, "dataIndex": "sl_namount", "width": 100, xtype: 'numbercolumn', align:'end' },{ "text": "单据日期", "flex": 1, "dataIndex": "sl_date", "width": 120, xtype: 'datecolumn', align:'end' }] }); } }, 'dbfindtrigger[name=pd_bankname]':{ beforerender: function (f) { Ext.apply(f, { dataUrl: '/api/document/bankinformation/list', addXtype: 'other-bankinformation', addTitle: '资金账户', dbfinds: [{ from: 'id', to: 'pd_bankid' }, { from: 'bk_bankcode', to: 'pd_bankcode' },{ from: 'bk_bankname', to: 'pd_bankname' }], dbtpls: [{ field: 'bk_bankcode', width: 100 }, { field: 'bk_bankname', width: 100 }], otherConditon:'', dbSearchFields: [{ emptyText: '查找资金账户', xtype: "textfield", name: "search", getCondition: function (v) { return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')"; }, allowBlank: true, columnWidth: 0.25 }], dbColumns: [{ "text": "账户ID", "flex": 0, "dataIndex": "id", "width": 0, "xtype": "" }, { "text": "资金账户", "flex": 1, "dataIndex": "bk_bankcode", "width": 120, "xtype": "" }, { "text": "账户名称", "flex": 1, "dataIndex": "bk_bankname", "width": 150, "xtype": "" }, { "text": "账户类别", "flex": 1, "dataIndex": "bk_type", "width": 120, "xtype": "" }, { "text": "账户余额", "flex": 1, "dataIndex": "bk_thisamount", "width": 120, xtype: 'numbercolumn', }, { "text": "建帐日期", "flex": 1, "dataIndex": "bk_date", "width": 120, "xtype": "datecolumn" }] }); } } }); }, addCombo:function(){ var combo=this.ownerCmp; Ext.create('Ext.window.Window',{ layout:'vbox', bodyPadding: 15, width:500, items:[{ fieldLabel:'实际值', xtype:'textfield' },{ fieldLabel:'显示值', xtype:'textfield' }], buttons:[{ text:'确认', handler:function(b){ combo.setValue('ok'); b.up('window').close(); } }], renderTo:this.ownerCmp.ownerCt.getEl() }).show(); }, turnIn: function() { var me = this, form = me.getView(), id = form.getForm().findField(form._idField); form.BaseUtil.request({ url: form._turnInUrl+id.value, method: 'GET', }) .then(function(localJson) { if(localJson.success){ showToast('转单成功'); } }) .catch(function(res) { console.error(res); showToast('转单失败: ' + res.message); }); }, onSave: function() { var me = this, form = me.getView(), viewModel = me.getViewModel(), store1 = viewModel.get('detail0').detailStore, store2 = viewModel.get('detail1').detailStore; var valid = form.isValid(); if(!valid) { showToast(form.invalidText); return false; } var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计 var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额 var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计 var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance; viewModel.set("pb_preamount",flag); if(flag != 0) { var t = flag > 0 ? '大' : '小'; showConfirm('提示', '付款金额' + t + '于本次折扣后核销金额,是否仍要保存?') .then(function(y) { if(y == 'yes') { me.save(); } }); }else { me.save(); } }, vendnamechange:function(dbfindtrigger){ var me = this, viewModel = me.getViewModel(); var c = viewModel.get('pb_vendname_change'); if(c!=null&&c!=''){ c = ' and sl_vendid='+c; }else{ c =''; } dbfindtrigger.defaultCondition = "sl_vendid<>0 and sl_kind in ('期初余额','采购验收单','采购验退单') and sl_namount<>0" + c; } });