Ext.define('saas.view.money.payBalance.FormPanel', { extend: 'saas.view.core.form.FormPanel', xtype: 'money-paybalance-formpanel', controller: 'money-paybalance-formpanel', viewModel: 'money-paybalance-formpanel', viewName: 'money-paybalance-formpanel', caller: 'PayBalance', //字段属性 _title: '付款单', _idField: 'id', _codeField: 'pb_code', _statusField: 'pb_status', _statusCodeField: 'pb_statuscode', _auditmanField: 'pb_auditman', _auditdateField: 'pb_auditdate', _readUrl: '/api/money/paybalance/read', _saveUrl: '/api/money/paybalance/save', _auditUrl: '/api/money/paybalance/audit', _unAuditUrl: '/api/money/paybalance/unAudit', _deleteUrl: '/api/money/paybalance/delete', initId: 0, toolBtns: [], initComponent: function () { Ext.apply(this, { defaultItems: [{ xtype: 'hidden', name: 'id', fieldLabel: 'id' }, { xtype: 'hidden', name: 'pb_kind', fieldLabel: '单据类型', defaultValue: '付款单', readOnly: true }, { xtype: 'hidden', name: 'pb_vendid', fieldLabel: '供应商ID' }, { xtype: "hidden", name: "pb_vendcode", fieldLabel: "供应商编号" }, { xtype: "vendorDbfindTrigger", name: "pb_vendname", fieldLabel: "供应商名称", allowBlank: false, columnWidth: 0.5, listeners: { change: 'clearDetails' } }, { xtype: 'condbfindtrigger', fieldLabel: '币别汇率', allowBlank: false, dbType: 'currencyDbfindTrigger', dbfinds: [{ from: 'cr_name', to: 'pb_currency' }, { from: 'cr_rate', to: 'pb_rate' }], listeners: { change: 'clearDetails' }, supFieldConfig: { xtype: 'numberfield', readOnly: false, defaultReadOnly: false, decimalPrecision: 6, vtype: 'positiveNumber', listeners: { change: function(f, v) { var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency'); f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency); } } } },{ xtype: "datefield", name: "pb_date", fieldLabel: "日期", defaultValue: new Date(), allowBlank: false }, { xtype: 'textfield', name: 'pb_manname', fieldLabel: '付款人', defaultValue: saas.util.BaseUtil.getCurrentUser().realname }, { xtype: "numberfield", name: "ve_leftamount", fieldLabel: "总欠款(元)", thousandSeparator: ',', ignore: true, readOnly: true }, { xtype: 'hidden', name: 'pb_pdamount', thousandSeparator: ',', fieldLabel: '付款金额(元)' }, { xtype: "hidden", name: "pb_pbdamount", thousandSeparator: ',', fieldLabel: "本次核销金额(元)" }, { xtype: "numberfield", name: "pb_preamount", fieldLabel: "本次预付(元)", thousandSeparator: ',', readOnly: true }, { xtype: 'hidden', name: 'pb_discounts', fieldLabel: '整单折扣(元)', hidden: true }, { xtype: 'hidden', name: 'pb_havebalance', thousandSeparator: ',', fieldLabel: '已核销金额(元)' }, { xtype: "detailGridField", name: 'detail1', storeModel: 'saas.model.money.PayBalance1', detnoColumn: 'pd_detno', deleteDetailUrl: '/api/money/paybalance/deleteDetail1', columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '期间', dataIndex: 'pd_ym', hidden: true, defaultValue: Ext.Date.format(new Date(), 'Ym'), width: 110.0 }, { text: '结算账户ID', dataIndex: 'pd_bankid', hidden: true }, { text: '资金账户', dataIndex: 'pd_bankname', width: 200.0, allowBlank: false, editor: { xtype: 'bandinfoDbfindTrigger' } }, { text: '资金账户编号', dataIndex: 'pd_bankcode', hidden: true }, { text: "付款金额(元)", xtype: 'numbercolumn', dataIndex: "pd_amount", width: 110.0, allowBlank: false, editor: { xtype: "numberfield", decimalPrecision: 2, thousandSeparator: ',' }, 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: "pd_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: "pd_paycode", editor: { xtype: 'textfield' } }, { text: "备注", dataIndex: "pd_remark", width: 250, editor: { xtype: 'textfield' } }, { dataIndex: "pd_text1", text: "自定义字段1", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pd_text2", text: "自定义字段2", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pd_text3", text: "自定义字段3", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pd_text4", text: "自定义字段4", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pd_text5", text: "自定义字段5", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }] }, { xtype: "detailGridField", name: 'detail2', storeModel: 'saas.model.money.PayBalance2', detnoColumn: 'pbd_detno', allowEmpty: true, deleteDetailUrl: '/api/money/paybalance/deleteDetail2', columns: [{ text: 'ID', dataIndex: 'id', hidden: true }, { text: '期间', dataIndex: 'pbd_ym', hidden: true }, { text: '来源ID', dataIndex: 'pbd_slid', hidden: true }, { text: '来源单号', dataIndex: 'pbd_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", // listeners: { // beforetriggerclick: 'vendnamechange' // } }, }, { text: "业务类型", dataIndex: "pbd_slkind", width: 110 }, { text: "单据日期", dataIndex: "pbd_sldate", xtype: 'datecolumn', width: 110 }, { text: "单据金额(元)", xtype: 'numbercolumn', dataIndex: "pbd_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", ignore: true, width: 120, 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: "pbd_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); } }, { text: '备注', dataIndex: 'pbd_remark', width: 250, hidden: true }, { dataIndex: "pbd_text1", text: "自定义字段1", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pbd_text2", text: "自定义字段2", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pbd_text3", text: "自定义字段3", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pbd_text4", text: "自定义字段4", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }, { dataIndex: "pbd_text5", text: "自定义字段5", width: 100, hidden: true, initHidden: false, editor: { xtype: "textfield" }, }] }, { xtype: 'textfield', name: 'pb_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: 'pb_auditman', fieldLabel: '审核人', readOnly: true }, { xtype: "datefield", name: "pb_auditdate", fieldLabel: "审核日期", readOnly: true }, { xtype: "textfield", name: "pb_text1", fieldLabel: "自定义字段1", hidden: true, initHidden: false }, { xtype: "textfield", name: "pb_text2", fieldLabel: "自定义字段2", hidden: true, initHidden: false }, { xtype: "textfield", name: "pb_text3", fieldLabel: "自定义字段3", hidden: true, initHidden: false }, { xtype: "textfield", name: "pb_text4", fieldLabel: "自定义字段4", hidden: true, initHidden: false }, { xtype: "textfield", name: "pb_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_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 ? '大' : '小'; saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?') .then(function (y) { if (y == 'yes') { controller.audit(); } }); } else { controller.audit(); } return false; } });