Ext.define('saas.view.money.verification.FormPanel', { extend: 'saas.view.core.form.FormPanel', // extend: 'Ext.panel.Panel', xtype: 'money-verification-formpanel', controller: 'money-verification-formpanel', viewModel: 'money-verification-formpanel', viewName: 'money-verification-formpanel', caller: 'Verification', //字段属性 _title: '核销单', _idField: 'id', _codeField: 'vc_code', _statusField: 'vc_status', _statusCodeField: 'vc_statuscode', _auditmanField: 'vc_auditman', _auditdateField:'vc_auditdate', _readUrl: '/api/money/verification/read', _saveUrl: '/api/money/verification/save', _auditUrl: '/api/money/verification/audit', _unAuditUrl: '/api/money/verification/unAudit', _deleteUrl: '/api/money/verification/delete', defatulType: 'receipts_offset_receivable', etc: { /** * 预收:receipts * 预付:prepaid * 应收:receivable * 应付:payable */ // base base: [{ xtype: 'combo', name: 'vc_kind', fieldLabel: '业务类型', editable: false, store: [ ['receipts_offset_receivable', '预收冲应收'], ['prepaid_offset_payable', '预付冲应付'], ['receivable_offset_payable', '应收冲应付'], ['receivable_to_receivable', '应收转应收'], ['payable_to_payable', '应付转应付'] ], listeners:{ beforerender:function(f){ f.firstLoad = true; if(f.ownerCt.initId!=0){ f.setReadOnly(true); f.setDisabled(true); } } } }], detail1: { xtype: "detailGridField", storeModel: 'saas.model.money.Verification1', detnoColumn: 'vd_detno', deleteDetailUrl: '/api/money/verification/deleteDetail1', columnWidth: 1, columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '来源ID', dataIndex: 'vd_slid', hidden: true }, { text: '来源单号', dataIndex: 'vd_slcode', width: 150, allowBlank:false, editor:{ displayField : "display", editable : true, format : "", hideTrigger : false, maxLength : 100.0, minValue : null, positiveNum : false, queryMode : "local", store : null, valueField : "value", xtype : "oriOrderMutiDbfindTrigger" } }, { text: '业务类型', dataIndex: "vd_slkind", width: 110 }, { text: "单据日期", dataIndex: "vd_sldate", xtype: 'datecolumn', width: 110 }, { text: "单据金额", xtype: 'numbercolumn', dataIndex: "vd_amount", width: 110, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "已核销金额", xtype: 'numbercolumn', dataIndex: "sl_yamount", width: 110, ignore:true, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "未核销金额", xtype: 'numbercolumn', dataIndex: "sl_namount", width: 110, ignore:true, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "本次核销金额", xtype: 'numbercolumn', dataIndex: "vd_nowbalance", width: 150, editor : { xtype : "numberfield", decimalPrecision: 2 }, allowBlank : false, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }] }, detail2: { xtype: "detailGridField", storeModel: 'saas.model.money.Verification2', detnoColumn: 'vcd_detno', deleteDetailUrl: '/api/money/verification/deleteDetail2', columnWidth: 1, columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '来源ID', dataIndex: 'vcd_slid', hidden: true }, { text: '来源单号', dataIndex: 'vcd_slcode', width: 150, allowBlank:false, editor:{ displayField : "display", editable : true, format : "", hideTrigger : false, maxLength : 100.0, minValue : null, positiveNum : false, queryMode : "local", store : null, valueField : "value", xtype : "oriOrderMutiDbfindTrigger" } }, { text: '业务类型', dataIndex: "vcd_slkind", width: 110 }, { text: "单据日期", dataIndex: "vcd_sldate", xtype: 'datecolumn', width: 110 }, { text: "单据金额", xtype: 'numbercolumn', dataIndex: "vcd_amount", width: 110, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "已核销金额", xtype: 'numbercolumn', dataIndex: "sl_yamount", width: 110, ignore:true, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "未核销金额", xtype: 'numbercolumn', dataIndex: "sl_namount", width: 110, ignore:true, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }, { text: "本次核销金额", dataIndex: "vcd_nowbalance", xtype: 'numbercolumn', width: 150, allowBlank : false, editor : { xtype : "numberfield", decimalPrecision: 2 }, renderer : function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); }, summaryType: 'sum', summaryRenderer: function(v) { var arr = (v + '.').split('.'); var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0'); var format = '0,000.' + xr.join(''); return Ext.util.Format.number(v, format); } }] }, other: [{ xtype: 'textfield', name: 'vc_remark', columnWidth: 1, fieldLabel: '备注' }, { xtype : "hidden", name : "creatorId", fieldLabel : "录入人ID", readOnly:true }, { xtype : "textfield", name : "creatorName", fieldLabel : "录入人", readOnly:true }, { xtype : "datefield", name : "createTime", fieldLabel : "录入日期", readOnly:true, defaultValue: new Date() },{ xtype : "hidden", name : "updaterId", fieldLabel : "更新人ID", readOnly:true },{ xtype : "hidden", name : "updaterName", fieldLabel : "更新人", readOnly:true }, { xtype : "hidden", name : "updateTime", fieldLabel : "更新日期", readOnly:true, defaultValue: new Date() },{ xtype: 'textfield', name: 'vc_auditman', fieldLabel: '审核人', readOnly: true },{ xtype: "datefield", name: "vc_auditdate", fieldLabel: "审核日期", readOnly: true }], // 预收冲应收 receipts_offset_receivable : { main: [{ xtype: 'hidden', fieldLabel: '客户名称', name: 'vc_custid', allowBlank : false, listeners: { change: 'clearDetails' } }, { fieldLabel: '客户编号', xtype: 'hidden', name: 'vc_custcode', }, { fieldLabel: '客户名称', xtype: 'customerDbfindTrigger', name: 'vc_custname', allowBlank : false }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }, { xtype: 'hidden', name: 'vc_amount1', fieldLabel: '核销金额(元)' }, { xtype: "hidden", name: "vc_amount2", fieldLabel: "未核销金额" }], details: ['detail1', 'detail2'], other: ['other'] }, // 预付冲应付 prepaid_offset_payable: { main: [{ xtype: 'hidden', name: 'vc_vendid', fieldLabel: '供应商名称', allowBlank : false, listeners: { change: 'clearDetails' } }, { xtype: "hidden", name: "vc_vendcode", fieldLabel: "供应商编号" }, { xtype: "vendorDbfindTrigger", name: "vc_vendname", fieldLabel: "供应商名称", allowBlank : false }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }, { xtype: 'hidden', name: 'vc_amount1', fieldLabel: '核销金额(元)' }, { xtype: "hidden", name: "vc_amount2", fieldLabel: "未核销金额" }], details: ['detail1', 'detail2'], other: ['other'] }, // 应收冲应付 receivable_offset_payable: { main: [{ fieldLabel: '客户名称', xtype: 'textfield', name: 'vc_custid', hidden: true, listeners: { change: 'clearDetail0' } }, { fieldLabel: '客户编号', xtype: 'textfield', name: 'vc_custcode', hidden: true }, { fieldLabel: '客户名称', xtype: 'customerDbfindTrigger', name: 'vc_custname', allowBlank : false, }, { xtype: 'hidden', name: 'vc_vendid', fieldLabel: '供应商ID', listeners: { change: 'clearDetail1' } }, { xtype: "hidden", name: "vc_vendcode", fieldLabel: "供应商编号" }, { xtype: "vendorDbfindTrigger", name: "vc_vendname", fieldLabel: "供应商名称", allowBlank : false }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }, { xtype: 'hidden', name: 'vc_amount1', fieldLabel: '核销金额(元)' }, { xtype: "hidden", name: "vc_amount2", fieldLabel: "未核销金额" }], details: ['detail1', 'detail2'], other: ['other'] }, // 应收转应收 receivable_to_receivable: { main: [{ fieldLabel: '转出客户', xtype: 'textfield', name: 'vc_custid', hidden: true, listeners: { change: 'clearDetail0' } }, { fieldLabel: '转出客户编号', xtype: 'textfield', name: 'vc_custcode', hidden: true }, { fieldLabel: '转出客户', xtype: 'customerDbfindTrigger', name: 'vc_custname', allowBlank : false, }, { fieldLabel: '转入客户id', xtype: 'textfield', name: 'vc_turncustid', hidden: true }, { fieldLabel: '转入客户编号', xtype: 'textfield', name: 'vc_turncustcode', hidden: true }, { fieldLabel: '转入客户', xtype: 'customerDbfindTrigger', name: 'vc_turncustname', allowBlank : false, }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }, { xtype: 'hidden', name: 'vc_amount1', fieldLabel: '核销金额(元)' }, { xtype: "hidden", name: "vc_amount2", fieldLabel: "未核销金额" }], details: ['detail1'], other: ['other'] }, // 应付转应付 payable_to_payable: { main: [{ fieldLabel: '转出供应商', xtype: 'textfield', name: 'vc_vendid', hidden: true, listeners: { change: 'clearDetail0' } }, { fieldLabel: '转出供应商编号', xtype: 'textfield', name: 'vc_vendcode', hidden: true }, { fieldLabel: '转出供应商', xtype: 'vendorDbfindTrigger', name: 'vc_vendname', allowBlank : false, }, { fieldLabel: '转入供应商id', xtype: 'textfield', name: 'vc_turnvendid', hidden: true }, { fieldLabel: '转入供应商编号', xtype: 'textfield', name: 'vc_turnvendcode', hidden: true }, { fieldLabel: '转入供应商', xtype: 'vendorDbfindTrigger', name: 'vc_turnvendname', allowBlank : false, }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }, { xtype: 'hidden', name: 'vc_amount1', fieldLabel: '核销金额(元)' }, { xtype: "hidden", name: "vc_amount2", fieldLabel: "未核销金额" }], details: ['detail1'], other: ['other'] }, defaultConditions: { receipts_offset_receivable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' + ' and ((sl_kind=\'收款单\') or (sl_kind=\'期初余额\' and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))', 'ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' + ' and (sl_kind in (\'出货单\',\'销售退货单\') or (sl_kind in (\'期初余额\') and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'], prepaid_offset_payable: ['ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' + ' and ((sl_kind=\'付款单\') or (sl_kind=\'期初余额\' and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))', 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' + ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'], receivable_offset_payable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' + ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or (sl_kind=\'期初余额\' and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))', 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' + ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'], receivable_to_receivable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' + ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or (sl_kind=\'期初余额\' and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'], payable_to_payable: ['ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' + ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' + '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'] } }, // initComponent: function() { // this.callParent(arguments); // }, initFormItems: function() { var me = this, cusItems = me.cusItems, defaultItems = me.getAcitveItems(), FormUtil = saas.util.FormUtil; me.detailCount = 0; if(cusItems) { var items = defaultItems || []; Ext.Array.each(cusItems, function(cusItem) { var item = items.find(function(item) { return item.name == cusItem.name; }); Ext.apply(item, cusItem); }); items = FormUtil.applyDefaultItems(me, items); me.removeAll(); me.addItems(items); FormUtil.loadData(me); }else { FormUtil.applyCusItemConfig(me) .then(function(res) { if(res.success) { var config = res.data || true, items = defaultItems || []; if(config) { cusItems = config.items || []; me.cusItems = cusItems; Ext.Array.each(cusItems, function(cusItem) { var item = items.find(function(item) { return item.name == cusItem.name; }); Ext.apply(item, cusItem); }); items = FormUtil.applyDefaultItems(me, items); } me.removeAll(); return me.addItems(items); } }) .then(function(items) { me.fireEvent('afterSetItems', me, items); }) .then(function() { FormUtil.loadData(me); }) .catch(function(response) { saas.util.BaseUtil.showErrorToast('错误:' + response.message); console.error(response); }); } }, getAcitveItems: function() { var me = this, acitveType = me.acitveType || me.defatulType, etc = me.etc, acitveEtc = etc[acitveType], mainItems = acitveEtc.main, details = acitveEtc.details, base = etc.base, detail1 = etc.detail1, detail2 = etc.detail2, other = etc.other, items = []; base[0].defaultValue = acitveType; items = Ext.Array.merge(base, mainItems, (details[0] ? [detail1] : []), (details[1] ? [detail2] : []), other ); return items; }, });