Ext.namespace('Shipping'); Shipping.SeaeHistryFee = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.SeaeHistryFee.superclass.constructor.call(this); }; Ext.extend(Shipping.SeaeHistryFee, Ext.Panel, { PageSize: 10, ParentWin: null, feeType: 0, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, StoreFee: null, StoreFeeUnit: null, StoreFeeCust: null, EditRecord: null, StoreDateCurr: null, StoreCurr: null, initUIComponents: function () { this.sqlcontext = ''; //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsSeaeOrderModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsSeaeOrder/GetDataList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); //#region 主grid this.gridListCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'north', height: 268, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.gridListCheckBoxModel, viewConfig: { autoFill: true, enableTextSelection: true }, columns: [{ sortable: true, dataIndex: 'BSNO', header: '业务编号', width: 0 }, { sortable: true, dataIndex: 'ORDNO', header: '订单号', width: 120 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 120 }, { sortable: true, dataIndex: 'ORSTATUSREF', header: '状态', width: 60 }, { sortable: true, dataIndex: 'SALE', header: '揽货人', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 120 }, { sortable: true, dataIndex: 'BSDATE', header: '接单日期', width: 80 }, { sortable: true, dataIndex: 'ETD', header: '开船日期', width: 80 }, { sortable: true, dataIndex: 'BLTYPE', header: '装运方式', width: 60 }, { sortable: true, dataIndex: 'STLNAME', header: '结算方式', width: 60 }, { sortable: true, dataIndex: 'STLDATE', header: '结算日期', width: 60 }, { sortable: true, dataIndex: 'BLFRT', header: '付费方式', width: 60 }, { sortable: true, dataIndex: 'CARGOID', header: '货物标识', width: 60 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 120 }, { sortable: true, dataIndex: 'GOODSNAME', header: '品名', width: 120 }, { sortable: true, dataIndex: 'PKGS', header: '件数', width: 80 }, { sortable: true, dataIndex: 'KGS', header: '毛重', width: 80 }, { sortable: true, dataIndex: 'CNTRTOTAL', header: '集装箱', width: 80 }, { sortable: true, dataIndex: 'INPUTBY', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'OP', header: '操作员', width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: '船名', width: 100 }, { sortable: true, dataIndex: 'VOYNO', header: '航次', width: 60 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 100 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 100 }, { sortable: true, dataIndex: 'CUSTOMSER', header: '报关行', width: 80 }, { sortable: true, dataIndex: 'KINDPKGS', header: '件数包装', width: 60 }, { sortable: true, dataIndex: 'CARRIER', header: '船公司', width: 100 }, { sortable: true, dataIndex: 'AUDITOPERATOR', header: '审核人', width: 100 }, { sortable: true, dataIndex: 'AUDITDATE', header: '审核日期', width: 100 }, { sortable: true, dataIndex: 'CONFIRMOP', header: '确认人', width: 100 }, { sortable: true, dataIndex: 'CONFIRMDATE', header: '确认日期', width: 100 } ], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); //#endregion //#region 固定费用明细表 //#region 费用表 //明细表表格相关 this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} }); this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', { store: this.storeFeeTypeRef, name: 'FeeType' }); //明细表-数据集 this.storeBodyChFee = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsChFee/GetOrderDataList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.radiogroup = new Ext.form.RadioGroup({ fieldLabel: '引入方式', width: 380, columns: 2, items: [ { boxLabel: '全部引入', name: 'rb', id: 'rdall', inputValue: '1', checked: true }, { boxLabel: '不引入客户', name: 'rb', id: 'rdfee', inputValue: '2' }, ] }); _this = this; this.gridListChFee = new Ext.grid.GridPanel({ store: this.storeBodyChFee, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.feeGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return Shipping.FeeGetRowClass(feeStatus); } }, columns: [{ 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: 120 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '不含税单价', 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; }, align: 'right', width: 80 }, { 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: 'TaxUnitPrice', header: '单价', 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; }, align: 'right', width: 80 }, { sortable: true, dataIndex: 'Quantity', header: '数量', width: 60 }, { sortable: true, dataIndex: 'NoTaxAmount', 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: 'Amount', 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: 'Currency', header: '币别', width: 40 }, { sortable: true, dataIndex: 'ExChangerate', 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: '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: 'IsAdvancedpay', header: '是否垫付', width: 60 }, { 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 } ], // paging bar on the bottom bbar: [this.radiogroup, '-', { xtype: "button", id: "button_add", iconCls: "btnadd", text: "引入费用", handler: function (button, event) { _this.onAddDetailClick(button, event); } }, '-', { xtype: "button", id: "button_close", text: "取消退出", handler: function (button, event) { window.close(); } } ] }); //#endregion //#region formSearch //#region formSearch枚举参照相关 //#endregion this.formSearch = Ext.widget('form', { frame: true, region: 'center', 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: 'MblNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '委托单位', name: 'CustName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '从开船日期', format: 'Y-m-d', xtype: 'datefield', name: 'CustDate_Min', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '至开船日期', format: 'Y-m-d', xtype: 'datefield', name: 'CustDate_Max', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { xtype: 'button', width: 90, text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this } ] }] }] }); //#endregion formSearch //#region 按钮ToolBar //#endregion //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 55, items: [this.formSearch] }); this.panelBodyChFee = new Ext.Panel({ title: '费用明细', layout: "border", region: 'center', margin: '5 10', items: [this.gridListChFee] }); this.panelFee = new Ext.Panel({ layout: "border", region: "center", items: [ this.panelBodyChFee ] }); Ext.apply(this, { items: [this.panelTop, this.gridList, this.panelFee] }); //#endregion this.parentWin = window.parent.opener._thisorderfee; if (this.parentWin) { this.feeType = this.parentWin.feeType; if (this.feeType == 1) { this.StoreFee = this.parentWin.storeDrChFee; } else if (this.feeType == 2) { this.StoreFee = this.parentWin.storeCrChFee; } this.StoreFeeUnit = this.parentWin.StoreUnit; this.StoreFeeCust = this.parentWin.StoreCustType; this.StoreDateCurr = this.parentWin.StoreDateCurr; this.StoreCurr = this.parentWin.StoreCurr; this.EditRecord = this.parentWin.EditRecord; } //#region 事件绑定 this.storeList.on('beforeload', function (store) { var sql = this.sqlcontext; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeList.on('load', function (store, records) { if (store.getCount() > 0) { this.gridList.getSelectionModel().select(0); //this.gridListCheckBoxModel.selectAll(); } }, this); this.gridList.getSelectionModel().on('select', function (model, record, index) { //alert(record.data.BillNo); var bsno = record.data.BSNO; this.storeBodyChFee.load({ params: { billno: bsno, type: this.feeType, optype: 'op_Seae'} }); }, this); //#endregion //#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示) // this.onAutoRefresh(); //#endregion // this.SetBtnRight(); }, //end initUIComponents onAutoRefresh: function () { var myDate = new Date(); var start = new Date(myDate.getTime() - 31 * 24 * 3600 * 1000); var mydatestr = Ext.util.Format.date(start, 'Y-m'); var sql = " B.ACCDATE='" + mydatestr + "'"; this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onAddDetailClick: function (button, event) { var type; var rdall = Ext.getCmp('rdall'); if (rdall.checked) { type = 1; } else { type = 2; } var myDate = new Date(); selectedRecords = this.feeGridCheckBoxModel.selected.items; if (selectedRecords.length == 0) { this.feeGridCheckBoxModel.selectAll(); selectedRecords = this.feeGridCheckBoxModel.selected.items; } for (i = 0; i < selectedRecords.length; i += 1) { var memberyf = selectedRecords[i]; var record = null; var records = DsStoreQueryBy(this.StoreFeeUnit, 'UNIT', memberyf.data.Unit); if (records.getCount() > 0) { var data = records.getAt(0).data; var quantity = data.QUANTITY; } else { var quantity = 0; } var taxrate = memberyf.data.TaxRate; if (taxrate == null) taxrate = 0; var notaxamount = Mul(quantity, memberyf.data.UnitPrice); var tax = Div(Mul(notaxamount, taxrate), 100); var amount = Add(notaxamount, tax); var Feetype = memberyf.data.FeeType; var curr = memberyf.data.Currency; var exrate = 0; if (curr =='RMB') { exrate = 1 } else { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', curr); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; if (Feetype == 2) exrate = ffdata.CRDEFRATE; else exrate = ffdata.DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', curr); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; if (Feetype == 2) exrate = dfdata.CRDEFRATE; else exrate = dfdata.DEFRATE; } else { } } if (exrate == 0) exrate = memberyf.data.ExchangeRate; }; // var amount = Ext.util.Format.number(parseFloat(notaxamount) + parseFloat(notaxamount) * parseFloat(taxrate) / 100, '0.00'); // var newsort = this.StoreFee.getCount() + 1; var newsort = this.GetHandleSerialNo(this.StoreFee, type); if (type == 1) { record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: memberyf.data.FeeType, FeeName: memberyf.data.FeeName, FeeDescription: memberyf.data.FeeDescription, CustomerType: memberyf.data.CustomerType, CustomerName: memberyf.data.CustomerName, Unit: memberyf.data.Unit, UnitPrice: memberyf.data.UnitPrice, TaxUnitPrice: memberyf.data.TaxUnitPrice, Quantity: quantity, TaxRate: taxrate, NoTaxAmount: notaxamount, Amount: amount, AccTaxRate: memberyf.data.AccTaxRate, Currency: memberyf.data.Currency, ExChangerate: exrate, 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: newsort, IsInvoice: "0", FeeFrt: memberyf.data.FeeFrt }); } else { var custtype = memberyf.data.CustomerType; if (custtype == '') { if (memberyf.data.FeeType == 1) custtype = '委托单位' else custtype = '订舱代理' }; var records = DsStoreQueryBy(this.StoreFeeCust, 'CUSTTYPE', custtype); if (records.getCount() > 0) { var data = records.getAt(0).data; var custname = this.EditRecord.get(data.CUSTNAME); } else { var custname = ''; } record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: memberyf.data.FeeType, 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: quantity, TaxRate: taxrate, NoTaxAmount: notaxamount, Amount: amount, AccTaxRate: memberyf.data.AccTaxRate, Currency: memberyf.data.Currency, ExChangerate: exrate, 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: newsort, IsInvoice: "0", FeeFrt: memberyf.data.FeeFrt, IsCrmOrderFee: "0", AuditStatus: 0 }); } record.id = NewGuid(); record.internalId = NewGuid(); this.StoreFee.add(record); }; this.parentWin.onPostDetailClick(NaN, NaN, this.feeType); this.parentWin.calcDetailTotal(); window.closeAction = 'destroy'; window.close(); }, 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; }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var custName = form.findField('CustName').getValue(); sql = sql + getAndConSql(sql, custName, "CUSTOMERNAME like '%" + custName + "%'"); var mblNo = form.findField('MblNo').getValue(); sql = sql + getAndConSql(sql, mblNo, " (CUSTNO like '%" + mblNo + "%' or CUSTOMNO like '%" + mblNo + "%' or MBLNO like '%" + mblNo + "%' or HBLNO like '%" + mblNo + "%') "); var custDate_Min = form.findField('CustDate_Min').getRawValue(); sql = sql + getAndConSql(sql, custDate_Min, "ETD>= '" + custDate_Min + "'"); var custDate_Max = form.findField('CustDate_Max').getRawValue(); sql = sql + getAndConSql(sql, custDate_Max, "ETD <= '" + custDate_Max + " 23:59:59'"); return sql; } });