Ext.define('saas.view.money.recBalance.FormPanel', { extend: 'saas.view.core.form.FormPanel', xtype: 'money-recbalance-formpanel', controller: 'money-recbalance-formpanel', viewModel: 'money-recbalance-formpanel', viewName: 'money-recbalance-formpanel', caller: 'RecBalance', //字段属性 _title: '收款单', _idField: 'id', _codeField: 'rb_code', _statusField: 'rb_status', _statusCodeField: 'rb_statuscode', _auditmanField: 'rb_auditman', _auditdateField: 'rb_auditdate', _readUrl: '/api/money/recbalance/read', _saveUrl: '/api/money/recbalance/save', _auditUrl: '/api/money/recbalance/audit', _unAuditUrl: '/api/money/recbalance/unAudit', _deleteUrl: '/api/money/recbalance/delete', initId: 0, initComponent: function () { Ext.apply(this, { defaultItems: [{ xtype: 'hidden', name: 'id', fieldLabel: 'id' }, { xtype: 'hidden', name: 'rb_custid', fieldLabel: '客户ID' }, { xtype: 'hidden', name: 'rb_kind', fieldLabel: '单据类型', defaultValue: '收款单', readOnly: true }, { xtype: 'hidden', name: 'rb_custcode', fieldLabel: '客户编号' }, { xtype: "customerDbfindTrigger", name: "rb_custname", fieldLabel: "客户名称", allowBlank: false, listeners: { change: 'clearDetails' } }, { xtype: "numberfield", name: "cu_leftamount", fieldLabel: "总欠款", thousandSeparator: ',', ignore: true, readOnly: true }, { xtype: 'hidden', name: 'rb_rbdamount', fieldLabel: '本次核销金额(元)', thousandSeparator: ',' }, { xtype: 'hidden', name: 'rb_rdamount', fieldLabel: '本次付款金额(元)', thousandSeparator: ',' }, { xtype: "datefield", name: "rb_date", fieldLabel: "日期", defaultValue: new Date(), allowBlank: false }, { xtype: "textfield", name: "rb_manname", fieldLabel: "收款人", defaultValue: saas.util.BaseUtil.getCurrentUser().realname }, { xtype: "numberfield", name: "rb_discounts", fieldLabel: "整单折扣", hidden: true }, { xtype: 'numberfield', name: 'rb_preamount', fieldLabel: '本次预收款', readOnly: true }, { xtype: 'hidden', name: 'rb_havebalance', fieldLabel: '已核销金额(元)' }, { xtype: "detailGridField", name: 'detail1', storeModel: 'saas.model.money.RecBalance1', detnoColumn: 'rd_detno', deleteDetailUrl: '/api/money/recbalance/deleteDetail1', columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '期间', dataIndex: 'rd_ym', defaultValue: Ext.Date.format(new Date(), 'Ym'), width: 110, hidden: true }, { text: '资金账户ID', dataIndex: 'rd_bankid', editor: { xtype: 'numberfield' }, hidden: true }, { text: '资金账户编号', dataIndex: 'rd_bankcode', editor: { xtype: 'textfield' }, hidden: true }, { text: '资金账户', dataIndex: 'rd_bankname', allowBlank: false, width: 200, editor: { xtype: 'bandinfoDbfindTrigger' } }, { text: "收款金额(元)", xtype: 'numbercolumn', dataIndex: "rd_amount", width: 110.0, allowBlank: false, editor: { xtype: "numberfield", decimalPrecision: 2 }, renderer: function(v, m, r) { return saas.util.BaseUtil.numberFormat(v, 2, true); }, summaryType: 'sum', summaryRenderer: function(v, d, f, m) { return saas.util.BaseUtil.numberFormat(v, 2, true); } }, { text: "结算方式", dataIndex: "rd_paymethod", width: 150.0, editor: { xtype: 'combo', queryMode: 'local', displayField: 'display', valueField: 'value', store: Ext.create('Ext.data.Store', { fields: ['value', 'display'], data: [{ value: "信用卡", display: "信用卡" }, { value: "支票", display: "支票" }, { value: "汇票", display: "汇票" }, { value: "现金", display: "现金" }, { value: "银行转账", display: "银行转账" }, { value: "支付宝转账", display: "支付宝转账" }, { value: "微信转账", display: "微信转账" }] }) } }, { text: "结算号", dataIndex: "rd_paycode", editor: { xtype: 'textfield' } }, { text: "备注", dataIndex: "rd_remark", width: 250, editor: { xtype: 'textfield' } }, { dataIndex: "rd_text1", text: "自定义字段1", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rd_text2", text: "自定义字段2", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rd_text3", text: "自定义字段3", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rd_text4", text: "自定义字段4", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rd_text5", text: "自定义字段5", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }] }, { xtype: "detailGridField", name: 'detail2', storeModel: 'saas.model.money.RecBalance2', detnoColumn: 'rbd_detno', allowEmpty: true, deleteDetailUrl: '/api/money/recbalance/deleteDetail2', columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '期间', dataIndex: 'rbd_ym', editor: { xtype: 'numberfield' }, hidden: true }, { text: '来源ID', dataIndex: 'rbd_slid', editor: { xtype: 'numberfield' }, hidden: true }, { text: '来源单号', dataIndex: 'rbd_slcode', width: 200, editor: { displayField: "display", editable: true, format: "", hideTrigger: false, maxLength: 100.0, minValue: null, positiveNum: false, queryMode: "local", store: null, valueField: "value", xtype: "oriOrderMutiDbfindTrigger", listeners: { beforetriggerclick: 'custnamechange' } } }, { text: "业务类型", dataIndex: "rbd_slkind", width: 110 }, { text: "单据日期", dataIndex: "rbd_sldate", xtype: 'datecolumn', width: 110 }, { text: "单据金额(元)", xtype: 'numbercolumn', dataIndex: "rbd_amount", width: 110, renderer: function(v, m, r) { return saas.util.BaseUtil.numberFormat(v, 2, true); }, summaryType: 'sum', summaryRenderer: function(v, d, f, m) { return saas.util.BaseUtil.numberFormat(v, 2, true); } }, { text: "已核销金额(元)", xtype: 'numbercolumn', dataIndex: "sl_yamount", width: 120, ignore: true, renderer: function(v, m, r) { return saas.util.BaseUtil.numberFormat(v, 2, true); }, summaryType: 'sum', summaryRenderer: function(v, d, f, m) { return saas.util.BaseUtil.numberFormat(v, 2, true); } }, { text: "未核销金额(元)", xtype: 'numbercolumn', dataIndex: "sl_namount", width: 120, ignore: true, renderer: function(v, m, r) { return saas.util.BaseUtil.numberFormat(v, 2, true); }, summaryType: 'sum', summaryRenderer: function(v, d, f, m) { return saas.util.BaseUtil.numberFormat(v, 2, true); } }, { text: "本次核销金额(元)", xtype: 'numbercolumn', dataIndex: "rbd_nowbalance", width: 140, editor: { xtype: "numberfield", decimalPrecision: 2 }, allowBlank: false, renderer: function(v, m, r) { return saas.util.BaseUtil.numberFormat(v, 2, true); }, summaryType: 'sum', summaryRenderer: function(v, d, f, m) { return saas.util.BaseUtil.numberFormat(v, 2, true); } }, { dataIndex: "rbd_text1", text: "自定义字段1", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rbd_text2", text: "自定义字段2", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rbd_text3", text: "自定义字段3", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rbd_text4", text: "自定义字段4", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "rbd_text5", text: "自定义字段5", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }] }, { xtype: 'textfield', name: 'rb_remark', fieldLabel: '备注', columnWidth: 1 }, { 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: 'rb_auditman', fieldLabel: '审核人', readOnly: true }, { xtype: "datefield", name: "rb_auditdate", fieldLabel: "审核日期", readOnly: true }, { xtype: "textfield", name: "rb_text1", fieldLabel: "自定义字段1", hidden: true, initHidden: false }, { xtype: "textfield", name: "rb_text2", fieldLabel: "自定义字段2", hidden: true, initHidden: false }, { xtype: "textfield", name: "rb_text3", fieldLabel: "自定义字段3", hidden: true, initHidden: false }, { xtype: "textfield", name: "rb_text4", fieldLabel: "自定义字段4", hidden: true, initHidden: false }, { xtype: "textfield", name: "rb_text5", fieldLabel: "自定义字段5", hidden: true, initHidden: false }], }); this.callParent(arguments); }, beforeAudit: function () { var form = this, idField = form._idField, controller = form.getController(), viewModel = form.getViewModel(), id = viewModel.get(idField); store1 = viewModel.get('detail0').detailStore, store2 = viewModel.get('detail1').detailStore; // 已保存过的单据不进行此项校验 if (id) { return true; } 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') { controller.audit(); } }); } else { controller.audit(); } return false; } });