Ext.namespace('Shipping'); Shipping.FeeViewGrid = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.FeeViewGrid.superclass.constructor.call(this); }; Ext.extend(Shipping.FeeViewGrid, Ext.Panel, { ParentWin: null, //弹出式 ParentPanel: null, //Tab页编辑模式 OpStatus: 'add', StoreBill: null, StoreCustType: null, EditRecord: null, RefBillNo: '*', DataLoading: true, strMBLNO: '', stroplb: '', strBSNO: '', 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.storeDrChFee = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetDataList', 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.cellEditingDrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); /* _this = this; this.cellEditingDrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, onSpecialKey: function (ed, field, e) { var sm; if (e.getKey() === 40) { 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, 1); e.stopEvent(); } } } }); */ this.initgirdDrcolums = [{ 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: '客户类别', width: 80 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', width: 110 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', align: 'right', width: 70, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Quantity', header: '数量', width: 50 }, { sortable: true, dataIndex: 'TaxRate', header: '税率', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 60 }, { sortable: true, dataIndex: 'NoTaxAmount', header: '不含税金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Amount', header: '金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Currency', header: '币别', width: 40 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 60 }, { sortable: true, dataIndex: 'IsAdvancedpay', header: '是否垫付', width: 60 }, { sortable: true, dataIndex: 'IsInvoice', header: '禁开发票', width: 60, renderer: function (value, meta, record) { if (value == '1') return '是'; else return value; } }, { sortable: true, dataIndex: 'AccTaxRate', header: '销项税率', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 80 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 150 }, { sortable: true, dataIndex: 'FeeFrt', header: 'FRT', width: 40 }, { sortable: true, dataIndex: 'Commissionrate', header: '佣金比率', 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: 'Auditoperator', header: '审核人', width: 60 }, { sortable: true, dataIndex: 'AuditDate', header: '审核日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), 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 }, { sortable: true, dataIndex: 'Settlement', header: '结算金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Invoice', header: '已开票金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, // { // sortable: true, // dataIndex: 'InvoiceNum', // header: '发票号码', // width: 80 // }, { sortable: true, dataIndex: 'INPUTMODE', header: '录入方式', //'录入方式', width: 80 }, { sortable: true, dataIndex: 'MANAGER', header: '责任人', //'MANAGER', renderer: function (value, p, record) { return record.data.MANAGERREF; }, width: 100 } ]; this.girdDrcolums = this.initgirdDrcolums; this.feeDrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _thisfeeview = this; 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, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); var BsNo = record.get('BsNo'); var ISSEL = record.get('ISSEL'); if (ISSEL == '1') { return Shipping.FeeGetRowClassFont(feeStatus); } else { if (BsNo == _thisfeeview.strBSNO) return Shipping.FeeGetRowClass(feeStatus); else return Shipping.FeeGetRowClassFont(feeStatus); } } }, tbar: [{ text: '', tooltip: '打印应收', iconCls: "btnprint", menu: [ { text: "打印应收账单", menu: [//海运进口应收应付列表 {text: "所选应收打印", handler: function (menu, event) { _thisfeeview.onPrintSelectDetailClick(menu, event, 1); } }, { text: "所有应收打印", handler: function (menu, event) { _thisfeeview.onPrintAllDetailClick(menu, event, 1); } } ] }, '-', { text: "利润核算单打印", handler: function (menu, event) { _thisfeeview.onPrintGainClick(menu, event, 1); } } ], /* handler: function (button, event) { this.onPrintDetailClick(button, event, 1); }, */ 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: "保存列表样式", //"保存列表样式", menu: [ { text: "保存", //"保存", handler: function (button, event) { _thisfeeview.girdDrcolums = DsTruck.SaveGridPanel(USERID, 'FEEDRGRIDVIEW', _thisfeeview.gridDrChFee.columns, _thisfeeview.girdDrcolums, 0, true); } }, { text: "初始化", //"初始化", handler: function (menu, event) { _thisfeeview.gridDrChFee.reconfigure(this.storeList, _thisfeeview.initgirdDrcolums); _thisfeeview.girdDrcolums = DsTruck.SaveGridPanel(USERID, 'FEEDRGRIDVIEW', _thisfeeview.gridDrChFee.columns, _thisfeeview.initgirdDrcolums, 0, true); } }], scope: this }], columns: this.girdDrcolums }); this.girdDrcolums = DsTruck.GetGridPanel(USERID, 'FEEDRGRIDVIEW', this.girdDrcolums, 0); //使用者id,表名,中间column数组,跳过一开始的几列 /* var map = new Ext.util.KeyMap(this.gridDrChFee, [ { key: [40], fn: function () { alert("Return was pressed"); } } ]); this.gridDrChFee.on('onKeyPress', function (e) { var k = e.getKey(); if (k == 40) { this.onAddDetailClick(null, null, 1); } }, this); */ //#endregion this.cellEditingCrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); /* this.cellEditingCrChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, onSpecialKey: function (ed, field, e) { var sm; if (e.getKey() === 40) { 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, 2); e.stopEvent(); } } } }); */ this.initgirdCrcolums = [{ 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: '应付费用名称', width: 100 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', width: 80 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', width: 110 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', align: 'right', width: 70, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 3, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Quantity', header: '数量', width: 50 }, { sortable: true, dataIndex: 'TaxRate', header: '税率', align: 'right', width: 60 }, { sortable: true, dataIndex: 'NoTaxAmount', header: '不含税金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Amount', header: '金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Currency', header: '币别', width: 40 }, { sortable: true, dataIndex: 'ExChangerate', header: '汇率', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 4, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 60 }, { sortable: true, dataIndex: 'IsAdvancedpay', header: '是否垫付', width: 60 }, { sortable: true, dataIndex: 'IsInvoice', header: '禁开发票', width: 60, renderer: function (value, meta, record) { if (value == '1') return '是'; else return value; } }, { sortable: true, dataIndex: 'AccTaxRate', header: '进项税率', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 80 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 150 }, { sortable: true, dataIndex: 'FeeFrt', header: 'FRT', width: 40 }, { sortable: true, dataIndex: 'Commissionrate', header: '佣金比率', 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: 'Auditoperator', header: '审核人', width: 60 }, { sortable: true, dataIndex: 'AuditDate', header: '审核日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), 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 }, { sortable: true, dataIndex: 'Settlement', header: '结算金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'OrderAmount', header: '申请金额', align: 'right', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'INPUTMODE', header: '录入方式', //'录入方式', width: 80 }, { sortable: true, dataIndex: 'MANAGER', header: '责任人', //'MANAGER', renderer: function (value, p, record) { return record.data.MANAGERREF; }, width: 100 } ]; this.girdCrcolums = this.initgirdCrcolums; this.feeCrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); 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, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); var BsNo = record.get('BsNo'); var ISSEL = record.get('ISSEL'); if (ISSEL == '1') { return Shipping.FeeGetRowClassFont(feeStatus); } else { if (BsNo == _thisfeeview.strBSNO) return Shipping.FeeGetRowClass(feeStatus); else return Shipping.FeeGetRowClassFont(feeStatus); } } }, tbar: [{ text: '', tooltip: '打印应付', iconCls: "btnprint", menu: [ { text: "打印应付账单", menu: [ { text: "所选应付打印", handler: function (menu, event) { _thisfeeview.onPrintSelectDetailClick(menu, event, 2); } }, { text: "所有应付打印", handler: function (menu, event) { _thisfeeview.onPrintAllDetailClick(menu, event, 2); } } ] }, '-', { text: "利润核算单打印", handler: function (menu, event) { _thisfeeview.onPrintGainClick(menu, event, 1); } } ], 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: "保存列表样式", //"保存列表样式", menu: [ { text: "保存", //"保存", handler: function (button, event) { _thisfeeview.girdCrcolums = DsTruck.SaveGridPanel(USERID, 'FEECRGRIDVIEW', _thisfeeview.gridCrChFee.columns, _thisfeeview.girdCrcolums, 0, true); } }, { text: "初始化", //"初始化", handler: function (menu, event) { _thisfeeview.gridCrChFee.reconfigure(this.storeList, _thisfeeview.initgirdCrcolums); _thisfeeview.girdCrcolums = DsTruck.SaveGridPanel(USERID, 'FEECRGRIDVIEW', _thisfeeview.gridCrChFee.columns, _thisfeeview.initgirdCrcolums, 0, true); } }], scope: this }], columns: this.girdCrcolums }); this.girdCrcolums = DsTruck.GetGridPanel(USERID, 'FEECRGRIDVIEW', this.girdCrcolums, 0); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridDrChFee.reconfigure(this.storeDrChFee, this.girdDrcolums); this.gridCrChFee.reconfigure(this.storeCrChFee, this.girdCrcolums); 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.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: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 160 }, { header: '含税', dataIndex: 'DR', align: 'right', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, width: 160 }] }, { text: '应 付', columns: [{ header: '不含税', dataIndex: 'NORATECR', align: 'right', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, width: 160 }, { header: '含税', dataIndex: 'CR', align: 'right', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, width: 160 }] }, { text: '利 润', columns: [{ header: '不含税', dataIndex: 'NORATEPR', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', width: 160 }, { header: '含税', dataIndex: 'PR', align: 'right', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, 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: LOCALCURR + '应收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'RMBCR', header: LOCALCURR + '应付', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'RMBPROFIT', header: LOCALCURR + '利润', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDDR', header: 'USD应收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDCR', header: 'USD应付', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'USDPROFIT', header: 'USD利润', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTDR', header: '其他币别应收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTCR', header: '其他币别应付', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'OTPROFIT', header: '其他币别利润', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), align: 'right', width: 80 }, { sortable: true, dataIndex: 'TTLDR', header: '合计应收', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'TTLCR', header: '合计应付', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, align: 'right', // summaryType: 'sum', // summaryRenderer: Ext.util.Format.numberRenderer('00.00'), width: 80 }, { sortable: true, dataIndex: 'TTLPROFIT', header: '合计利润', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, 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.panelDrChFee = new Ext.Panel({ title: '应收费用', layout: "border", anchor: '100% 50%', frame: true, split: true, items: [this.gridDrChFee] }); this.panelCrChFee = new Ext.Panel({ title: '应付费用', layout: "border", anchor: '100% 50%', // region: 'center', frame: true, items: [this.gridCrChFee] }); 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'; this.storeBodySum.on('load', function (store, records) { this.setTotalHead(); }, this); this.gridDrChFee.getSelectionModel().on('select', function (model, record, index) { var FeeStatus = record.data.FeeStatus; var CustomerName = record.data.CustomerName; var GId = record.data.GId; var FeeName = record.data.FeeName; for (i = 0; i < this.storeCrChFee.getCount(); i += 1) { var memberyf = this.storeCrChFee.getAt(i); var recchange = memberyf.getChanges(); if ((FeeName != '') && (memberyf.data.FeeName == FeeName)) { memberyf.set("ISSEL", '1'); } else { memberyf.set("ISSEL", '0'); } if (isEmptyObject(recchange)) memberyf.commit(); }; }, this); this.gridCrChFee.getSelectionModel().on('select', function (model, record, index) { var FeeStatus = record.data.FeeStatus; var CustomerName = record.data.CustomerName; var GId = record.data.GId; var FeeName = record.data.FeeName; for (i = 0; i < this.storeDrChFee.getCount(); i += 1) { var memberyf = this.storeDrChFee.getAt(i); var recchange = memberyf.getChanges(); if ((FeeName != '') && (memberyf.data.FeeName == FeeName)) { memberyf.set("ISSEL", '1'); } else { memberyf.set("ISSEL", '0'); } if (isEmptyObject(recchange)) memberyf.commit(); }; }, this); this.gridDrChFee.on({ selectionchange: function (sm, selections) { if (selections.length == 0) { for (i = 0; i < _thisfee.storeCrChFee.getCount(); i += 1) { var memberyf = _thisfee.storeCrChFee.getAt(i); var recchange = memberyf.getChanges(); memberyf.set("ISSEL", '0'); if (isEmptyObject(recchange)) memberyf.commit(); }; } } }); this.gridCrChFee.on({ selectionchange: function (sm, selections) { if (selections.length == 0) { for (i = 0; i < _thisfee.storeDrChFee.getCount(); i += 1) { var memberyf = _thisfee.storeDrChFee.getAt(i); var recchange = memberyf.getChanges(); memberyf.set("ISSEL", '0'); if (isEmptyObject(recchange)) memberyf.commit(); }; var DRSELECTSTR = Ext.getCmp('CRSELECTSTR'); DRSELECTSTR.setText('', false); } } }); /* parentWin = window.parent.opener; { if (parentWin) { var ret = parentWin.OprationSwap(); var fun = ret[4]; } } */ 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 明细操作 GetHandleSerialNo: function (store, type) { var result = 0; if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (member.data.Sort > result) { result = member.data.Sort; } } } result = parseInt(result) + 1; return result; }, //end save onViewDetailClick: function (button, event, type) { var openSet = "height=740, 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; var openUrl = "../../MvcShipping/MsOpBill/MsFeeHistoryView??bsno=" + this.strBSNO + "&oplb=" + this.stroplb + "&type=" + type; window.open(openUrl, openType, openSet); }, getAllowOperationDetail: function () { var feeStatus = 0; if (feeStatus == '0' || feeStatus == false || feeStatus == 'false') return true; else { Ext.Msg.show({ title: '错误', msg: "此票委托已费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return false; } }, //#endregion //#region 表格的AfterEdit 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; for (var i = 0; i < this.storeDrChFee.getCount(); i += 1) { var member = this.storeDrChFee.getAt(i); var value = member.get('Amount'); var curr = member.get('Currency'); var rate = member.get('ExChangerate'); if (curr ==LOCALCURR) { rmbdr = parseFloat(rmbdr) + parseFloat(value); } else if (curr == 'USD') { usddr = parseFloat(usddr) + parseFloat(value); } else { otdr = parseFloat(otdr) + parseFloat(value); } ttldr = parseFloat(ttldr) + parseFloat(value) * 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'); if (curr == LOCALCURR) { rmbcr = parseFloat(rmbcr) + parseFloat(value); } else if (curr == 'USD') { usdcr = parseFloat(usdcr) + parseFloat(value); } else { otcr = parseFloat(otcr) + parseFloat(value); } ttlcr = parseFloat(ttlcr) + parseFloat(value) * 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); this.setHeadFieldValue('RMBDR', Ext.util.Format.number(parseFloat(rmbdr), '00.00')); this.setHeadFieldValue('RMBCR', Ext.util.Format.number(parseFloat(rmbcr), '00.00')); this.setHeadFieldValue('USDDR', Ext.util.Format.number(parseFloat(usddr), '00.00')); this.setHeadFieldValue('USDCR', Ext.util.Format.number(parseFloat(usdcr), '00.00')); this.setHeadFieldValue('OTDR', Ext.util.Format.number(parseFloat(otdr), '00.00')); this.setHeadFieldValue('OTCR', Ext.util.Format.number(parseFloat(otcr), '00.00')); this.setHeadFieldValue('TTLDR', Ext.util.Format.number(parseFloat(ttldr), '00.00')); this.setHeadFieldValue('TTLCR', Ext.util.Format.number(parseFloat(ttlcr), '00.00')); this.setHeadFieldValue('RMBPROFIT', Ext.util.Format.number(parseFloat(rmbprofit), '00.00')); this.setHeadFieldValue('USDPROFIT', Ext.util.Format.number(parseFloat(usdprofit), '00.00')); this.setHeadFieldValue('OTPROFIT', Ext.util.Format.number(parseFloat(otprofit), '00.00')); this.setHeadFieldValue('TTLPROFIT', Ext.util.Format.number(parseFloat(ttlprofit), '00.00')); this.setTotalHead(); }, setHeadFieldValue: function (fieldName, value) { var field = this.formtotal.getForm().findField(fieldName); field.setValue(value); }, setTotalHead: 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 rmbprofit = 0; var usdprofit = 0; var otprofit = 0; var ttlprofit = 0; var profitrate = 0; for (i = 0; i < this.storeBodySum.getCount(); i += 1) { var memberyf = this.storeBodySum.getAt(i); if (memberyf.data.CURR ==LOCALCURR) { rmbdr = memberyf.data.DR; rmbcr = memberyf.data.CR; rmbprofit = memberyf.data.PR; } else if (memberyf.data.CURR == 'USD') { usddr = memberyf.data.DR; usdcr = memberyf.data.CR; usdprofit = memberyf.data.PR; } if (memberyf.data.CURR == '其他币别') { otdr = memberyf.data.DR; otcr = memberyf.data.CR; otprofit = memberyf.data.PR; } if (memberyf.data.CURR == '合计') { ttldr = memberyf.data.DR; ttlcr = memberyf.data.CR; ttlprofit = memberyf.data.PR; profitrate = memberyf.data.PROFITRATE; } } var rmbdrlb = ""; var usddrlb = ""; var otdrlb = ""; var ttldrlb = ""; var rmbcrlb = ""; var usdcrlb = ""; var otcrlb = ""; var ttlcrlb = ""; var rmblb = ""; var usdlb = ""; var otlb = ""; var ttllb = ""; rmbdrlb = "   " + LOCALCURR + "应收:" + returnfloat(rmbdr) + ""; rmbcrlb = "    " + LOCALCURR + "应付: " + returnfloat(rmbcr) + ""; if (rmbprofit < 0) rmblb = "  " + LOCALCURR + "利润:" + returnfloat(rmbprofit) + "   |"; else rmblb = "  " + LOCALCURR + "利润:" + returnfloat(rmbprofit) + "   |"; // rmblb = "统计信息(文字标题)(字段名-中文):(字段值-负值)(字段名-中文):(字段值-正值)"; usddrlb = "   USD应收:" + returnfloat(usddr) + ""; usdcrlb = "    USD应付: " + returnfloat(usdcr) + ""; if (usdprofit < 0) usdlb = "   USD利润" + returnfloat(usdprofit) + "   |"; else usdlb = "   USD利润" + returnfloat(usdprofit) + "   |"; otdrlb = "   其他币别应收:" + returnfloat(otdr) + ""; otcrlb = "    其他币别应付: " + returnfloat(otcr) + ""; if (otprofit < 0) otlb = "   其他币别利润" + returnfloat(otprofit) + "   |"; else otlb = "   其他币别利润" + returnfloat(otprofit) + "   |"; ttldrlb = "    合计应收: " + returnfloat(ttldr) + ""; ttlcrlb = "    合计应付: " + returnfloat(ttlcr) + ""; if (ttlprofit < 0) ttllb = "   合计利润" + returnfloat(ttlprofit) + "  利润率" + returnfloat(profitrate) + "%"; else ttllb = "   合计利润" + returnfloat(ttlprofit) + "  利润率" + returnfloat(profitrate) + "%"; this.panelDrChFee.setTitle("应收费用 " + rmbdrlb + usddrlb + otdrlb + ttldrlb); this.panelCrChFee.setTitle("应付费用 " + rmbcrlb + usdcrlb + otcrlb + ttlcrlb); this.tabTotal.setTitle("利润合计:" + rmblb + usdlb + otlb + ttllb); }, //#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; 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); // } }, 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 selectedRecords = []; var storeadd = null; if (type == 1) { selectedRecords = this.feeDrGridCheckBoxModel.selected.items; MBLNO = _thisfeeview.strMBLNO; } else if (type == 2) { selectedRecords = this.feeCrGridCheckBoxModel.selected.items; MBLNO = _thisfeeview.strMBLNO; } else { alert(Zi.LAN.FEE.HanShuCanShuSheZhiBuDui); return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: Zi.LAN.FEE.TiShi, msg: Zi.LAN.FEE.QingXianXuanZeYeWu, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } _thisfeeview.strPBSNO = _thisfeeview.strBSNO; 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } 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 = '" + _thisfeeview.strPBSNO + "'"; } else if (this.stroplb == 'OpCtnBsCard') { var printType = ''; if (type == 1) { printType = 'CTNBSCARDDRFEE'; } else { printType = 'CTNBSCARDCRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_ctnbscard WHERE GID= '" + _thisfeeview.strPBSNO + "'"; } else if (this.stroplb == 'import_main') { var printType = ''; if (type == 1) { printType = 'IMPORTTRADEDRFEE'; } else { printType = 'IMPORTTRADECRFEE'; }; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from Import_main WHERE ContractNo= '" + _thisfeeview.strPBSNO + "'"; }; 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 录入人,(select DESCRIPTION from info_client where SHORTNAME=c.CUSTOMERNAME) CUSTFULLNAME 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='" + _thisfeeview.strBSNO + "')"; var sql5 = ""; if (feeGidSql != '') { sql5 = sql5 + " Select c.*,(select showname from [user] where gid=c.enteroperator) as 录入人,(select DESCRIPTION from info_client where SHORTNAME=c.CUSTOMERNAME) CUSTFULLNAME from ch_fee c where c.feetype=1 and c.bsno='" + _thisfeeview.strBSNO + "' and c.FEENAME in (SELECT FEENAME FROM CH_FEE WHERE GID IN (" + feeGidSql + ")) order by sort,LineNum "; } var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, MBLNO); }, onPrintAllDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } 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; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onPrintGainClick: function (button, event, type) { _thisfeeview = this; Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsChFee/GetGainPrint', scope: this, params: { bsno: _thisfeeview.strBSNO, oplb: _thisfeeview.stroplb }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { if (_thisfeeview.stroplb == 'op_Seae') { var printType = 'SEAEGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_Apply') { var printType = 'APPLYGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_Seai') { var printType = 'SEAIGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seai WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_Bulk') { var printType = 'BULKGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_bulk WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_other') { var printType = 'OTHERGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_other WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_railway') { var printType = 'RAILWAYGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_railway WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_Aire') { var printType = 'AIREGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_aire WHERE BSNO = '" + _thisfeeview.strBSNO + "'"; } else if (_thisfeeview.stroplb == 'op_Airi') { var printType = 'AIRIGAIN'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_airi WHERE BSNO = '" + _thisfeeview.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='" + _thisfeeview.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='" + _thisfeeview.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='" + _thisfeeview.strBSNO + "'" + " GROUP BY BSNO,CURRENCY,EXCHANGERATE,FEETYPE " + " ) AS C GROUP BY BSNO "; var sql5 = "exec GetPrintData '" + _thisfeeview.strBSNO + "'"; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } 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 }); } } }); } });