Ext.define('saas.view.money.recBalance.FormPanelController', { extend: 'saas.view.core.form.FormPanelController', alias: 'controller.money-recbalance-formpanel', init: function (form) { var me = this; this.control({ 'dbfindtrigger[name=rb_custname]':{ beforerender:function(f){ Ext.apply(f,{ //赋值 dbfinds:[{ from: 'id', to: 'rb_custid',ignore:true }, { from:'cu_code', to:'rb_custcode' },{ from:'cu_name', to:'rb_custname' },{ from:'cu_leftamount', to:'cu_leftamount' }], }) ; } }, 'dbfindtrigger[name=rd_bankname]':{ beforerender:function(f){ Ext.apply(f,{ //赋值 dbfinds:[{ from: 'id', to: 'rd_bankid',ignore:true }, { from:'bk_bankcode', to:'rd_bankcode' },{ from:'bk_bankname', to:'rd_bankname' }], }) ; } }, 'multidbfindtrigger[name=rbd_slcode]': { beforerender: function (f) { Ext.apply(f, { dataUrl: '/api/money/subledger/list', addTitle: '源单单据', dbfinds: [{ from: 'id', to: 'rbd_slid',ignore:true }, { from: 'sl_code', to: 'rbd_slcode' },{ from: 'sl_orderamount', to: 'rbd_amount' },{ from: 'sl_yamount', to: 'sl_yamount' },{ from: 'sl_namount', to: 'sl_namount' },{ from:'sl_date', to:'rbd_sldate' },{ from:'sl_kind', to:'rbd_slkind' },{ from: 'sl_namount', to: 'rbd_nowbalance' }], dbtpls: [{ field: 'sl_code', width: 100 }], defaultCondition: "sl_custid<>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": "源单编号", "dataIndex": "sl_code", "width": 180 }, { "text": "源单类型", "flex": 1, "dataIndex": "sl_kind", "width": 100 },{ "text": "单据金额", "flex": 1, "dataIndex": "sl_orderamount", "width": 100, xtype: 'numbercolumn', align:'end' }, { "text": "已核销金额", "flex": 0, "dataIndex": "sl_yamount", "width": 200, "items": null, xtype: 'numbercolumn', align:'end' }, { "text": "未核销金额", "flex": 1, "dataIndex": "sl_namount", "width": 100, xtype: 'numbercolumn', align:'end' },{ "text": "单据日期", "flex": 1, "dataIndex": "sl_date", "width": 120, xtype: 'datecolumn', align:'end' }] }); } }, }); }, 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); saas.util.BaseUtil.request({ url: form._turnInUrl+id.value, method: 'GET', }) .then(function(localJson) { if(localJson.success){ saas.util.BaseUtil.showToast('转单成功'); } }) .catch(function(res) { console.error(res); saas.util.BaseUtil.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) { saas.util.BaseUtil.showToast(form.invalidText); return false; } var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计 var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额 var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计 var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance; viewModel.set("rb_preamount",flag); if(flag != 0) { var t = flag > 0 ? '大' : '小'; saas.util.BaseUtil.showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?') .then(function(y) { if(y == 'yes') { me.save(); } }); }else { me.save(); } }, custnamechange:function(dbfindtrigger){ var me = this, viewModel = me.getViewModel(); var c = viewModel.get('rb_custname_change'); if(c!=null&&c!=''){ c = ' and sl_custid='+c; }else{ c =''; } dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c; } });