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', _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', '应付转应付'] ] }], 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, 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.Verification1', 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, 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: "本次核销金额", xtype: 'numbercolumn', dataIndex: "vcd_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); } }] }, other: [{ fieldLabel: '备注', xtype: 'textfield', columnWidth: 1, name: 'vc_remark' }], // 预收冲应收 receipts_offset_receivable : { main: [{ xtype: 'hidden', fieldLabel: '客户名称', name: 'vc_custid', listeners: { change: 'clearDetails' } }, { fieldLabel: '客户编号', xtype: 'hidden', name: 'vc_custcode', }, { fieldLabel: '客户名称', xtype: 'customerDbfindTrigger', name: 'vc_custname', }, { 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'] }, // 预付冲应付 prepaid_offset_payable: { main: [{ xtype: 'hidden', name: 'vc_vendid', fieldLabel: '供应商名称', 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' }], details: ['detail1', 'detail2'] }, // 应收冲应付 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' }, { 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' }], details: ['detail1', 'detail2'] }, // 应收转应收 receivable_to_receivable: { main: [{ fieldLabel: '转出客户', xtype: 'textfield', name: 'vc_outcustid', hidden: true, listeners: { change: 'clearDetail0' } }, { fieldLabel: '转出客户编号', xtype: 'textfield', name: 'vc_outcustcode', hidden: true }, { fieldLabel: '转出客户', xtype: 'customerDbfindTrigger', name: 'vc_outcustname' }, { fieldLabel: '转入客户id', xtype: 'textfield', name: 'vc_turncustid', hidden: true }, { fieldLabel: '转入客户编号', xtype: 'textfield', name: 'vc_turncustcode', hidden: true }, { fieldLabel: '转入客户', xtype: 'customerDbfindTrigger', name: 'vc_turncustname', }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }], details: ['detail1'] }, // 应付转应付 payable_to_payable: { main: [{ fieldLabel: '转出供应商', xtype: 'textfield', name: 'vc_outvendid', hidden: true, listeners: { change: 'clearDetail0' } }, { fieldLabel: '转出供应商编号', xtype: 'textfield', name: 'vc_outvendcode', hidden: true }, { fieldLabel: '转出供应商', xtype: 'vendorDbfindTrigger', name: 'vc_outvendname' }, { fieldLabel: '转入供应商id', xtype: 'textfield', name: 'vc_turnvendid', hidden: true }, { fieldLabel: '转入供应商编号', xtype: 'textfield', name: 'vc_turnvendcode', hidden: true }, { fieldLabel: '转入供应商', xtype: 'vendorDbfindTrigger', name: 'vc_turnvendname', }, { fieldLabel: '日期', xtype: 'datefield', defaultValue: new Date(), allowBlank : false, name: 'vc_date' }], details: ['detail1'] }, defaultConditions: { receipts_offset_receivable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0', 'ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 and sl_kind in (\'期初余额\',\'出货单\',\'销售退货单\')'], prepaid_offset_payable: ['ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0', 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0'], receivable_offset_payable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0', 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0'], receivable_to_receivable: ['ifnull(sl_custid,0)={vc_outcustid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0'], payable_to_payable: ['ifnull(sl_vendtid,0)={vc_outvendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0'] } }, // 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.showToast('错误:' + 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; }, });