Ext.namespace('Shipping'); Shipping.FeeEditGrid = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.FeeEditGrid.superclass.constructor.call(this); }; Ext.extend(Shipping.FeeEditGrid, Ext.Panel, { ParentWin: null, //弹出式 ParentPanel: null, //Tab页编辑模式 OpStatus: 'add', StoreBill: null, StoreCustType: null, EditRecord: null, RefBillNo: '*', DataLoading: true, stroplb: '', strBSNO: '', WMSOUTBSNO: '', feeType: 0, OprationSwap: function () { var ret = new Array(); ret[0] = this.stroplb; ret[1] = this.feeType; ret[2] = this.storeDrChFee; ret[3] = this.storeCrChFee; return ret; }, // region: 'center', initUIComponents: function () { this.feeDrSerialNo = 0; this.feeDrBodyDel = []; this.feeCrSerialNo = 0; this.feeCrBodyDel = []; this.StoreDrOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsChFee/GetFeeOpRang' } }); this.StoreCrOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeOP', proxy: { url: '/MvcShipping/MsChFee/GetFeeOpRang' } }); this.StoreCustType = Ext.create('Ext.data.Store', { fields: ['SCUSTTYPE', 'CUSTTYPE', 'CUSTNAME'] }); this.comboxCustType = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCustType, forceSelection: true, name: 'CustomerType', valueField: 'CUSTTYPE', displayField: 'SCUSTTYPE' }); this.StoreFeeFrt = Ext.create('Ext.data.Store', { fields: ['Frt'] }); this.StoreFeeFrt.add({ "Frt": "PP" }); this.StoreFeeFrt.add({ "Frt": "CC" }); this.comboxFeeFrt = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreFeeFrt, forceSelection: true, name: 'FeeFrt', valueField: 'Frt', displayField: 'Frt' }); this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' } }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, forceSelection: true, name: 'FeeName', valueField: 'Name', displayField: 'CodeAndName' }); this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustomerNameRef.load({ params: { condition: ""} }); this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCustomerNameRef, forceSelection: true, name: 'CustomerName', valueField: 'CustName', displayField: 'CodeAndName' }); this.StoreUnit = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeUnit', proxy: { url: '/MvcShipping/MsChFee/GetCtnUnitList' } }); this.comboxUnit = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreUnit, name: 'Unit', valueField: 'UNIT', displayField: 'SUNIT' }); this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeDateCurrList' } }); this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr.load({ params: { condition: ""} }); this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCurr, forceSelection: true, name: 'Currency', valueField: 'CURR', displayField: 'CURR' }); //明细表-数据集 this.storeDrChFee = Ext.create('Ext.data.Store', { model: 'MsChFeeImport', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetImportDataList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); this.storeCrChFee = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetDataList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); this.storeChFeeGain = Ext.create('Ext.data.Store', { model: 'MsChFeeGain', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetGainData', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); this.storeChFeeModify = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetModifyData', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); this.cellEditingDrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.feeDrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _thisfee = this; this.girdDrcolums = [{ sortable: true, dataIndex: 'GId', header: '惟一编号', hidden: true, width: 160 }, { sortable: true, dataIndex: 'BsNo', header: '业务编号', hidden: true, width: 200 }, { sortable: true, dataIndex: 'FeeStatus', header: '费用状态', renderer: function (value, p, record) { return record.data.FeeStatus_Ref; }, width: 66 }, { sortable: true, dataIndex: 'FeeName', header: '应收费用名称', editor: this.comboxFeeNameRef, width: 90 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', editor: this.comboxCustType, // hidden: true, width: 75 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', editor: this.comboxCustomerNameRef, width: 110 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', editor: this.comboxUnit, width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '不含税单价', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, decimalPrecision: 4, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 8) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 8) } } } }, renderer: Ext.util.Format.numberRenderer('00.0000'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'TaxRate', header: '税率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 9) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 9) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 60 }, { sortable: true, dataIndex: 'TaxUnitPrice', header: '单价', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, decimalPrecision: 4, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 10) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 10) } } } }, renderer: Ext.util.Format.numberRenderer('00.0000'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Quantity', header: '数量', editor: { xtype: 'numberfield', keyNavEnabled: false, allowDecimals: true, decimalPrecision: 4, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 11) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 11) } } } }, width: 60 }, { sortable: true, dataIndex: 'NoTaxAmount', header: '不含税金额', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 12) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 12) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Amount', header: '金额', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 13) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 13) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Currency', header: '币别', editor: this.comboxCurr, width: 40 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, decimalPrecision: 6, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 15) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 15) } } } }, renderer: Ext.util.Format.numberRenderer('00.000000'), align: 'right', width: 60 }, { sortable: true, dataIndex: 'AccTaxRate', header: '销项税率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 16) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 16) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 17) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 17) } } } }, width: 150 }, { sortable: true, dataIndex: 'FeeDescription', header: '费用英文名称', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 18) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 18) } } } }, width: 150 }, { sortable: true, dataIndex: 'IsAdvancedpay', header: '是否垫付', editor: { xtype: 'checkboxfield' // selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'IsInvoice', header: '不开发票', width: 60 }, { sortable: true, dataIndex: 'FeeFrt', header: 'FRT', editor: this.comboxFeeFrt, width: 40 }, { sortable: true, dataIndex: 'Commissionrate', header: '佣金比率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(1, 20) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(1, 20) } } } }, width: 60 }, { sortable: true, dataIndex: 'OpName', header: '录入人', width: 60 }, { sortable: true, dataIndex: 'EnterDate', header: '录入日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 80 }, { sortable: true, dataIndex: 'Settlement', header: '结算金额', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Invoice', header: '已开票金额', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'InvoiceNum', header: '发票号码', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSER', header: '修改人', width: 60 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '修改日期', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), width: 130 }, { dataIndex: 'UNINVOICE', header: '未开票金额', width: 60, renderer: function (value, cellmeta) { if (value == 0) { return " *已开票 "; } else return value; } }, { sortable: true, dataIndex: 'SALESNO', header: '销售单号', width: 125 }, { sortable: true, dataIndex: 'DELIVERYNO', header: '提货单号', width: 125 } ]; this.gridDrChFee = new Ext.grid.GridPanel({ store: this.storeDrChFee, enableHdMenu: false, region: 'center', id: 'gridDrChFee', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingDrChFee], selModel: this.feeDrGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return Shipping.FeeGetRowClass(feeStatus); } }, tbar: [{ xtype: 'label', text: '应收费用', style: 'font-size:18px', labelColor: '#000', //style:'background-color: #4b9bf5', x: '5%', y: '5%' }, { text: '', tooltip: '添加应收费用', iconCls: "btnadd", handler: function (button, event) { this.onAddDetailClick(button, event, 1); }, scope: this }, '-', { text: '', tooltip: '保存应收费用', iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event, 1); }, scope: this }, '-', { text: '', tooltip: '删除应收费用', iconCls: "btndelete", handler: function (button, event) { this.onDelDetailClick(button, event, 1); }, scope: this }, '-', { text: '', tooltip: '取消修改', iconCls: "btncancel", handler: function (button, event) { this.onCancelDetailClick(button, event, 1); }, scope: this }, '-', { text: '', tooltip: '刷新应收', iconCls: "btnrefresh", handler: function (button, event) { //this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb} }); this.LoadDrChFee(button, event); }, scope: this }, '-', { text: '', tooltip: '打印应收', iconCls: "btnprint", menu: [ { text: "打印应收账单", menu: [//海运进口应收应付列表 {text: "所选应收打印", handler: function (menu, event) { _thisfee.onPrintSelectDetailClick(menu, event, 1); } }, { text: "应收客户打印", handler: function (menu, event) { _thisfee.onPrintCustDetailClick(menu, event, 1); } }, { text: "所有应收打印", handler: function (menu, event) { _thisfee.onPrintAllDetailClick(menu, event, 1); } } ] }, '-', { text: "利润核算单打印", handler: function (menu, event) { _thisfee.onPrintGainClick(menu, event, 1); } } ], /* handler: function (button, event) { this.onPrintDetailClick(button, event, 1); }, */ scope: this }, '-', { text: '提交审核', tooltip: '提交审核', menu: [ { text: "提交审核", handler: function (menu, event) { _thisfee.onSubmitAuditNewClick(menu, event, 1); } }, { text: "全部提交", handler: function (menu, event) { _thisfee.onSubmitAuditAllClick(menu, event, 1); } }, { text: "撤销提交", handler: function (menu, event) { _thisfee.onCancelAuditNewClick(menu, event, 1); } }], scope: this }, '-', { text: '申请修改', tooltip: '申请修改', handler: function (button, event) { this.onShenModifyClick(button, event, 1); }, scope: this }, '-', { text: '申请删除', tooltip: '申请删除', handler: function (button, event) { this.onShenDeleteClick(button, event, 1); }, scope: this }, '-', { text: '取消申请', tooltip: '取消申请', handler: function (button, event) { this.onCancelShenClick(button, event, 1); }, scope: this }, '-', { text: '不开发票', tooltip: '不开发票', menu: [ { text: '不开发票', tooltip: '不开发票', handler: function (button, event) { this.onNoIvoiceClick(button, event, 1); }, scope: this }, { text: '解禁发票', tooltip: '解禁发票', handler: function (button, event) { this.onCancelNoIvoiceClick(button, event, 1); }, scope: this }], scope: this }, '-', { text: '历史申请', tooltip: '历史申请', handler: function (button, event) { this.onHistryShenClick(button, event, 1); }, scope: this }, '-', { text: '查看信息', tooltip: '查看信息', handler: function (button, event) { this.onViewDetailClick(button, event, 1); }, scope: this }, '-', { text: '引入费用', tooltip: '引入费用', menu: [ { text: "历史引入", handler: function (menu, event) { _thisfee.onHistryAddDetailClick(menu, event, 1); } }, { text: "引入费用模板", handler: function (menu, event) { _thisfee.onTemplateAddDetailClick(menu, event, 1); } }, '-', { text: "生成应付", menu: [ { text: "所选生成应付", handler: function (menu, event) { _thisfee.onAddSelectDetailClick(menu, event, 2); } }, { text: "所有生成应付", handler: function (menu, event) { _thisfee.onAddAllDetailClick(menu, event, 2); } } ] } ], /* handler: function (button, event) { this.onCopyAddClick(button, event, 1); }, */ scope: this }, '-', { text: '保存列表', tooltip: '保存列表', handler: function (button, event) { DsTruck.SaveGridPanel(GID, 'FEEDRGRID', this.gridDrChFee.columns, this.girdDrcolums, 0, true); }, scope: this } , '-', { text: '费用提交至销售助理', tooltip: '将在采购合同下录入的应收,根据结算对象和销售取用记录,关联到相应的销售单内', menu: [ { text: "提交费用", handler: function (menu, event) { _thisfee.SetSALESNO(menu, event); } }, { text: "取消提交", handler: function (menu, event) { _thisfee.UnSetSALESNO(menu, event); } } ], /* handler: function (button, event) { this.onCopyAddClick(button, event, 1); }, */ scope: this } ], columns: this.girdDrcolums }); this.girdDrcolums = DsTruck.GetGridPanel(GID, 'FEEDRGRID', this.girdDrcolums, 0); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridDrChFee.reconfigure(this.storeDrChFee, this.girdDrcolums); this.gridDrChFee.on('edit', function (editor, e, eOpts) { this.gridListChFeeAfterEdit(editor, e, eOpts); }, this); this.cellEditingDrChFee.on('beforeedit', function (editor, e) { return this.cellEditingChFeeBeforeEdit(editor, e); }, this); this.cellEditingCrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.feeCrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _thisfee = this; this.girdCrcolums = [{ sortable: true, dataIndex: 'GId', header: '惟一编号', hidden: true, width: 160 }, { sortable: true, dataIndex: 'BsNo', header: '业务编号', hidden: true, width: 200 }, { sortable: true, dataIndex: 'FeeStatus', header: '费用状态', renderer: function (value, p, record) { return record.data.FeeStatus_Ref; }, width: 66 }, { sortable: true, dataIndex: 'FeeName', header: '应付费用名称', editor: this.comboxFeeNameRef, width: 100 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', editor: this.comboxCustType, // hidden: true, width: 80 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', editor: this.comboxCustomerNameRef, width: 120 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', editor: this.comboxUnit, width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '不含税单价', editor: { xtype: 'numberfield', allowDecimals: true, //这里允许保留3位小数,所以你输入11.996就不会进位了 decimalPrecision: 6, keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 8) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 8) } } } }, renderer: Ext.util.Format.numberRenderer('00.000000'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'TaxRate', header: '税率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 9) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 9) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 60 }, { sortable: true, dataIndex: 'TaxUnitPrice', header: '单价', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, decimalPrecision: 4, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 10) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 10) } } } }, renderer: Ext.util.Format.numberRenderer('00.0000'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Quantity', header: '数量', editor: { xtype: 'numberfield', keyNavEnabled: false, allowDecimals: true, decimalPrecision: 4, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 11) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 11) } } } }, width: 60 }, { sortable: true, dataIndex: 'NoTaxAmount', header: '不含税金额', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, enableKeyEvents: true, hideTrigger: true, mouseWheelEnabled: false, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 12) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 12) } } } }, //renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Amount', header: '金额', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 13) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 13) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Currency', header: '币别', editor: this.comboxCurr, width: 40 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, decimalPrecision: 6, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 15) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 15) } } } }, renderer: Ext.util.Format.numberRenderer('00.000000'), align: 'right', width: 60 }, { sortable: true, dataIndex: 'AccTaxRate', header: '进项税率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 16) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 16) } } } }, renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 17) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 17) } } } }, width: 150 }, { sortable: true, dataIndex: 'FeeDescription', header: '费用英文名称', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 18) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 18) } } } }, width: 150 }, { sortable: true, dataIndex: 'IsAdvancedpay', header: '是否垫付', editor: { xtype: 'checkboxfield' // selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'IsInvoice', header: '不开发票', width: 60 }, { sortable: true, dataIndex: 'FeeFrt', header: 'FRT', editor: this.comboxFeeFrt, width: 40 }, { sortable: true, dataIndex: 'Commissionrate', header: '佣金比率', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, enableKeyEvents: true, hideTrigger: true, mouseWheelEnabled: false, listeners: { keydown: function (textField, e) { if (e.getKey() == 40) { _thisfee.onNextKeyClick(2, 21) } else if (e.getKey() == 38) { _thisfee.onUpKeyClick(2, 21) } } } }, width: 60 }, { sortable: true, dataIndex: 'OpName', header: '录入人', width: 60 }, { sortable: true, dataIndex: 'EnterDate', header: '录入日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 80 }, { sortable: true, dataIndex: 'Settlement', header: '结算金额', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'Invoice', header: '已开票金额', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OrderAmount', header: '申请金额', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSER', header: '修改人', width: 60 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '修改日期', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), width: 130 }, { dataIndex: 'UNINVOICE', header: '未开票金额', width: 60, renderer: function (value, cellmeta) { if (value == 0) { return " *已开票 "; } else return value; } } ]; this.gridCrChFee = new Ext.grid.GridPanel({ store: this.storeCrChFee, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingCrChFee], selModel: this.feeCrGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return Shipping.FeeGetRowClass(feeStatus); } }, tbar: [{ xtype: 'label', text: '应付费用', style: 'font-size:18px', labelColor: '#000', //style:'background-color: #4b9bf5', x: '5%', y: '5%' }, { text: '', tooltip: '添加应付费用', iconCls: "btnadd", handler: function (button, event) { this.onAddDetailClick(button, event, 2); }, scope: this }, '-', { text: '', tooltip: '保存应付费用', iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event, 2); }, scope: this }, '-', { text: '', tooltip: '删除应付费用', iconCls: "btndelete", handler: function (button, event) { this.onDelDetailClick(button, event, 2); }, scope: this }, '-', { text: '', tooltip: '取消修改', iconCls: "btncancel", handler: function (button, event) { this.onCancelDetailClick(button, event, 2); }, scope: this }, '-', { text: '', tooltip: '刷新应付', iconCls: "btnrefresh", handler: function (button, event) { //this.storeCrChFee.load({ params: { billno: this.strBSNO, type: 2, optype: this.stroplb} }); this.LoadCrChFee(button, event); }, scope: this }, '-', { text: '', tooltip: '打印应付', iconCls: "btnprint", menu: [ { text: "打印应付账单", menu: [ { text: "所选应付打印", handler: function (menu, event) { _thisfee.onPrintSelectDetailClick(menu, event, 2); } }, { text: "应付客户打印", handler: function (menu, event) { _thisfee.onPrintCustDetailClick(menu, event, 2); } }, { text: "所有应付打印", handler: function (menu, event) { _thisfee.onPrintAllDetailClick(menu, event, 2); } } ] }, '-', { text: "利润核算单打印", handler: function (menu, event) { _thisfee.onPrintGainClick(menu, event, 1); } } ], scope: this }, '-', { text: '提交审核', tooltip: '提交审核', menu: [ { text: "提交审核", handler: function (menu, event) { _thisfee.onSubmitAuditNewClick(menu, event, 2); } }, { text: "全部提交", handler: function (menu, event) { _thisfee.onSubmitAuditAllClick(menu, event, 1); } }, { text: "撤销提交", handler: function (menu, event) { _thisfee.onCancelAuditNewClick(menu, event, 2); } }], scope: this }, '-', { text: '申请修改', tooltip: '申请修改', handler: function (button, event) { this.onShenModifyClick(button, event, 2); }, scope: this }, '-', { text: '申请删除', tooltip: '申请删除', handler: function (button, event) { this.onShenDeleteClick(button, event, 2); }, scope: this }, '-', { text: '取消申请', tooltip: '取消申请', handler: function (button, event) { this.onCancelShenClick(button, event, 2); }, scope: this }, '-', { text: '不开发票', tooltip: '不开发票', menu: [ { text: '不开发票', tooltip: '不开发票', handler: function (button, event) { this.onNoIvoiceClick(button, event, 2); }, scope: this }, { text: '解禁发票', tooltip: '解禁发票', handler: function (button, event) { this.onCancelNoIvoiceClick(button, event, 2); }, scope: this }], scope: this }, '-', { text: '历史申请', tooltip: '历史申请', handler: function (button, event) { this.onHistryShenClick(button, event, 2); }, scope: this }, '-', { text: '查看信息', tooltip: '查看信息', handler: function (button, event) { this.onViewDetailClick(button, event, 2); }, scope: this }, '-', { text: '引入费用', tooltip: '引入费用', menu: [ { text: "历史引入", handler: function (menu, event) { _thisfee.onHistryAddDetailClick(menu, event, 2); } }, { text: "引入费用模板", handler: function (menu, event) { _thisfee.onTemplateAddDetailClick(menu, event, 2); } }, '-', { text: "生成应收", menu: [ { text: "所选生成应收", handler: function (menu, event) { _thisfee.onAddSelectDetailClick(menu, event, 1); } }, { text: "所有生成应收", handler: function (menu, event) { _thisfee.onAddAllDetailClick(menu, event, 1); } } ] } ], scope: this }, '-', { text: '保存列表', tooltip: '保存列表', handler: function (button, event) { DsTruck.SaveGridPanel(GID, 'FEECRGRID', this.gridCrChFee.columns, this.girdCrcolums, 0, true); }, scope: this }], columns: this.girdCrcolums }); this.girdCrcolums = DsTruck.GetGridPanel(GID, 'FEECRGRID', this.girdCrcolums, 0); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridCrChFee.reconfigure(this.storeCrChFee, this.girdCrcolums); this.gridCrChFee.on('edit', function (editor, e, eOpts) { this.gridListChFeeAfterEdit(editor, e, eOpts); }, this); this.cellEditingCrChFee.on('beforeedit', function (editor, e) { return this.cellEditingChFeeBeforeEdit(editor, e); }, this); //#endregion this.storeBodySum = Ext.create('Ext.data.Store', { model: 'MsOPGain', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetOPGainList', reader: { root: 'data', totalProperty: 'totalCount' } } }); this.gridSum = new Ext.grid.GridPanel({ store: this.storeBodySum, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: [{ header: "总 计", sortable: false, align: 'center', dataIndex: 'CURR', width: 160 }, { text: '应 收', columns: [{ header: '不含税', dataIndex: 'NORATEDR', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 160 }, { header: '含税', dataIndex: 'DR', align: 'right', renderer: Ext.util.Format.numberRenderer('00.00'), width: 160 }] }, { text: '应 付', columns: [{ header: '不含税', dataIndex: 'NORATECR', align: 'right', renderer: Ext.util.Format.numberRenderer('00.00'), width: 160 }, { header: '含税', dataIndex: 'CR', align: 'right', renderer: Ext.util.Format.numberRenderer('00.00'), width: 160 }] }, { text: '利 润', columns: [{ header: '不含税', dataIndex: 'NORATEPR', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 160 }, { header: '含税', dataIndex: 'PR', align: 'right', renderer: Ext.util.Format.numberRenderer('00.00'), width: 160 }] } ] }); //定义Grid this.gridListCust = new Ext.grid.GridPanel({ store: this.storeChFeeGain, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, // features: [{ // ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 // }], columns: [{ sortable: true, dataIndex: 'CUSTOMERNAME', header: '结算对象', // summaryRenderer: function () { // return '合计' // }, width: 110 }, { sortable: true, dataIndex: 'RMBDR', header: 'RMB应收', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'RMBCR', header: 'RMB应付', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'RMBPROFIT', header: 'RMB利润', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDDR', header: 'USD应收', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDCR', header: 'USD应付', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDPROFIT', header: 'USD利润', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTDR', header: '其他币别应收', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTCR', header: '其他币别应付', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTPROFIT', header: '其他币别利润', renderer: Ext.util.Format.numberRenderer('00.00'), // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'TTLDR', header: '合计应收', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'TTLCR', header: '合计应付', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'TTLPROFIT', header: '合计利润', renderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 } ], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeChFeeGain, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.panelCustSum = new Ext.Panel({ title: '客户合计', layout: "border", region: 'center', animate: true, autoScroll: true, // containerScroll: true, frame: false, items: [this.gridListCust] }); this.panelCurrSum = new Ext.Panel({ title: '币别合计', layout: "border", region: 'center', animate: true, autoScroll: true, // containerScroll: true, frame: false, items: [this.gridSum] }); this.tabTotal = new Ext.TabPanel({ activeTab: 0, autoWidth: true, border: true, height: 210, frame: false, region: 'south', enableHdMenu: false, // region: 'center', title: "利润统计", collapsed: true, collapsible: true, split: true, enableTabScroll: true, items: [ this.panelCustSum, this.panelCurrSum ] }); // this.formtotal = Ext.widget('form', { // region: 'south', // title: "利润统计", // //height: 150, // items: [this.tabTotal] // }); //#region 申请修改和删除界面 this.comboxFeeFrtModify = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreFeeFrt, forceSelection: true, fieldLabel: 'FRT', name: 'FeeFrt', valueField: 'Frt', displayField: 'Frt' }); this.comboxFeeNameRefModify = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, fieldLabel: '费用名称', forceSelection: true, name: 'FeeName', valueField: 'Name', displayField: 'CodeAndName' }); this.storeCustomerNameRefM = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustomerNameRefM.load({ params: { condition: ""} }); this.comboxCustomerNameRefModify = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCustomerNameRefM, forceSelection: true, fieldLabel: '结费对象', name: 'CustomerName', valueField: 'CustName', displayField: 'CodeAndName' }); this.comboxUnitModify = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreUnit, fieldLabel: '单位标准', name: 'Unit', valueField: 'UNIT', displayField: 'SUNIT' }); this.CheckIsAdvancedpay = new Ext.form.Checkbox({ fieldLabel: '是否垫付', uncheckedValue: 'false', inputValue: 'true', name: 'IsAdvancedpay' }); this.comboxCurrModify = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCurr, fieldLabel: '币别', forceSelection: true, name: 'Currency', valueField: 'CURR', displayField: 'CURR', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { if (this.DataLoading == true) return; var CURR = records[0].data.CURR; var form = _thisfee.NewFeeEdit.getForm(); if (CURR == 'RMB') { form.findField('ExChangerate').setValue(1); } else { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', CURR); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; form.findField('ExChangerate').setValue(DEFRATE); } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', CURR); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; form.findField('ExChangerate').setValue(DEFRATE); } else { form.findField('ExChangerate').setValue(1); } } } } } } }); _thisfee = this; this.NewFeeEdit = Ext.widget('form', { frame: true, region: 'center', trackResetOnLoad: true, title: '费用新值', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BsNo', hidden: true }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'FeeType', name: 'FeeType', flex: 0, hidden: true, margins: '0' }, this.comboxFeeNameRefModify, this.comboxCustomerNameRefModify, this.comboxUnitModify] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '不含税单价', xtype: 'numberfield', name: 'UnitPrice', listeners: { scope: this, 'change': function (ths, newValue, oldValue, eOpts) { if (this.DataLoading == true) return; if (newValue == oldValue) return; var form = _thisfee.NewFeeEdit.getForm(); var unitPrice = newValue; var FeeName = form.findField('FeeName').getValue(); var quantity = form.findField('Quantity').getValue(); var taxrate = form.findField('TaxRate').getValue(); this.DataLoading = true; if (taxrate != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var TaxUnitPrice = (parseFloat(unitPrice).mul(taxrateb)).toFixed(2); form.findField('TaxUnitPrice').setValue(TaxUnitPrice); } var notaxamount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); form.findField('NoTaxAmount').setValue(notaxamount); taxrate = parseFloat(taxrate) / 100; var tax = parseFloat(notaxamount).mul(taxrate); var amount = (parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); form.findField('Amount').setValue(amount); this.DataLoading = false; } } }, { fieldLabel: '税率', xtype: 'numberfield', name: 'TaxRate', listeners: { scope: this, 'change': function (ths, newValue, oldValue, eOpts) { if (this.DataLoading == true) return; if (newValue == oldValue) return; var form = _thisfee.NewFeeEdit.getForm(); var unitPrice = form.findField('UnitPrice').getValue(); var FeeName = form.findField('FeeName').getValue(); var quantity = form.findField('Quantity').getValue(); var taxrate = newValue; this.DataLoading = true; if (unitPrice != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var TaxUnitPrice = (parseFloat(unitPrice).mul(taxrateb)).toFixed(2); form.findField('TaxUnitPrice').setValue(TaxUnitPrice); } var notaxamount = form.findField('NoTaxAmount').getValue(); taxrate = parseFloat(taxrate) / 100; var tax = parseFloat(notaxamount).mul(taxrate); var amount = (parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); form.findField('Amount').setValue(amount); this.DataLoading = false; } } }, { fieldLabel: '含税单价', xtype: 'numberfield', name: 'TaxUnitPrice', listeners: { scope: this, 'change': function (ths, newValue, oldValue, eOpts) { if (this.DataLoading == true) return; if (newValue == oldValue) return; var form = _thisfee.NewFeeEdit.getForm(); var quantity = form.findField('Quantity').getValue(); var TaxUnitPrice = newValue; var taxrate = form.findField('TaxRate').getValue(); this.DataLoading = true; if (TaxUnitPrice != 0) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); form.findField('UnitPrice').setValue(unitPrice); } if (quantity != null) { var amount = (parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); form.findField('Amount').setValue(amount); var notaxamount = (parseFloat(amount).div(taxrateb)).toFixed(2); form.findField('NoTaxAmount').setValue(notaxamount); } this.DataLoading = false; } } } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '计费数量', xtype: 'numberfield', name: 'Quantity', listeners: { scope: this, 'change': function (ths, newValue, oldValue, eOpts) { if (this.DataLoading == true) return; if (newValue == oldValue) return; var form = _thisfee.NewFeeEdit.getForm(); var unitPrice = form.findField('UnitPrice').getValue(); var FeeName = form.findField('FeeName').getValue(); var quantity = newValue; var taxrate = form.findField('TaxRate').getValue(); this.DataLoading = true; if (taxrate != null) { var taxrateb = parseFloat(1 + parseFloat(taxrate / 100)); var TaxUnitPrice = (parseFloat(unitPrice).mul(taxrateb)).toFixed(2); form.findField('TaxUnitPrice').setValue(TaxUnitPrice); } var notaxamount = (parseFloat(unitPrice).mul(quantity)).toFixed(2); form.findField('NoTaxAmount').setValue(notaxamount); taxrate = parseFloat(taxrate) / 100; var tax = parseFloat(notaxamount).mul(taxrate); var amount = (parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); form.findField('Amount').setValue(amount); this.DataLoading = false; } } }, { fieldLabel: '不含税金额', xtype: 'numberfield', name: 'NoTaxAmount', listeners: { scope: this, 'change': function (ths, newValue, oldValue, eOpts) { if (this.DataLoading == true) return; if (newValue == oldValue) return; var form = _thisfee.NewFeeEdit.getForm(); var notaxamount = newValue; var taxrate = form.findField('TaxRate').getValue(); this.DataLoading = true; if (taxrate != null) { taxrate = parseFloat(taxrate) / 100; var tax = parseFloat(notaxamount).mul(taxrate); var amount = (parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); form.findField('Amount').setValue(amount); } this.DataLoading = false; } } }, { fieldLabel: '含税金额', xtype: 'numberfield', name: 'Amount' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCurrModify, { fieldLabel: '汇率', xtype: 'numberfield', name: 'ExChangerate' }, { fieldLabel: '财务税率', xtype: 'numberfield', name: 'AccTaxRate' }, this.CheckIsAdvancedpay ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '修改原因', name: 'Reason' }] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.OldFee = Ext.widget('form', { frame: true, region: 'center', title: '费用旧值', trackResetOnLoad: true, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BsNo', hidden: true }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用名称', readOnly: true, name: 'FeeName' }, { fieldLabel: '费用对象', readOnly: true, name: 'CustomerName' }, { fieldLabel: '单位标准', readOnly: true, name: 'Unit' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '不含税单价', readOnly: true, name: 'UnitPrice' }, { fieldLabel: '税率', readOnly: true, name: 'TaxRate' }, { fieldLabel: '含税单价', readOnly: true, name: 'TaxUnitPrice' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '计费数量', readOnly: true, name: 'Quantity' }, { fieldLabel: '不含税金额', readOnly: true, name: 'NoTaxAmount' }, { fieldLabel: '含税金额', readOnly: true, name: 'Amount' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '币别', readOnly: true, name: 'Currency' }, { fieldLabel: '汇率', readOnly: true, name: 'ExChangerate' }, { fieldLabel: '财务税率', readOnly: true, name: 'AccTaxRate' }, { fieldLabel: '是否垫付', readOnly: true, name: 'IsAdvancedpay' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.DeleteFee = Ext.widget('form', { frame: true, region: 'center', trackResetOnLoad: true, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BsNo', hidden: true }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'FeeType', name: 'FeeType', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用名称', name: 'FeeName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用对象', name: 'CustomerName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '单位标准', name: 'Unit', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '不含税单价', name: 'UnitPrice', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '税率', name: 'TaxRate', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '含税单价', name: 'TaxUnitPrice', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '计费数量', name: 'Quantity', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '不含税金额', name: 'NoTaxAmount', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '含税金额', name: 'Amount', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '币别', name: 'Currency', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '汇率', name: 'ExChangerate', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '财务税率', name: 'AccTaxRate', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '是否垫付', name: 'IsAdvancedpay', flex: 0, hidden: true, margins: '0' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '删除原因', name: 'Reason' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.NewFeeShowDr = Ext.widget('form', { frame: true, region: 'east', hidden: true, title: '费用修改新值', width: 600, trackResetOnLoad: true, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BsNo', hidden: true }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用名称', readOnly: true, name: 'FeeName' }, { fieldLabel: '费用对象', readOnly: true, name: 'CustomerName' }, { fieldLabel: '单位标准', readOnly: true, name: 'Unit' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '不含税单价', readOnly: true, name: 'UnitPrice' }, { fieldLabel: '税率', readOnly: true, name: 'TaxRate' }, { fieldLabel: '含税单价', readOnly: true, name: 'TaxUnitPrice' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '计费数量', readOnly: true, name: 'Quantity' }, { fieldLabel: '不含税金额', readOnly: true, name: 'NoTaxAmount' }, { fieldLabel: '含税金额', readOnly: true, name: 'Amount' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '币别', readOnly: true, name: 'Currency' }, { fieldLabel: '汇率', readOnly: true, name: 'ExChangerate' }, { fieldLabel: '财务税率', readOnly: true, name: 'AccTaxRate' }, { fieldLabel: '是否垫付', readOnly: true, name: 'IsAdvancedpay' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '修改原因', readOnly: true, name: 'Reason' }] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.NewFeeShowCr = Ext.widget('form', { frame: true, region: 'east', hidden: true, title: '费用修改新值', width: 600, trackResetOnLoad: true, bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BsNo', hidden: true }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用名称', readOnly: true, name: 'FeeName' }, { fieldLabel: '费用对象', readOnly: true, name: 'CustomerName' }, { fieldLabel: '单位标准', readOnly: true, name: 'Unit' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '不含税单价', readOnly: true, name: 'UnitPrice' }, { fieldLabel: '税率', readOnly: true, name: 'TaxRate' }, { fieldLabel: '含税单价', readOnly: true, name: 'TaxUnitPrice' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '计费数量', readOnly: true, name: 'Quantity' }, { fieldLabel: '不含税金额', readOnly: true, name: 'NoTaxAmount' }, { fieldLabel: '含税金额', readOnly: true, name: 'Amount' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '币别', readOnly: true, name: 'Currency' }, { fieldLabel: '汇率', readOnly: true, name: 'ExChangerate' }, { fieldLabel: '财务税率', readOnly: true, name: 'AccTaxRate' }, { fieldLabel: '是否垫付', readOnly: true, name: 'IsAdvancedpay' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '修改原因', readOnly: true, name: 'Reason' }] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; this.winShenModifyShow = Ext.create('Ext.window.Window', { title: "费用申请修改", width: 600, //height : 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", layout: "anchor", items: [this.OldFee, this.NewFeeEdit], buttons: [{ text: "提交申请", minWidth: 70, handler: function () { var form = me.NewFeeEdit.getForm(); var FeeName = form.findField('FeeName').getValue(); if (FeeName == '' || FeeName == null || FeeName == undefined) { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var CustomerName = form.findField('CustomerName').getValue(); if (CustomerName == '' || CustomerName == null || CustomerName == undefined) { Ext.Msg.show({ title: '提示', msg: '结费对象不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var TaxRate = form.findField('TaxRate').getValue(); if (TaxRate == null || TaxRate == undefined) { Ext.Msg.show({ title: '提示', msg: '税率不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = form.findField('Currency').getValue(); if (Currency == '' || Currency == null || Currency == undefined) { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = form.findField('ExChangerate').getValue(); if (ExChangerate == '' || ExChangerate == null || ExChangerate == undefined) { Ext.Msg.show({ title: '提示', msg: '汇率不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var REASON = form.findField('Reason').getValue(); if (REASON == '' || REASON == null || REASON == undefined) { Ext.Msg.show({ title: '提示', msg: '修改原因不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var type = form.findField('FeeType').getValue(); me.onCreateModifyClick(type); } }, { text: "取消申请", minWidth: 70, handler: function () { me.winShenModifyShow.close(); } }] }); this.winShenDeleteShow = Ext.create('Ext.window.Window', { title: "费用申请删除", width: 600, //height : 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", layout: "anchor", items: [this.DeleteFee], buttons: [{ text: "提交申请", minWidth: 70, handler: function () { var form = me.DeleteFee.getForm(); var REASON = form.findField('Reason').getValue(); if (REASON == '' || REASON == null || REASON == undefined) { Ext.Msg.show({ title: '提示', msg: '删除原因不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var type = form.findField('FeeType').getValue(); me.onCreateDeleteClick(type); } }, { text: "取消申请", minWidth: 70, handler: function () { me.winShenDeleteShow.close(); } }] }); //#endregion this.panelDrChFee = new Ext.Panel({ //title: '应收费用', layout: "border", anchor: '100% 50%', frame: true, split: true, items: [this.gridDrChFee, this.NewFeeShowDr] }); this.panelCrChFee = new Ext.Panel({ //title: '应付费用', layout: "border", anchor: '100% 50%', // region: 'center', frame: true, items: [this.gridCrChFee, this.NewFeeShowCr] }); this.panelFee = new Ext.Panel({ // layout: "border", layout: "anchor", // region: 'north', // height: 560, region: 'center', items: [ this.panelDrChFee, this.panelCrChFee ] }); //#region 布局 Ext.apply(this, { items: [this.panelFee, this.tabTotal] }); //#endregion this.opStatus = 'add'; /* parentWin = window.parent.opener; { if (parentWin) { var ret = parentWin.OprationSwap(); var fun = ret[4]; } } */ _thisfee = this; this.gridDrChFee.getSelectionModel().on('select', function (model, record, index) { var FeeStatus = record.data.FeeStatus; var GId = record.data.GId; if (FeeStatus == 3) { this.NewFeeShowDr.setVisible(true); this.storeChFeeModify.load({ params: { FeeID: GId, ApplyType: 2 }, callback: function (r, options, success) { if (success) { _thisfee.NewFeeShowDr.getForm().loadRecord(_thisfee.storeChFeeModify.getAt(0)); } }, scope: this }); } else { this.NewFeeShowDr.setVisible(false); } }, this); this.gridCrChFee.getSelectionModel().on('select', function (model, record, index) { var FeeStatus = record.data.FeeStatus; var GId = record.data.GId; if (FeeStatus == 3) { this.NewFeeShowCr.setVisible(true); this.storeChFeeModify.load({ params: { FeeID: GId, ApplyType: 2 }, callback: function (r, options, success) { if (success) { _thisfee.NewFeeShowCr.getForm().loadRecord(_thisfee.storeChFeeModify.getAt(0)); } }, scope: this }); } else { this.NewFeeShowCr.setVisible(false); } }, this); this.InitData(); }, //end initUIComponents //#region 加载数据 InitData: function () { var condition = ''; /* if (this.ParentPanel) { var ret = this.ParentPanel.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; this.RefBillNo = ret[3]; } */ this.LoadData(this.opStatus, condition, this.RefBillNo); }, //end InitData LoadData: function (opstatus, condition, refbillno) { this.feeCrSerialNo = 0; this.feeCrBodyDel = []; this.feeCrSerialNo = 0; this.feeCrBodyDel = []; this.opStatus = opstatus; // var el = Ext.get("gridDrChFee"); /* this.storeDrChFee.load({ params: { billno: this.gid, type: 1} }); this.storeCrChFee.load({ params: { billno: this.gid, type: 2} }); this.storeChFeeGain.load({ params: { bsno: this.gid }, callback: function (r, options, success) { if (success) { this.formtotal.getForm().loadRecord(this.storeChFeeGain.getAt(0)); } }, scope: this }); */ }, // end LoadDate //#endregion //#region 明细操作 onNextKeyClick: function (type, col) { if (type == 1) { var rows = this.gridDrChFee.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridDrChFee.getStore(); var number = s.indexOf(row) + 1; if (number == this.gridDrChFee.getStore().getCount()) { this.onAddDetailClick(s, event, type); } else { this.cellEditingDrChFee.startEditByPosition({ row: number, column: col }); } } else { var rows = this.gridCrChFee.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridCrChFee.getStore(); var number = s.indexOf(row) + 1; if (number == this.gridCrChFee.getStore().getCount()) { this.onAddDetailClick(s, event, type); } else { this.cellEditingCrChFee.startEditByPosition({ row: number, column: col }); } } }, onUpKeyClick: function (type, col) { if (type == 1) { var rows = this.gridDrChFee.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridDrChFee.getStore(); var number = s.indexOf(row) - 1; if (number < 0) number = 0; this.cellEditingDrChFee.startEditByPosition({ row: number, column: col }); } else { var rows = this.gridCrChFee.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridCrChFee.getStore(); var number = s.indexOf(row) - 1; if (number < 0) number = 0; this.cellEditingCrChFee.startEditByPosition({ row: number, column: col }); } }, onAddDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var custtype = ''; if (type == 1) custtype = '委托单位' else custtype = '订舱代理' var records = DsStoreQueryBy(this.StoreCustType, 'CUSTTYPE', custtype); if (records.getCount() > 0) { var data = records.getAt(0).data; var custname = this.EditRecord.get(data.CUSTNAME); } else { var custname = ''; } var newSerialno = this.GetHandleSerialNo(store); var newsort = store.getCount() + 1; var myDate = new Date(); var record = null; record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: type, FeeName: '', FeeDescription: '', CustomerType: custtype, CustomerName: custname, Unit: '', UnitPrice: 0, TaxUnitPrice: 0, Quantity: 1, TaxRate: 0, NoTaxAmount: 0, Amount: 0, AccTaxRate: 0, Currency: 'RMB', ExChangerate: 1, Reason: '', Remark: '', Commissionrate: 0, Settlement: 0, Invoice: 0, OrderAmount: 0, OrderInvoice: 0, SubmitDate: null, Auditoperator: '', AuditDate: null, EnteroPerator: USERID, OpName: SHOWNAME, EnterDate: myDate, DebitNo: '', IsDebit: "0", IsOpen: "0", IsAdvancedpay: "false", Sort: newSerialno, IsInvoice: "0", FeeFrt: '', IsCrmOrderFee: "0", AuditStatus: 0, InvoiceNum: '', ChequeNum: '', WmsOutBsNo: this.WMSOUTBSNO, UNINVOICE: -1 }); store.add(record); var editColumnIndex = 0; var cellediting = null; if (type == 1) { cellediting = this.cellEditingDrChFee; editColumnIndex = 4; } else if (type == 2) { cellediting = this.cellEditingCrChFee; editColumnIndex = 4; } var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex }); }, onAddSelectDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var selectedRecords = []; var storeadd = null; if (type == 2) { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; storeadd = this.storeCrChFee; } else if (type == 1) { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; storeadd = this.storeDrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var myDate = new Date(); for (var i = 0; i < selectedRecords.length; i++) { var memberyf = selectedRecords[i]; var custtype = ''; if (type == 1) custtype = '委托单位' else custtype = '订舱代理' var records = DsStoreQueryBy(this.StoreCustType, 'CUSTTYPE', custtype); if (records.getCount() > 0) { var data = records.getAt(0).data; var custname = this.EditRecord.get(data.CUSTNAME); } else { var custname = ''; } var newSerialno = this.GetHandleSerialNo(storeadd); var newsort = storeadd.getCount() + 1; var record = null; record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: type, FeeName: memberyf.data.FeeName, FeeDescription: memberyf.data.FeeDescription, CustomerType: custtype, CustomerName: custname, Unit: memberyf.data.Unit, UnitPrice: memberyf.data.UnitPrice, TaxUnitPrice: memberyf.data.TaxUnitPrice, Quantity: memberyf.data.Quantity, TaxRate: memberyf.data.TaxRate, NoTaxAmount: memberyf.data.NoTaxAmount, Amount: memberyf.data.Amount, AccTaxRate: memberyf.data.AccTaxRate, Currency: memberyf.data.Currency, ExChangerate: memberyf.data.ExChangerate, Reason: '', Remark: '', Commissionrate: memberyf.data.Commissionrate, Settlement: 0, Invoice: 0, OrderAmount: 0, OrderInvoice: 0, SubmitDate: null, Auditoperator: '', AuditDate: null, EnteroPerator: USERID, OpName: SHOWNAME, EnterDate: myDate, DebitNo: '', IsDebit: "0", IsOpen: "0", IsAdvancedpay: "false", Sort: newSerialno, IsInvoice: "0", FeeFrt: memberyf.data.FeeFrt, IsCrmOrderFee: "0", AuditStatus: 0, InvoiceNum: '', ChequeNum: '', WmsOutBsNo: this.WMSOUTBSNO }); storeadd.add(record); }; var editColumnIndex = 0; var cellediting = null; if (type == 2) { cellediting = this.cellEditingDrChFee; editColumnIndex = 4; } else if (type == 1) { cellediting = this.cellEditingCrChFee; editColumnIndex = 4; } var n = storeadd.getCount(); cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex }); this.calcDetailTotal(); }, onAddAllDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; var storeadd = null; if (type == 2) { store = this.storeDrChFee; storeadd = this.storeCrChFee; } else if (type == 1) { store = this.storeCrChFee; storeadd = this.storeDrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var myDate = new Date(); for (i = 0; i < store.getCount(); i += 1) { var memberyf = store.getAt(i); var custtype = ''; if (type == 1) custtype = '委托单位' else custtype = '订舱代理' var records = DsStoreQueryBy(this.StoreCustType, 'CUSTTYPE', custtype); if (records.getCount() > 0) { var data = records.getAt(0).data; var custname = this.EditRecord.get(data.CUSTNAME); } else { var custname = ''; } var newSerialno = this.GetHandleSerialNo(storeadd); var newsort = storeadd.getCount() + 1; var record = null; record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: type, FeeName: memberyf.data.FeeName, FeeDescription: memberyf.data.FeeDescription, CustomerType: custtype, CustomerName: custname, Unit: memberyf.data.Unit, UnitPrice: memberyf.data.UnitPrice, TaxUnitPrice: memberyf.data.TaxUnitPrice, Quantity: memberyf.data.Quantity, TaxRate: memberyf.data.TaxRate, NoTaxAmount: memberyf.data.NoTaxAmount, Amount: memberyf.data.Amount, AccTaxRate: memberyf.data.AccTaxRate, Currency: memberyf.data.Currency, ExChangerate: memberyf.data.ExChangerate, Reason: '', Remark: '', Commissionrate: memberyf.data.Commissionrate, Settlement: 0, Invoice: 0, OrderAmount: 0, OrderInvoice: 0, SubmitDate: null, Auditoperator: '', AuditDate: null, EnteroPerator: USERID, OpName: SHOWNAME, EnterDate: myDate, DebitNo: '', IsDebit: "0", IsOpen: "0", IsAdvancedpay: "false", Sort: newSerialno, IsInvoice: "0", FeeFrt: memberyf.data.FeeFrt, IsCrmOrderFee: "0", AuditStatus: 0, InvoiceNum: '', ChequeNum: '', WmsOutBsNo: this.WMSOUTBSNO }); storeadd.add(record); }; var editColumnIndex = 0; var cellediting = null; if (type == 2) { cellediting = this.cellEditingDrChFee; editColumnIndex = 4; } else if (type == 1) { cellediting = this.cellEditingCrChFee; editColumnIndex = 4; } var n = storeadd.getCount(); cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex }); this.calcDetailTotal(); }, onHistryAddDetailClick: function (menu, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } this.feeType = type; var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } if (this.stroplb == 'op_Seae') { DsOpenEditWin("/MvcShipping/MsSeaeFee/HistryIndex", "历史引入费用"); } else if (this.stroplb == 'op_Apply') { DsOpenEditWin("/MvcShipping/MsOpApply/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_Seai') { DsOpenEditWin("/MvcShipping/MsOpSeai/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_Bulk') { DsOpenEditWin("/MvcShipping/MsOpBulk/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_other') { DsOpenEditWin("/MvcShipping/MsOpOther/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_railway') { DsOpenEditWin("/MvcShipping/MsOpRailway/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_aire') { DsOpenEditWin("/MvcShipping/MsOpAire/HistryFeeIndex", "历史引入费用"); } else if (this.stroplb == 'op_airi') { DsOpenEditWin("/MvcShipping/MsOpAiri/HistryFeeIndex", "历史引入费用"); } }, onTemplateAddDetailClick: function (menu, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } this.feeType = type; var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } window.open('/MvcShipping/MsFeeTemplate/AddFeeIndex', "模板引入费用", 'width=1200,height=800,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes'); // DsOpenEditWin("/MvcShipping/MsFeeTemplate/AddFeeIndex", "模板引入费用"); }, onCancelDetailClick: function (menu, event, type) { var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onCancelDetailClick)的参数type类型设置的不对'); return; } for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); member.reject(); } this.calcDetailTotal(); }, GetHandleSerialNo: function (store) { var result = 0; if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (parseInt(member.data.Sort) > parseInt(result)) { result = member.data.Sort; } } } result = parseInt(result) + 1; return result; }, onDelDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var feeGidSql = ''; var selectedRecords = []; if (type == '1') { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; var candelete = this.CheckChFeeDelete(selectedRecords, 1); if (candelete == false) return; } else if (type == '2') { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; var candelete = this.CheckChFeeDelete(selectedRecords, 2); if (candelete == false) return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要删除选中的费用吗?', function (btn) { if (btn == 'yes') { if (selectedRecords.length > 0) { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BsNo == "*") //如果是新增但没有保存的数据,没有必要提交到后台 { if (type == '1') { this.storeDrChFee.remove(selectedRecords[i]); } else if (type == '2') { this.storeCrChFee.remove(selectedRecords[i]); } this.calcDetailTotal(); } else { var feeGId = "'" + rec.data.GId + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } } } } _thisfee = this; Ext.Msg.wait('正在删除数据...'); if (feeGidSql != '') { Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsChFee/Delete', params: { bsno: _thisfee.strBSNO, data: feeGidSql }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { if (type == '1') { this.storeDrChFee.remove(selectedRecords[i]); } else if (type == '2') { this.storeCrChFee.remove(selectedRecords[i]); } } // this.calcDetailTotal(); this.storeChFeeGain.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); this.storeBodySum.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } else { Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } }, this); }, CheckChFeeDelete: function (records, type) { for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var canDelete = feeStatus == 1 || feeStatus == 6; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只能删除费用状态为[录入状态]和[驳回提交]的费用,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); if (canDelete) { var op = rec.data.EnteroPerator; var opname = rec.data.OpName; if (type == 1) { var recop = DsStoreQueryBy(this.StoreDrOpRange, 'OPID', op); if (recop.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限删除' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canDelete = false; } } else if (type == 2) { var recop = DsStoreQueryBy(this.StoreCrOpRange, 'OPID', op); if (recop.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限删除' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canDelete = false; } } } return false; } } return true; }, onPostDetailClick: function (button, event, type) { var bodyDrChFeeDatas = []; var i; if (type == '1') { for (i = 0; i < this.storeDrChFee.getCount(); i += 1) { var memberyf = this.storeDrChFee.getAt(i); bodyDrChFeeDatas.push(memberyf); var ExChangerate = memberyf.data.ExChangerate; }; var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas); } else if (type == '2') { for (i = 0; i < this.storeCrChFee.getCount(); i += 1) { var memberyf = this.storeCrChFee.getAt(i); bodyDrChFeeDatas.push(memberyf); var amount = memberyf.data.Amount; var ExChangerate = memberyf.data.ExChangerate; }; var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas); }; _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsChFee/Save', scope: this, params: { bsno: _thisfee.strBSNO, type: type, chfeebody: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { if (type == '1') { for (var i = 0; i < this.storeDrChFee.getCount(); i += 1) { var member = this.storeDrChFee.getAt(i); member.set("BsNo", _thisfee.strBSNO); member.commit(); } } else if (type == '2') { for (var i = 0; i < this.storeCrChFee.getCount(); i += 1) { var member = this.storeCrChFee.getAt(i); member.set("BsNo", _thisfee.strBSNO); member.commit(); } } this.storeChFeeGain.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); this.storeBodySum.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save onShenModifyClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var selectedRecords = []; if (type == '1') { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; } if (selectedRecords.count == 0) { Ext.Msg.show({ title: '提示', msg: '没有选择要申请修改的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var rec = selectedRecords[0]; if (rec.data.FeeStatus != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用状态无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.Settlement != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已结算无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.IsDebit == 'True') { Ext.Msg.show({ title: '提示', msg: '当前费用已対帐无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.Invoice != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已开出发票无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.OrderAmount != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已申请费用无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.OrderInvoice != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已申请开票无法申请修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.DataLoading = true; this.NewFeeEdit.getForm().loadRecord(rec); this.OldFee.getForm().loadRecord(rec); this.DataLoading = false; this.winShenModifyShow.show(); }, onCreateModifyClick: function (type) { var feeGIdSql = ''; var form = this.NewFeeEdit.getForm(); var data = this.NewFeeEdit.getForm().getValues(); var olddata = this.OldFee.getForm().getValues(); _thisfee = this; Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_Audit/ShenModify', params: { data: Ext.JSON.encode(data), olddata: Ext.JSON.encode(olddata), optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) //_this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb} }); _thisfee.LoadDrChFee(); if (type == 2) //_this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb} }); _thisfee.LoadCrChFee(); _thisfee.winShenModifyShow.close(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onShenDeleteClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var selectedRecords = []; if (type == '1') { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; } if (selectedRecords.count == 0) { Ext.Msg.show({ title: '提示', msg: '没有选择要申请删除的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var rec = selectedRecords[0]; if (rec.data.FeeStatus != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用状态无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.Settlement != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已结算无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.Invoice != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已开出发票无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.IsDebit == 'True') { Ext.Msg.show({ title: '提示', msg: '当前费用已対帐无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.OrderAmount != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已申请费用无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (rec.data.OrderInvoice != 0) { Ext.Msg.show({ title: '提示', msg: '当前费用已申请开票无法申请删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } this.DataLoading = true; this.DeleteFee.getForm().loadRecord(rec); this.DataLoading = false; this.winShenDeleteShow.show(); }, onCreateDeleteClick: function (type) { var feeGIdSql = ''; var form = this.DeleteFee.getForm(); var data = this.DeleteFee.getForm().getValues(); _thisfee = this; Ext.Ajax.request({ waitMsg: '正在申请删除...', url: '/Account/Chfee_Audit/ShenDelete', params: { data: Ext.JSON.encode(data), optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) //_this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb} }); _thisfee.LoadDrChFee(); if (type == 2) //_this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb} }); _thisfee.LoadCrChFee(); _thisfee.winShenDeleteShow.close(); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onCancelShenClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var selectedRecords = []; if (type == '1') { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; } if (selectedRecords.count == 0) { Ext.Msg.show({ title: '提示', msg: '没有选择要取消申请的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var rec = selectedRecords[0]; if (rec.data.FeeStatus != 3 && rec.data.FeeStatus != 4) { Ext.Msg.show({ title: '提示', msg: '当前费用状态无法取消申请!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } // var bodyDrChFeeDatas = []; // bodyDrChFeeDatas.push(rec); // var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas); Ext.Ajax.request({ waitMsg: '正在取消申请...', url: '/Account/Chfee_Audit/CancelShen', params: { Feeid: rec.data.GId, optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { /* _this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb }, callback: function (r, options, success) { if (success) { if (r.length > 0) { _this.storeDrChFee.getSelectionModel().select(0); } else { } } }, scope: this });*/ this.LoadDrChFee(button, event); this.NewFeeShowDr.setVisible(false); } if (type == 2) { /* _this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb }, callback: function (r, options, success) { if (r.length > 0) { _this.storeCrChFee.getSelectionModel().select(0); } else { } }, scope: this });*/ this.LoadCrChFee(button, event); this.NewFeeShowCr.setVisible(false); } } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, onViewDetailClick: function (button, event, type) { var openSet = "height=540, width=890, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 540) / 2 + ",Left= " + (screen.width - 890) / 2 var openType = "_blank"; //打开费用“历史信息查询”页面 var openUrl = "../../Shipping/FeeHistory.aspx?bsno=" + this.strBSNO + "&oplb=" + this.stroplb + "&type=" + type; window.open(openUrl, openType, openSet); }, getAllowOperationDetail: function () { var feeStatus = this.getFeeStatus(); if (feeStatus == '0' || feeStatus == '') return true; else { Ext.Msg.show({ title: '错误', msg: "此票委托已费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return false; } }, //#endregion //#region 表格的AfterEdit gridListChFeeAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; //var BSNO = e.record.get('BSNO'); if (e.field == 'UnitPrice') { var unitPrice = e.record.data['UnitPrice']; var quantity = e.record.data['Quantity']; var taxrate = e.record.data['TaxRate']; if (taxrate != null) { var taxrateb = Add(1, Div(taxrate, 100)); //parseFloat(1 + parseFloat(taxrate).mul(0.01)); var TaxUnitPrice = Mul(unitPrice, taxrateb); //(parseFloat(unitPrice).mul(taxrateb)).toFixed(2); e.record.set('TaxUnitPrice', TaxUnitPrice); } var notaxamount = Mul(unitPrice, quantity); //(parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('NoTaxAmount', notaxamount); ////taxrate = Div(taxrate, 100); //parseFloat(taxrate).mul(0.01); // tax = notaxamount * taxrate; var tax = Div(Mul(notaxamount, taxrate), 100); //parseFloat(notaxamount).mul(taxrate); var amount = Add(notaxamount, tax); //(parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2);// e.record.set('Amount', Ext.util.Format.number(amount, '0.00')); e.record.set('Amount', amount); this.calcDetailTotal(); } else if (e.field == 'TaxUnitPrice') { var TaxUnitPrice = e.record.data['TaxUnitPrice']; if (e.value != 0) { var quantity = e.record.data['Quantity']; var taxrate = e.record.data['TaxRate']; var taxrateb = Add(1, Div(taxrate, 100), 4); //parseFloat(1 + parseFloat(taxrate).mul(0.01)); var unitPrice = Div(TaxUnitPrice, taxrateb); //(parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2); e.record.set('UnitPrice', unitPrice); if (quantity != null) { var amount = Mul(TaxUnitPrice, quantity); //(parseFloat(TaxUnitPrice).mul(quantity)).toFixed(2); e.record.set('Amount', amount); var notaxamount = Div(amount, taxrateb); //(parseFloat(amount).div(taxrateb)).toFixed(2); e.record.set('NoTaxAmount', notaxamount); } this.calcDetailTotal(); } } else if (e.field == 'Quantity') { var unitPrice = e.record.data['UnitPrice']; var quantity = e.record.data['Quantity']; var TaxUnitPrice = e.record.data['TaxUnitPrice']; var taxrate = e.record.data['TaxRate']; if (taxrate != null) { var taxrateb = Add(1, Div(taxrate, 100)); if ((TaxUnitPrice == null || TaxUnitPrice == 0 || TaxUnitPrice == NaN) && (unitPrice != null)) { var TaxUnitPrice = Mul(unitPrice, taxrateb); e.record.set('TaxUnitPrice', TaxUnitPrice); } } if (unitPrice != null) { var notaxamount = Mul(unitPrice, quantity); //(parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('NoTaxAmount', notaxamount); } if (TaxUnitPrice != null) { var amount = Mul(TaxUnitPrice, quantity); //(parseFloat(unitPrice).mul(quantity)).toFixed(2); e.record.set('Amount', amount); } this.calcDetailTotal(); } else if (e.field == 'FeeName') { var records = DsStoreQueryBy(this.storeFeeNameRef, 'Name', e.value); var FEENAME = e.value; if (records.getCount() > 0) { var data = records.getAt(0).data; var Currency = data.DefaultCurr; var Description = data.Description; var DEFAULTUNIT = data.DefaultUnit; var UNIT = ''; var custtype = ''; var FeeType = e.record.data['FeeType']; var codeFEETYPE = data.FEETYPE; //alert(codeFEETYPE); e.record.set('Currency', Currency); e.record.set('FeeDescription', Description); if (DEFAULTUNIT == "1" || DEFAULTUNIT == "11") { e.record.set('Unit', "单票"); e.record.set('Quantity', 1); UNIT = '单票'; } else if (DEFAULTUNIT == "2") { e.record.set('Unit', "重量"); UNIT = '重量'; //设置重量,如果是进口的设置净重 Quantity //获取业务类型 获取重量 设置 } else if (DEFAULTUNIT == "5") { e.record.set('Unit', "TEU"); UNIT = 'TEU'; //设置数量 //获取业务类型 获取所有集装箱信息 折算TEU } else if (DEFAULTUNIT == "6") { e.record.set('Unit', "净重"); UNIT = '净重'; //如果是进口的设置净重 } else if (DEFAULTUNIT == "10" || DEFAULTUNIT == "3") { e.record.set('Unit', "尺码"); UNIT = '尺码'; //如果是进口的设置净重 } else if (DEFAULTUNIT == "9") { var Unitrecords = DsStoreQueryLikeBy(this.StoreUnit, 'UNIT', 1, '2'); if (Unitrecords.getCount() > 0) { var ffdata = Unitrecords.getAt(0).data; var aUNIT = ffdata.UNIT; e.record.set('Unit', aUNIT); UNIT = aUNIT; } else { var Unitrecords = DsStoreQueryLikeBy(this.StoreUnit, 'UNIT', 1, '4'); if (Unitrecords.getCount() > 0) { var ffdata = Unitrecords.getAt(0).data; var aUNIT = ffdata.UNIT; e.record.set('Unit', aUNIT); UNIT = aUNIT; } } //如果是进口的设置净重 } else { e.record.set('Unit', DEFAULTUNIT); UNIT = DEFAULTUNIT; } if (Currency != 'RMB') { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', Currency); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; e.record.set('ExChangerate', DEFRATE); } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', Currency); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; e.record.set('ExChangerate', DEFRATE); } else { e.record.set('ExChangerate', 0); } } } else { e.record.set('ExChangerate', 1); }; var Unitrecords = DsStoreQueryBy(this.StoreUnit, 'UNIT', UNIT); var QUANTITY = 1; if (Unitrecords.getCount() > 0) { var Unitdata = Unitrecords.getAt(0).data; QUANTITY = Unitdata.QUANTITY; if ((UNIT == '重量') && (QUANTITY == 0)) { Unitrecords = DsStoreQueryBy(this.StoreUnit, 'UNIT', '净重'); if (Unitrecords.getCount() > 0) { Unitdata = Unitrecords.getAt(0).data; QUANTITY = Unitdata.QUANTITY; } } e.record.set('Quantity', QUANTITY); } else { e.record.set('Quantity', 1); } var taxrate = e.record.data['TaxRate']; if (taxrate == null) taxrate = 0; var unitPrice = e.record.data['UnitPrice']; var notaxamount = Mul(unitPrice, QUANTITY); //(parseFloat(unitPrice).mul(QUANTITY)).toFixed(2); if (notaxamount == null || notaxamount == NaN) notaxamount = 0; e.record.set('NoTaxAmount', notaxamount); //taxrate = parseFloat(taxrate) / 100; var tax = Mul3(notaxamount, taxrate, 0.01); //parseFloat(notaxamount).mul(taxrate); var amount = Add(notaxamount, tax); //(parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); if (amount == null || amount == NaN) amount = 0; e.record.set('Amount', amount); this.calcDetailTotal(); if (codeFEETYPE == "普通") { e.record.set('IsAdvancedpay', "False"); } else { e.record.set('IsAdvancedpay', "True"); } } else { e.record.set('Currency', 'RMB'); e.record.set('FeeDescription', ''); } } else if (e.field == 'TaxRate') { var taxrate = e.record.data['TaxRate']; var unitPrice = e.record.data['UnitPrice']; var quantity = e.record.data['Quantity']; if (unitPrice != null) { var taxrateb = Add(1, Div(taxrate, 100, 4), 4); //parseFloat(1 + parseFloat(taxrate).mul(0.01)); var TaxUnitPrice = Mul(unitPrice, taxrateb); //(parseFloat(unitPrice).mul(taxrateb)).toFixed(2); e.record.set('TaxUnitPrice', TaxUnitPrice); } var notaxamount = e.record.data['NoTaxAmount']; ////taxrate = Div(taxrate, 100); //parseFloat(taxrate).mul(0.01); var tax = Div(Mul(notaxamount, taxrate), 100); //parseFloat(notaxamount).mul(taxrate); var amount = Add(notaxamount, tax); //(parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); e.record.set('Amount', amount); this.calcDetailTotal(); } else if (e.field == 'NoTaxAmount') { var taxrate = e.record.data['TaxRate']; var notaxamount = e.record.data['NoTaxAmount']; ////taxrate = parseFloat(taxrate).mul(0.01); var tax = Div(Mul(notaxamount, taxrate), 100); //parseFloat(notaxamount).mul(taxrate); var amount = Add(notaxamount, tax); //(parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); e.record.set('Amount', amount); /* var amount = parseFloat(notaxamount) + parseFloat(notaxamount * taxrate / 100); e.record.set('Amount', Ext.util.Format.number(amount, '0.00')); */ this.calcDetailTotal(); } else if (e.field == 'Amount') { var taxrate = e.record.data['TaxRate']; var amount = e.record.data['Amount']; if (taxrate != null) { var taxrateb = Add(1, Mul(taxrate, 0.01)); //parseFloat(1 + parseFloat(taxrate.mul(0.01))); var notaxamount = Div(amount, taxrateb); //(parseFloat(amount).div(taxrateb)).toFixed(2); e.record.set('NoTaxAmount', notaxamount); var quantity = e.record.data['Quantity']; if (quantity != null && quantity != 0) { var unitPrice = Div(notaxamount, quantity); //(parseFloat(notaxamount).div(parseFloat(quantity))).toFixed(2); e.record.set('UnitPrice', unitPrice); var TaxUnitPrice = Div(amount, quantity); e.record.set('TaxUnitPrice', TaxUnitPrice); } }; this.calcDetailTotal(); } else if (e.field == 'Unit') { var records = DsStoreQueryBy(this.StoreUnit, 'UNIT', e.value); var QUANTITY = 1; if (records.getCount() > 0) { var data = records.getAt(0).data; QUANTITY = data.QUANTITY; e.record.set('Quantity', QUANTITY); } else { e.record.set('Quantity', 1); } var taxrate = e.record.data['TaxRate']; if (taxrate == null) taxrate = 0; var unitPrice = e.record.data['UnitPrice']; var notaxamount = Mul(unitPrice, QUANTITY); //(parseFloat(unitPrice).mul(QUANTITY)).toFixed(2); e.record.set('NoTaxAmount', notaxamount); //taxrate = parseFloat(taxrate) / 100; var tax = Mul3(notaxamount, taxrate, 0.01); //parseFloat(notaxamount).mul(taxrate); var amount = Add(notaxamount, tax); //(parseFloat(notaxamount).add(parseFloat(tax))).toFixed(2); e.record.set('Amount', amount); this.calcDetailTotal(); } else if (e.field == 'Currency') { if (e.value == 'RMB') { e.record.set('ExChangerate', 1); } else { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', e.value); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; e.record.set('ExChangerate', DEFRATE); } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', e.value); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; e.record.set('ExChangerate', DEFRATE); } else { e.record.set('ExChangerate', 0); } } } this.calcDetailTotal(); } else if (e.field == 'CustomerType') { var records = DsStoreQueryBy(this.StoreCustType, 'CUSTTYPE', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; var CUSTNAME = this.EditRecord.get(data.CUSTNAME); e.record.set('CustomerName', CUSTNAME); } else { // e.record.set('CustomerName', 0); } } }, calcDetailTotal: function () { var rmbdr = 0; var rmbcr = 0; var usddr = 0; var usdcr = 0; var otdr = 0; var otcr = 0; var ttldr = 0; var ttlcr = 0; var notaxrmbdr = 0; var notaxrmbcr = 0; var notaxusddr = 0; var notaxusdcr = 0; var notaxotdr = 0; var notaxotcr = 0; var notaxttldr = 0; var notaxttlcr = 0; for (var i = 0; i < this.storeDrChFee.getCount(); i += 1) { var member = this.storeDrChFee.getAt(i); var value = member.get('Amount'); var notaxvalue = member.get('NoTaxAmount'); var curr = member.get('Currency'); var rate = member.get('ExChangerate'); if (curr == 'RMB') { rmbdr = parseFloat(rmbdr) + parseFloat(value); notaxrmbdr = parseFloat(notaxrmbdr) + parseFloat(notaxvalue); } else if (curr == 'USD') { usddr = parseFloat(usddr) + parseFloat(value); notaxusddr = parseFloat(notaxusddr) + parseFloat(notaxvalue); } else { otdr = parseFloat(otdr) + parseFloat(value); notaxotdr = parseFloat(notaxotdr) + parseFloat(notaxvalue); } ttldr = parseFloat(ttldr) + parseFloat(value) * parseFloat(rate); notaxttldr = parseFloat(notaxttldr) + parseFloat(notaxvalue) * parseFloat(rate); } for (var i = 0; i < this.storeCrChFee.getCount(); i += 1) { var member = this.storeCrChFee.getAt(i); var value = member.get('Amount'); var curr = member.get('Currency'); var rate = member.get('ExChangerate'); var notaxvalue = member.get('NoTaxAmount'); if (curr == 'RMB') { rmbcr = parseFloat(rmbcr) + parseFloat(value); notaxrmbcr = parseFloat(notaxrmbcr) + parseFloat(notaxvalue); } else if (curr == 'USD') { usdcr = parseFloat(usdcr) + parseFloat(value); notaxusdcr = parseFloat(notaxusdcr) + parseFloat(notaxvalue); } else { otcr = parseFloat(otcr) + parseFloat(value); notaxotcr = parseFloat(notaxotcr) + parseFloat(notaxvalue); } ttlcr = parseFloat(ttlcr) + parseFloat(value) * parseFloat(rate); notaxttlcr = parseFloat(notaxttlcr) + parseFloat(notaxvalue) * parseFloat(rate); } var rmbprofit = parseFloat(rmbdr) - parseFloat(rmbcr); var usdprofit = parseFloat(usddr) - parseFloat(usdcr); var otprofit = parseFloat(otdr) - parseFloat(otcr); var ttlprofit = parseFloat(ttldr) - parseFloat(ttlcr); var notaxrmbprofit = parseFloat(notaxrmbdr) - parseFloat(notaxrmbcr); var notaxusdprofit = parseFloat(notaxusddr) - parseFloat(notaxusdcr); var notaxotprofit = parseFloat(notaxotdr) - parseFloat(notaxotcr); var notaxttlprofit = parseFloat(notaxttldr) - parseFloat(notaxttlcr); for (i = 0; i < this.storeBodySum.getCount(); i += 1) { var memberyf = this.storeBodySum.getAt(i); if (memberyf.data.CURR == '人民币') { memberyf.set("NORATEDR", notaxrmbdr); memberyf.set("DR", rmbdr); memberyf.set("NORATECR", notaxrmbcr); memberyf.set("CR", rmbcr); memberyf.set("NORATEPR", notaxrmbprofit); memberyf.set("PR", rmbprofit); memberyf.commit(); } else if (memberyf.data.CURR == '美元') { memberyf.set("NORATEDR", notaxusddr); memberyf.set("DR", usddr); memberyf.set("NORATECR", notaxusdcr); memberyf.set("CR", usdcr); memberyf.set("NORATEPR", notaxusdprofit); memberyf.set("PR", usdprofit); memberyf.commit(); } if (memberyf.data.CURR == '其他币别') { memberyf.set("NORATEDR", notaxotdr); memberyf.set("DR", otdr); memberyf.set("NORATECR", notaxotcr); memberyf.set("CR", otcr); memberyf.set("NORATEPR", notaxotprofit); memberyf.set("PR", otprofit); memberyf.commit(); } if (memberyf.data.CURR == '合计') { memberyf.set("NORATEDR", notaxttldr); memberyf.set("DR", ttldr); memberyf.set("NORATECR", notaxttlcr); memberyf.set("CR", ttlcr); memberyf.set("NORATEPR", notaxttlprofit); memberyf.set("PR", ttlprofit); memberyf.commit(); } } }, setHeadFieldValue: function (fieldName, value) { var field = this.formtotal.getForm().findField(fieldName); field.setValue(value); }, //#endregion cellEditingChFeeBeforeEdit: function (editor, e) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var chfeefeeStatus = e.record.get('FeeStatus'); var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6 || chfeefeeStatus == 2; var IsDebit = e.record.get('IsDebit'); if (canedit) { if (IsDebit == 'True') { Ext.Msg.show({ title: '提示', msg: '当前费用已対帐无法修改!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canedit = true; } }; if (canedit) { var type = e.record.get('FeeType'); var op = e.record.get('EnteroPerator'); var opname = e.record.get('OpName'); if (type == 1) { var records = DsStoreQueryBy(this.StoreDrOpRange, 'OPID', op); if (records.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限修改' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canedit = false; } } else if (type == 2) { var records = DsStoreQueryBy(this.StoreCrOpRange, 'OPID', op); if (records.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限修改' + opname + '录入的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canedit = false; } } } return canedit; }, refBillNoSeChange: function (field, newValue, oldValue) { // if (newValue != oldValue) { // alert(newValue + "," + oldValue); // } }, onSubmitAuditClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var records = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 records = records.concat(phantoms); //将幻影数据与真实数据合并 if (records.length != 0) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { var records = this.feeCrGridCheckBoxModel.selected.items; }; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要提交审核的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var insert; for (var i = 0; i < records.length; i++) { var rec = records[i]; var bsno = rec.data.BsNo; if (bsno == '*') { insert = true; } var custname = rec.data.CustomerName; if (custname == '') { Ext.Msg.show({ title: '提示', msg: '客户名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var FeeName = rec.data.FeeName; if (FeeName == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = rec.data.Currency; if (Currency == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = rec.data.ExChangerate; if (ExChangerate == 0) { Ext.Msg.show({ title: '提示', msg: '汇率不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var amount = rec.data.Amount; if (amount == 0) { Ext.Msg.show({ title: '警告', msg: '费用的金额不允许为0,请修改后再保存', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } } if (insert == true) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var iSuccess = 0; var iFailure = 0; var postCount = 0; var postBillNO = ""; var loadVal = 0; for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var canDelete = feeStatus == 1 || feeStatus == 6; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只能费用状态为[录入状态]和[驳回提交]的费用才能提交审核,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { var urlVal = "../../AuditProcess/AuditService.aspx?handle=audit&oplb=" + this.stroplb + "&id=" + rec.data.GId + "&val=" + NewGuid(); Ext.Ajax.request({ async: false, url: urlVal, success: function (response) { loadVal = response.responseText; postCount++; if (loadVal > 0) { iSuccess++; if (iSuccess == 1) { postBillNO = rec.data.GId; } } else { iFailure++; } } }) } } if (postCount > 0) { if (loadVal != 10 && loadVal > 0) { //向审核人发送申请消息 var postUrlVal = "../../message/messageservice.aspx?billno=" + postBillNO + "&type=1&oplb=" + this.stroplb + "&handle=postmessage&bsno=" + this.strBSNO + "&uid=" + NewGuid(); ; Ext.Ajax.request({ url: postUrlVal, success: function (response) { loadVal = response.responseText; } }) } Ext.Msg.show({ title: '提示', msg: "提交应收费用审核 " + postCount + " 条 成功 " + iSuccess + " 条 失败 " + iFailure + " 条", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } if (type == 1) { //this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb} }); this.LoadDrChFee(button, event); } else { //this.storeCrChFee.load({ params: { billno: this.strBSNO, type: 2, optype: this.stroplb} }); this.LoadCrChFee(button, event); } // Shipping.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..'); }, onSubmitAuditNewClick: function (button, event, type) { var GidStr = ''; var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var modifyrecords = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 modifyrecords = modifyrecords.concat(phantoms); //将幻影数据与真实数据合并 if (modifyrecords.length != 0) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { var records = this.feeCrGridCheckBoxModel.selected.items; }; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要提交审核的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var insert; for (var i = 0; i < records.length; i++) { var rec = records[i]; var bsno = rec.data.BsNo; if (bsno == '*') { insert = true; } var custname = rec.data.CustomerName; if (custname == '') { Ext.Msg.show({ title: '提示', msg: '客户名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var FeeName = rec.data.FeeName; if (FeeName == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = rec.data.Currency; if (Currency == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = rec.data.ExChangerate; if (ExChangerate == 0) { Ext.Msg.show({ title: '提示', msg: '汇率不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } if (insert == true) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var iSuccess = 0; var iFailure = 0; var postCount = 0; var postBillNO = ""; var loadVal = 0; for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; var canDelete = feeStatus == 1 || feeStatus == 6; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只能费用状态为[录入状态]和[驳回提交]的费用才能提交审核,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { if (GidStr == '') GidStr = Gid; else { GidStr = GidStr + ',' + Gid; } } } _thisfee = this; if (GidStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_Audit/SubmitAudit', params: { GidStr: GidStr, optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { //_this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb} }); _thisfee.LoadDrChFee(button, event); } else { //_this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb} }); _thisfee.LoadCrChFee(button, event); } this.storeChFeeGain.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); this.storeBodySum.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onSubmitAuditAllClick: function (button, event, type) { var GidStr = ''; var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } for (var i = 0; i < store.getCount(); i++) { var rec = store.getAt(i); var bsno = rec.data.BsNo; if (bsno == '*') { insert = true; } var custname = rec.data.CustomerName; if (custname == '') { Ext.Msg.show({ title: '提示', msg: '客户名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var FeeName = rec.data.FeeName; if (FeeName == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = rec.data.Currency; if (Currency == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = rec.data.ExChangerate; if (ExChangerate == 0) { Ext.Msg.show({ title: '提示', msg: '汇率不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } var modifyrecords = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 modifyrecords = modifyrecords.concat(phantoms); //将幻影数据与真实数据合并 if (modifyrecords.length != 0) { var bodyDrChFeeDatas = []; var i; if (type == '1') { for (i = 0; i < this.storeDrChFee.getCount(); i += 1) { var memberyf = this.storeDrChFee.getAt(i); bodyDrChFeeDatas.push(memberyf); var ExChangerate = memberyf.data.ExChangerate; }; var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas); } else if (type == '2') { for (i = 0; i < this.storeCrChFee.getCount(); i += 1) { var memberyf = this.storeCrChFee.getAt(i); bodyDrChFeeDatas.push(memberyf); var amount = memberyf.data.Amount; var ExChangerate = memberyf.data.ExChangerate; }; var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas); }; _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsChFee/Save', scope: this, params: { bsno: _thisfee.strBSNO, type: type, chfeebody: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { if (type == '1') { for (var i = 0; i < this.storeDrChFee.getCount(); i += 1) { var member = this.storeDrChFee.getAt(i); member.set("BsNo", _thisfee.strBSNO); member.commit(); } } else if (type == '2') { for (var i = 0; i < this.storeCrChFee.getCount(); i += 1) { var member = this.storeCrChFee.getAt(i); member.set("BsNo", _thisfee.strBSNO); member.commit(); } } this.onSubmitAuditAllfn(button, event, type); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } else { this.onSubmitAuditAllfn(button, event, type); } }, onSubmitAuditAllfn: function (button, event, type) { var GidStr = ''; var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } for (var i = 0; i < store.getCount(); i++) { var rec = store.getAt(i); var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; var canDelete = feeStatus == 1 || feeStatus == 6; if (canDelete == false) { } else { if (GidStr == '') GidStr = Gid; else { GidStr = GidStr + ',' + Gid; } } } _thisfee = this; if (GidStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_Audit/SubmitAudit', params: { GidStr: GidStr, optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { //_this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb} }); _thisfee.LoadDrChFee(button, event); } else { //_this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb} }); _thisfee.LoadCrChFee(button, event); } this.storeChFeeGain.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); this.storeBodySum.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onCancelAuditNewClick: function (menu, event, type) { var GidStr = ''; var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var modifyrecords = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 modifyrecords = modifyrecords.concat(phantoms); //将幻影数据与真实数据合并 if (modifyrecords.length != 0) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { var records = this.feeCrGridCheckBoxModel.selected.items; }; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要撤销提交的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var iSuccess = 0; var iFailure = 0; var postCount = 0; var postBillNO = ""; var loadVal = 0; for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; var canDelete = feeStatus == 2; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只能费用状态为[提交审核]的费用才能撤销提交审核,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { if (GidStr == '') GidStr = Gid; else { GidStr = GidStr + ',' + Gid; } } } _thisfee = this; if (GidStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在添加数据...', url: '/Account/Chfee_Audit/CancelAudit', params: { GidStr: GidStr, optype: _thisfee.stroplb }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { //_this.storeDrChFee.load({ params: { billno: _this.strBSNO, type: 1, optype: _this.stroplb} }); _thisfee.LoadDrChFee(); } else { //_this.storeCrChFee.load({ params: { billno: _this.strBSNO, type: 2, optype: _this.stroplb} }); _thisfee.LoadCrChFee(); } this.storeChFeeGain.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); this.storeBodySum.load({ params: { bsno: _thisfee.strBSNO, optype: _thisfee.stroplb} }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onNoIvoiceClick: function (button, event, type) { var GidStr = ''; if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { var records = this.feeCrGridCheckBoxModel.selected.items; }; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要禁开发票的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; if (GidStr == '') GidStr = Gid; else { GidStr = GidStr + ',' + Gid; } } _this = this; if (GidStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在提交数据...', url: '/Account/Chfee_Audit/NoIvoice', params: { bill: GidStr }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { _thisfee.LoadDrChFee(); } else { _thisfee.LoadCrChFee(); } } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, onCancelNoIvoiceClick: function (button, event, type) { var GidStr = ''; if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; } else if (type == '2') { var records = this.feeCrGridCheckBoxModel.selected.items; }; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要解禁开发票的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } // isAll = this.comboxaddDCType.getValue(); for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; if (GidStr == '') GidStr = Gid; else { GidStr = GidStr + ',' + Gid; } } _this = this; if (GidStr == '') { } else { Ext.Ajax.request({ waitMsg: '正在提交数据...', url: '/Account/Chfee_Audit/CancelNoIvoice', params: { bill: GidStr }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { if (type == 1) { _thisfee.LoadDrChFee(); } else { _thisfee.LoadCrChFee(); } } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, getModifyStatus: function () { var drmodify = this.storeDrChFee.getModifiedRecords(); var crmodify = this.storeCrChFee.getModifiedRecords(); if (drmodify.length != 0 || crmodify.length != 0) { return true } else { for (i = 0; i < this.storeDrChFee.getCount(); i += 1) { var memberyf = this.storeDrChFee.getAt(i); if (memberyf.data.BsNo == "*") return true } for (i = 0; i < this.storeCrChFee.getCount(); i += 1) { var memberyf = this.storeCrChFee.getAt(i); if (memberyf.data.BsNo == "*") return true } return false; } }, getFeeStatus: function () { var feeStatus = this.EditRecord.get('FEESTATUS'); return feeStatus; }, getBillStatus: function () { // var basicForm = this.formEdit.getForm(); // var billStatus = basicForm.findField('BillStatus').value; // return billStatus; }, getCustName: function () { // var custName = this.formEdit.getForm().findField('RefCustomerName'); //return custName.getValue(); }, setSaveBtnStatus: function (enable) { var bsbtnSave = Ext.getCmp('pcbtnSave'); var bsbtnSaveAndClose = Ext.getCmp('pcbtnSaveAndClose'); var bsbtnSaveAndNew = Ext.getCmp('pcbtnSaveAndNew'); var pcbtnNew = Ext.getCmp('pcbtnNew'); if (enable) { bsbtnSave.enable(); bsbtnSaveAndClose.enable(); bsbtnSaveAndNew.enable(); pcbtnNew.enable(); } else { //bsbtnSave.disable(); //bsbtnSaveAndClose.disable(); bsbtnSaveAndNew.disable(); pcbtnNew.disable(); } }, onPrintSelectDetailClick: function (button, event, type) { var USDEXRATE = 0; var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', 'USD'); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; USDEXRATE = ffdata.DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', 'USD'); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; USDEXRATE = dfdata.DEFRATE; } } var selectedRecords = []; var storeadd = null; if (type == 1) { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; } else if (type == 2) { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要打印的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (this.stroplb == 'op_Seae') { var printType = ''; if (type == 1) { printType = 'SEAEDRFEE'; } else { printType = 'SEAECRFEE'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = ''; if (type == 1) { printType = 'APPLYDRFEE'; } else { printType = 'APPLYCRFEE'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = ''; if (type == 1) { printType = 'SEAIDRFEE'; } else { printType = 'SEAICRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_seai WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = ''; if (type == 1) { printType = 'BULKDRFEE'; } else { printType = 'BULKCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_bulk WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = ''; if (type == 1) { printType = 'OTHERDRFEE'; } else { printType = 'OTHERCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_other WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_railway') { var printType = ''; if (type == 1) { printType = 'RAILWAYDRFEE'; } else { printType = 'RAILWAYCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_railway WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Aire') { var printType = ''; if (type == 1) { printType = 'AIREDRFEE'; } else { printType = 'AIRECRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_aire WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Airi') { var printType = ''; if (type == 1) { printType = 'AIRIDRFEE'; } else { printType = 'AIRICRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_airi WHERE BsNo = '" + this.strBSNO + "'"; }; var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "''" + record.get('GId') + "''"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var sql2 = " declare @sql varchar(8000) "; sql2 = sql2 + " set @sql = 'select bsno '"; sql2 = sql2 + " select @sql = @sql + ' , sum(case feename when ''' + feename + ''' then amount else 0 end) [' + feename + ']' "; sql2 = sql2 + " from (select name as feename from code_fee where name in "; sql2 = sql2 + " ('掏箱费','港杂费','关税','增值税','监管费','滞报金','保证金','滞纳金', "; sql2 = sql2 + " '二次换单费','换单费','报检费','仓储费','分拨费','港杂费','港建费','港口包干费', "; sql2 = sql2 + " '验货费','熏蒸费','还柜吊柜费','转栈费','海运费','空运费','捆绑费', "; sql2 = sql2 + " '铁路运费','公路运费','短途运输费','木检运费','搬倒费','装箱费','修箱费', "; sql2 = sql2 + " '滞箱费','出入库费','拆箱费','吊箱费',"; sql2 = sql2 + " '国际运费','报关费','保险费','包干费','THC','运费','商检验货费','集装箱费'"; sql2 = sql2 + " )) as a set @sql = @sql + ' from ch_fee where bsno=''" + this.strBSNO + "'' ' "; if (feeGidSql != '') { sql2 = sql2 + " set @sql = @sql + ' and Gid in (" + feeGidSql + ") '"; } sql2 = sql2 + "set @sql = @sql +' group by bsno ' exec(@sql) "; var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('GId') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var sql3 = ""; if (feeGidSql != '') { sql3 = sql3 + " Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人 from ch_fee c where c.Gid in (" + feeGidSql + ") order by sort,LineNum "; } var sql4 = " Select ic.*,icc.showname,icc.addr from info_client ic "; sql4 = sql4 + " left join info_client_contact icc on icc.linkid=ic.gid where shortname=(select customername from v_op_bill where bsno='" + this.strBSNO + "')"; var sql5 = ""; var sql6 = " SELECT " + USDEXRATE + " AS USDEXRATE FROM [USER]"; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onPrintCustDetailClick: function (button, event, type) { var USDEXRATE = 0; var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', 'USD'); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; USDEXRATE = ffdata.DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', 'USD'); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; USDEXRATE = dfdata.DEFRATE; } } var selectedRecords = []; var storeadd = null; if (type == 1) { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; } else if (type == 2) { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要打印的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (this.stroplb == 'op_Seae') { var printType = ''; if (type == 1) { printType = 'SEAEDRFEE'; } else { printType = 'SEAECRFEE'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = ''; if (type == 1) { printType = 'APPLYDRFEE'; } else { printType = 'APPLYCRFEE'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = ''; if (type == 1) { printType = 'SEAIDRFEE'; } else { printType = 'SEAICRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_seai WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = ''; if (type == 1) { printType = 'BULKDRFEE'; } else { printType = 'BULKCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_bulk WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = ''; if (type == 1) { printType = 'OTHERDRFEE'; } else { printType = 'OTHERCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_other WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_railway') { var printType = ''; if (type == 1) { printType = 'RAILWAYDRFEE'; } else { printType = 'RAILWAYCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_railway WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Aire') { var printType = ''; if (type == 1) { printType = 'AIREDRFEE'; } else { printType = 'AIRECRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_aire WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Airi') { var printType = ''; if (type == 1) { printType = 'AIRIDRFEE'; } else { printType = 'AIRICRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_airi WHERE BsNo = '" + this.strBSNO + "'"; }; var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var custname = record.get('CustomerName'); var FeeType = record.get('FeeType'); var BsNo = record.get('BsNo'); }; var sql2 = " declare @sql varchar(8000) "; sql2 = sql2 + " set @sql = 'select bsno '"; sql2 = sql2 + " select @sql = @sql + ' , sum(case feename when ''' + feename + ''' then amount else 0 end) [' + feename + ']' "; sql2 = sql2 + " from (select name as feename from code_fee where name in "; sql2 = sql2 + " ('掏箱费','港杂费','关税','增值税','监管费','滞报金','保证金','滞纳金', "; sql2 = sql2 + " '二次换单费','换单费','报检费','仓储费','分拨费','港杂费','港建费','港口包干费', "; sql2 = sql2 + " '验货费','熏蒸费','还柜吊柜费','转栈费','海运费','空运费','捆绑费', "; sql2 = sql2 + " '铁路运费','公路运费','短途运输费','木检运费','搬倒费','装箱费','修箱费', "; sql2 = sql2 + " '滞箱费','出入库费','拆箱费','吊箱费',"; sql2 = sql2 + " '国际运费','报关费','保险费','包干费','THC','运费','商检验货费','集装箱费'"; sql2 = sql2 + " )) as a set @sql = @sql + ' from ch_fee where bsno=''" + this.strBSNO + "'' ' "; if (custname != '') { sql2 = sql2 + " set @sql = @sql + ' and CustomerName=''" + custname + "'' and Bsno=''" + BsNo + "'' and feetype=" + FeeType + " '"; } sql2 = sql2 + "set @sql = @sql +' group by bsno ' exec(@sql) "; var sql3 = ""; sql3 = sql3 + " Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人 from ch_fee c where c.CustomerName='" + custname + "' and c.BsNo='" + BsNo + "' and c.feetype=" + FeeType + " order by sort,LineNum "; var sql4 = " Select ic.*,icc.showname,icc.addr from info_client ic "; sql4 = sql4 + " left join info_client_contact icc on icc.linkid=ic.gid where shortname=(select customername from v_op_bill where bsno='" + this.strBSNO + "')"; var sql5 = ""; var sql6 = " SELECT " + USDEXRATE + " AS USDEXRATE FROM [USER]"; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onPrintAllDetailClick: function (button, event, type) { if (this.stroplb == 'op_Seae') { var printType = ''; if (type == 1) { printType = 'SEAEDRFEEALL'; } else { printType = 'SEAECRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = ''; if (type == 1) { printType = 'APPLYDRFEEALL'; } else { printType = 'APPLYCRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = ''; if (type == 1) { printType = 'SEAIDRFEEALL'; } else { printType = 'SEAICRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seai WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = ''; if (type == 1) { printType = 'BULKDRFEEALL'; } else { printType = 'BULKCRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_bulk WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = ''; if (type == 1) { printType = 'OTHERDRFEEALL'; } else { printType = 'OTHERCRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_other WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_railway') { var printType = ''; if (type == 1) { printType = 'RAILWAYDRFEEALL'; } else { printType = 'RAILWAYCRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_railway WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Aire') { var printType = ''; if (type == 1) { printType = 'AIREDRFEEALL'; } else { printType = 'AIRECRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_aire WHERE BsNo = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Airi') { var printType = ''; if (type == 1) { printType = 'AIRIDRFEEALL'; } else { printType = 'AIRICRFEEALL'; }; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_airi WHERE BsNo = '" + this.strBSNO + "'"; }; var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + this.strBSNO + "' and FEETYPE=" + type + " order by sort,LineNum "; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onPrintGainClick: function (button, event, type) { if (this.stroplb == 'op_Seae') { var printType = 'SEAEGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = 'APPLYGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = 'SEAIGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seai WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = 'BULKGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_bulk WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = 'OTHERGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_other WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_railway') { var printType = 'RAILWAYGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_railway WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Aire') { var printType = 'AIREGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_aire WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Airi') { var printType = 'AIRIGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_airi WHERE BSNO = '" + this.strBSNO + "'"; }; // sql3 = sql3 + " Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人 from ch_fee c where c.Gid in (" + feeGidSql + ") order by sort,LineNum "; var sql2 = "SET LANGUAGE 'us_english' Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人 from ch_fee c where c.BSNO='" + this.strBSNO + "' and c.FEETYPE=1 order by sort,LineNum "; var sql3 = "SET LANGUAGE 'us_english' Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人 from ch_fee c where c.BSNO='" + this.strBSNO + "' and c.FEETYPE=2 order by sort,LineNum "; //全部费用利润 或 海运费利润 或 仓储利润 var sql4 = "SELECT BSNO" + ",SUM(RMBDR) as RMBDR,SUM(RMBCR) as RMBCR,SUM(USDDR) as USDDR,SUM(USDCR) as USDCR" + ",SUM(RMBDR+USDTORMBDR) as DRTTL" + ",SUM(RMBCR+USDTORMBCR) as CRTTL" + ",(SUM(RMBDR)-SUM(RMBCR)) AS RMBPROFIT" + ",(SUM(USDDR)-SUM(USDCR)) AS USDPROFIT" + ",SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT" //+ ",(CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((case when SUM(RMBDR+USDTORMBDR)=0 then 0 else (SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR) END),4))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE" + ",(CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND(((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBCR+USDTORMBCR)),4))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE" + ",'" + SHOWNAME + "' as CREATEUSER,GETDATE() as CREATETIME " + " FROM (" + "SELECT BSNO,CURRENCY,FEETYPE" + ",SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR" + ",SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR" + ",SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR" + ",SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR" + ",SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR" + ",SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR " + " FROM ch_fee WHERE 1=1 and BSNO='" + this.strBSNO + "'" + " GROUP BY BSNO,CURRENCY,EXCHANGERATE,FEETYPE " + " ) AS C GROUP BY BSNO "; var sql5 = "exec GetPrintData '" + this.strBSNO + "'"; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, LoadDrChFee: function (button, event) { var fieldcomm = []; var valuecomm = []; if (this.WMSOUTBSNO != "") { fieldcomm.push("WMSOUTBSNO"); valuecomm.push(this.WMSOUTBSNO); } var _thisfee = this; if (fieldcomm.length == 0) { this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb } , callback: function (r, options, success) { if (success) { if (r.length > 0) { _thisfee.storeDrChFee.getSelectionModel().select(0); } else { } } }, scope: this }); } else { this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb, Fields: fieldcomm, Values: valuecomm } , callback: function (r, options, success) { if (success) { if (r.length > 0) { _thisfee.storeDrChFee.getSelectionModel().select(0); } else { } } }, scope: this }); } this.storeChFeeGain.load({ params: { bsno: this.strBSNO, optype: this.stroplb} }); }, LoadCrChFee: function (button, event) { var fieldcomm = []; var valuecomm = []; if (this.WMSOUTBSNO != "") { fieldcomm.push("WMSOUTBSNO"); valuecomm.push(this.WMSOUTBSNO); } var _thisfee = this; if (fieldcomm.length == 0) { _thisfee.storeCrChFee.load({ params: { billno: this.strBSNO, type: 2, optype: this.stroplb }, callback: function (r, options, success) { if (r.length > 0) { _thisfee.storeCrChFee.getSelectionModel().select(0); } else { } }, scope: this }); } else { _thisfee.storeCrChFee.load({ params: { billno: this.strBSNO, type: 2, optype: this.stroplb, Fields: fieldcomm, Values: valuecomm }, callback: function (r, options, success) { if (r.length > 0) { _thisfee.storeCrChFee.getSelectionModel().select(0); } else { } }, scope: this }); } this.storeChFeeGain.load({ params: { bsno: this.strBSNO, optype: this.stroplb} }); } /////20160109 北京二商 增加将费用的SALESNO设置到相应的期货销售合同下 , SetSALESNO: function (button, event) { var GidStr = ''; var type = 1; var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var modifyrecords = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 modifyrecords = modifyrecords.concat(phantoms); //将幻影数据与真实数据合并 if (modifyrecords.length != 0) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } //if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; //} else if (type == '2') { // var records = this.feeCrGridCheckBoxModel.selected.items; //}; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要提交至期货销售合同的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var insert; for (var i = 0; i < records.length; i++) { var rec = records[i]; var bsno = rec.data.BsNo; if (bsno == '*') { insert = true; } var custname = rec.data.CustomerName; if (custname == '') { Ext.Msg.show({ title: '提示', msg: '客户名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var FeeName = rec.data.FeeName; if (FeeName == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = rec.data.Currency; if (Currency == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = rec.data.ExChangerate; if (ExChangerate == 0) { Ext.Msg.show({ title: '提示', msg: '汇率不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } if (insert == true) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var iSuccess = 0; var iFailure = 0; var postCount = 0; var postBillNO = ""; var loadVal = 0; for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; var canDelete = feeStatus == 0 || feeStatus == 8 || feeStatus == 9; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只有费用状态为[审核通过]和[部分/全部结算]的费用才能提交,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { if (GidStr == "") GidStr = "'" + Gid + "'"; else { GidStr = GidStr + ",'" + Gid + "'"; } } } _thisfee = this; if (GidStr == "") { } else { this.SetChFee(GidStr) } }, UnSetSALESNO: function (button, event) { var GidStr = ''; var type = 1; var store = null; if (type == 1) { store = this.storeDrChFee; } else if (type == 2) { store = this.storeCrChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var modifyrecords = store.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据 var phantoms = store.getNewRecords(); //获得幻影行 modifyrecords = modifyrecords.concat(phantoms); //将幻影数据与真实数据合并 if (modifyrecords.length != 0) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } //if (type == '1') { var records = this.feeDrGridCheckBoxModel.selected.items; //} else if (type == '2') { // var records = this.feeCrGridCheckBoxModel.selected.items; //}; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要提交至期货销售合同的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var insert; for (var i = 0; i < records.length; i++) { var rec = records[i]; var bsno = rec.data.BsNo; if (bsno == '*') { insert = true; } var custname = rec.data.CustomerName; if (custname == '') { Ext.Msg.show({ title: '提示', msg: '客户名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var FeeName = rec.data.FeeName; if (FeeName == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var Currency = rec.data.Currency; if (Currency == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var ExChangerate = rec.data.ExChangerate; if (ExChangerate == 0) { Ext.Msg.show({ title: '提示', msg: '汇率不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } if (insert == true) { Ext.Msg.show({ title: '提示', msg: '有未保存的费用,请先保存费用然后再提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var iSuccess = 0; var iFailure = 0; var postCount = 0; var postBillNO = ""; var loadVal = 0; for (var i = 0; i < records.length; i++) { var rec = records[i]; var feeStatus = rec.data.FeeStatus; var Gid = rec.data.GId; var canDelete = feeStatus == 0 || feeStatus == 8 || feeStatus == 9; if (canDelete == false) { Ext.Msg.show({ title: '提示', msg: '只有费用状态为[审核通过]和[部分/全部结算]的费用才能提交,请重新选择', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { if (GidStr == "") GidStr = "'" + Gid + "'"; else { GidStr = GidStr + ",'" + Gid + "'"; } } } _thisfee = this; if (GidStr == "") { } else { this.UnSetChFee(GidStr) } }, SetChFee: function (GidStr) { //alert(this.strBSNO + " " + GidStr); //return; var SQL = " update ch_fee set SALESNO= "; SQL = SQL + " (select top 1 ss.SALESNO from Import_Saledetail s "; SQL = SQL + " left join Import_Sales ss on ss.SALESNO=s.SALESNO "; SQL = SQL + " where CARGO_GID in( "; SQL = SQL + " select gid from import_cargo where ContractNo='" + this.strBSNO + "' "; SQL = SQL + " ) and ss.mainstate=0 and ss.CUSTOMERNAME=ch_fee.CUSTOMERNAME "; SQL = SQL + " ) where gid in ( " + GidStr + ")"; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ async: false, waitMsg: '正在保存数据...', url: '/Import/ImportSync/SaveSync', scope: this, params: { SQL: SQL }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); //刷新费用列表 var jsonresult = Ext.JSON.decode(response.responseText); if (parseInt(jsonresult.data) > 0) { this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb } , callback: function (r, options, success) { if (success) { if (r.length > 0) { //_thisfee.storeDrChFee.getSelectionModel().select(0); } else { } } }, scope: this }); } else { alert("影响行数为0,请检查如下情况:1是否还未有相应的销售合同;2是否销售合同的销售类型已设置为期货销售。"); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } //alert('03'); } }); }, UnSetChFee: function (GidStr) { //alert(this.strBSNO + " " + GidStr); //return; var SQL = " update ch_fee set SALESNO='' "; SQL = SQL + " where gid in ( " + GidStr + ")"; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ async: false, waitMsg: '正在保存数据...', url: '/Import/ImportSync/SaveSync', scope: this, params: { SQL: SQL }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); //刷新费用列表 var jsonresult = Ext.JSON.decode(response.responseText); if (parseInt(jsonresult.data) > 0) { this.storeDrChFee.load({ params: { billno: this.strBSNO, type: 1, optype: this.stroplb } , callback: function (r, options, success) { if (success) { if (r.length > 0) { //_thisfee.storeDrChFee.getSelectionModel().select(0); } else { } } }, scope: this }); } else { //alert("影响行数为0,请检查如下情况:1是否还未有相应的销售合同;2是否销售合同的销售类型已设置为期货销售。"); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } //alert('03'); } }); } });