//集运管理-路单查询 Ext.namespace('Shipping'); Shipping.MsOpPriceProjectAddIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpPriceProjectAddIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpPriceProjectAddIndex, Ext.Panel, { PageSize: 2000, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '1=2', MainEditRecord: null, storeBodyCostList: null, initUIComponents: function () { this.formname = 'MsOpPriceProjectAddIndex'; this.sqlcontext = '1=2'; //定义Grid this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeNowCurrList' } }); this.StoreDateCurr.load(); this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr.load({ params: { condition: "" } }); //#region 运价方案 this.storeListProject = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpPrice', remoteSort: true, proxy: { type: 'ajax', url: '/MvcContainer/MsOpPrice/GetProjectDataList', reader: { root: 'data', totalProperty: 'totalCount' } } }); //定义Grid this.initgirdcolumsProject = [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'COMPANYID', header: 'COMPANYID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'PRICETYPE', header: 'PRICETYPE', hidden: true, width: 120 }, { sortable: true, dataIndex: 'AGENTNAME', header: '代理名称', width: 100 }, { sortable: true, dataIndex: 'PRJECTTYPE', header: '方案类别', width: 60 }, { sortable: true, dataIndex: 'PRJECTSOURCE', header: '运价来源', width: 60 }, { sortable: true, dataIndex: 'BEGINDATE', header: '开始日期', width: 60 }, { sortable: true, dataIndex: 'ENDDATE', header: '结束日期', width: 60 }, { sortable: true, dataIndex: 'ISTRANSPORT', header: '是否中转', width: 60, renderer: function (value, meta) { if (value == '1') { return "是"; } } }, { sortable: true, dataIndex: 'ISBEST', header: '是否最优方案', width: 60, renderer: function (value, meta) { if (value == '1') { return "是"; } } }, { sortable: true, dataIndex: 'PRJECTMARK', header: '方案批注', width: 100 }, { sortable: true, dataIndex: 'OPREF', header: '维护人', width: 100 }, { sortable: true, dataIndex: 'PORTLOAD', header: '起运港', width: 100 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '目的港', width: 100 }, { sortable: true, dataIndex: 'CARRIER', header: '船公司', width: 100 }, { sortable: true, dataIndex: 'VOYAGE', header: '航程', width: 100 }, { sortable: true, dataIndex: 'VALIDETD', header: '有效期', width: 100 }, { sortable: true, dataIndex: 'SERVICE', header: '运输条款', width: 100 }, { sortable: true, dataIndex: 'GOODTYPE', header: '货物类别', width: 100 }, { sortable: true, dataIndex: 'CTNSTATUS', header: '箱状态', width: 100 }, { sortable: true, dataIndex: 'REMARKS', header: '备注', width: 200 }, { sortable: true, dataIndex: 'OTHER1COST', header: '出口海运费', width: 100 }, { sortable: true, dataIndex: 'OTHER2COST', header: '出口港杂费', width: 100 }, { sortable: true, dataIndex: 'OTHER3COST', header: '目的港DAP费用', width: 100 }, { sortable: true, dataIndex: 'OTHER4COST', header: '目的港加热相关', width: 100 }, { sortable: true, dataIndex: 'OTHER5COST', header: '回程起运港堆场费用', width: 100 }, { sortable: true, dataIndex: 'OTHER6COST', header: '回程起运港杂费', width: 100 }, { sortable: true, dataIndex: 'OTHER7COST', header: '回程海运费', width: 100 }, { sortable: true, dataIndex: 'OTHER8COST', header: '回程目的港杂费', width: 100 }, { sortable: true, dataIndex: 'OTHER9COST', header: '改装费', width: 100 }, { sortable: true, dataIndex: 'OTHER10COST', header: '清洗相关费用', width: 100 }, { sortable: true, dataIndex: 'OTHER11COST', header: '清洗调拨费', width: 100 }, { sortable: true, dataIndex: 'TTL1COST', header: '罐租成本', width: 100 }, { sortable: true, dataIndex: 'TTL2COST', header: '成本合计', width: 100 }, { sortable: true, dataIndex: 'TTL4COST', header: '客户罐成本', width: 100 }, { sortable: true, dataIndex: 'TTL6COST', header: '回程成本合计', width: 100 }, { sortable: true, dataIndex: 'INPUTBYREF', header: '创建人', width: 100 }, { sortable: true, dataIndex: 'INPUTTIME', header: '创建时间', width: 100 }]; this.girdcolumsProject = this.initgirdcolumsProject; this.gridListProject = new Ext.grid.GridPanel({ store: this.storeListProject, enableHdMenu: false, region: 'north', height: 260, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolumsProject, bbar: Ext.create('Ext.PagingToolbar', { store: this.storeListProject, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.girdcolumsProject = DsTruck.GetGridPanel(USERID, this.formname + 'Project', this.girdcolumsProject, 1); this.gridListProject.reconfigure(this.storeListProject, this.girdcolumsProject); this.gridListProject.addListener('itemdblclick', function (dataview, record, item, index, e, b) { }, this); this.gridListProject.getSelectionModel().on('select', function (model, record, index) { var GID = record.data.GID; var sql = ""; sql = " LINKGID='" + GID + "' and ISNULL(ISSTOP,0)=0 AND FEESTATUS=0 "; this.storeBodyListProject.load({ params: { condition: sql } }); }, this); //#region 费用信息 this.storeBodyListProject = Ext.create('Ext.data.Store', { model: 'MsOpPriceItems', remoteSort: false, proxy: { type: 'ajax', url: '/MvcContainer/MsOpPrice/GetPriceItemsList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCheckBoxModelProject = Ext.create('Ext.selection.CheckboxModel'); this.gridListBodyProject = new Ext.grid.GridPanel({ store: this.storeBodyListProject, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.gridListCheckBoxModelProject, tbar: [{ text: '确认添加', tooltip: '确认添加', id: "btnadddetailProject", iconCls: "btnadddetail", handler: function (button, event) { this.addDetailProject(); }, scope: this }], columns: [{ sortable: true, dataIndex: 'GID', header: '编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'LINKGID', header: '业务编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'ITEMSNO', header: '序号', renderer: Ext.util.Format.numberRenderer('00'), align: 'right', width: 60 }, { sortable: true, dataIndex: 'FEENAME', header: '费用名称', width: 140 }, { sortable: true, dataIndex: 'UNIT', header: '标准', width: 100 }, { sortable: true, dataIndex: 'CURRENCY', header: '币别', width: 100 }, { sortable: true, dataIndex: 'UNITPRICE', 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: 110 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '付款方', width: 110 }, { sortable: true, dataIndex: 'REMARKS', header: '备注', width: 250 }, { sortable: true, dataIndex: 'PRICECLASS', header: '类别归属', width: 100 }, { sortable: true, dataIndex: 'MODIFYUSERREF', header: '录入人', width: 60 }, { sortable: true, dataIndex: 'MODIFYTIME', header: '录入日期', width: 80 }] }); this.panelBodyProject = new Ext.Panel({ title: '运价详细信息', layout: "border", region: 'center', animate: true, // autoScroll: true, // containerScroll: true, frame: false, items: [this.gridListBodyProject] }); //#endregion //#region formSearch 查询面板 this.storeCodeDisportProject = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' } }); //this.storeCodeDisportProject.load(); this.comboxPORTDISCHARGEProject = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '目的港', store: this.storeCodeDisportProject, name: 'PORTDISCHARGE', valueField: 'PORT', queryMode: 'remote', minChars: 2, queryParam: 'PORT', displayField: 'PORT', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); this.storePORTLOADProject = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' } }); this.comboxPORTLOADProject = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '起运港', store: this.storePORTLOADProject, name: 'PORTLOAD', valueField: 'PORT', queryMode: 'remote', minChars: 2, queryParam: 'PORT', displayField: 'PORT', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); //船公司 this.comboxCARRIERProject = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '船公司', store: this.storeCARRIER, forceSelection: true, name: 'CARRIER', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); this.storePRJECTTYPE = Ext.create('DsExt.ux.RefEnumStore', {}); this.storePRJECTTYPE.load({ params: { enumTypeId: 99070 } }); this.comboxPRJECTTYPE = Ext.create('DsExt.ux.RefTableCombox', { store: this.storePRJECTTYPE, fieldLabel: '方案类别', name: 'PRJECTTYPE', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); this.storeAgent = Ext.create('DsExt.ux.RefTableStore', { model: 'MsInfoClientModel', proxy: { url: '/MvcShipping/MsInfoClient/GetDataListAll' } }); this.storeAgent.load({ params: { start: 0, limit: 6000, condition: "ISAGENT='1'" } }); this.comboxAgent = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '代理', store: this.storeAgent, forceSelection: true, name: 'AGENTNAME', valueField: 'SHORTNAME', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); this.storeGOODTYPE = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeGOODTYPE.load({ params: { enumTypeId: 97028 } }); this.comboxGOODTYPE = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeGOODTYPE, fieldLabel: '货物类别', name: 'GOODTYPE', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshProjectClick(); } } } }); _this = this; this.formSearchProject = Ext.widget('form', { frame: true, region: 'north', height: 40, 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: [this.comboxPORTLOADProject, this.comboxPORTDISCHARGEProject, this.comboxAgent, this.comboxPRJECTTYPE, this.comboxGOODTYPE, { fieldLabel: '有效日期', format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'VALIDETD', 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.onRefreshProjectClick(button, event); }, scope: this } , { xtype: 'button', text: "保存列表样式", menu: [ { text: "保存", handler: function (button, event) { this.girdcolumsProject = DsTruck.SaveGridPanel(USERID, _this.formname + 'Project', _this.gridListProject.columns, _this.girdcolumsProject, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.gridListProject.reconfigure(_this.storeListProject, _this.initgirdcolumsProject); _this.girdcolumsProject = DsTruck.SaveGridPanel(USERID, _this.formname + 'Project', _this.gridListProject.columns, _this.initgirdcolumsProject, 1, true); } }] } ] } ]//end items(fieldset 1) }]//end root items }); //#endregion formSearch //#endregion this.panelProject = new Ext.Panel({ title: '运价方案', layout: "border", region: 'center', margin: '0 0', frame: true, items: [this.formSearchProject, this.gridListProject, this.panelBodyProject] }); this.tabpanel = new Ext.TabPanel ({ activeTab: 0, autoWidth: true, border: false, frame: false, region: 'center', id: "TabPanelID", enableTabScroll: true, items: [ this.panelProject ] }); Ext.apply(this, { items: [this.tabpanel] }); _this = this; this.storeListProject.on('beforeload', function (store) { var sql = this.getConditionProject(); Ext.apply(store.proxy.extraParams, { condition: sql, pricetype: '6' }); }, this); this.parentWin = window.parent.opener._this; window.closeAction = 'destroy'; }, //end initUIComponents onRefreshProjectClick: function (button, event) { var sql = this.getConditionProject(); this.sqlcontext = sql; this.storeListProject.load({ params: { start: 0, limit: this.PageSize, condition: sql, pricetype: '6' }, waitMsg: "正在查询数据...", scope: this }); }, addDetailProject: function () { var selections = this.gridListProject.getSelectionModel().getSelection(); if (selections.length == 0) { this.gridListProject.getSelectionModel().select(0); } selections = this.gridListProject.getSelectionModel().getSelection(); var rec = selections[0]; this.parentWin.setHeadFieldValue('PRICEGID', rec.data.GID); this.parentWin.ImportPriceData('edit', "GID='" + rec.data.GID + "'"); var usdexrate =this.calExchange('USD'); var selectedRecords = []; var storeadd = null; selectedRecords = this.gridListCheckBoxModelProject.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var CTNAMOUNT = 0; var TTLAMOUNT = 0; for (var i = 0; i < selectedRecords.length; i++) { var memberyf = selectedRecords[i]; // var newsort = this.parentWin.storeBodyPriceList.getCount() + 1; //var QUANTITY = 1; //var AMOUNT = memberyf.data.UNITPRICE; //if (memberyf.data.UNIT == '20TK') { var QUANTITY = this.parentWin.formHead.getForm().findField('CTNNUM').getValue(); var AMOUNT = Mul(memberyf.data.UNITPRICE, QUANTITY); //} var exchange = this.calExchange(memberyf.data.CURRENCY); var CTNUNITPRICE = Div(Mul(memberyf.data.UNITPRICE, exchange, 4), usdexrate); CTNAMOUNT = Add(CTNAMOUNT, CTNUNITPRICE , 2); TTLAMOUNT = Add(TTLAMOUNT, Mul(CTNUNITPRICE, QUANTITY, 4), 2); var record = Ext.create('MsOpPriceItems', { GID: '*', LINKGID: '*', PRICEGID: memberyf.data.LINKGID, ITEMSNO: memberyf.data.ITEMSNO, CUSTOMERNAME: memberyf.data.CUSTOMERNAME, FEENAME: memberyf.data.FEENAME, UNIT: memberyf.data.UNIT, UNITPRICE: memberyf.data.UNITPRICE, QUANTITY: QUANTITY, AMOUNT: AMOUNT, CURRENCY: memberyf.data.CURRENCY, EXCHANGERATE: exchange, GOODSNAME: memberyf.data.GOODSNAME, REMARKS: memberyf.data.REMARKS, INPUTBY: memberyf.data.INPUTBY, INPUTBYREF: memberyf.data.INPUTBYREF, INPUTTIME: memberyf.data.INPUTTIME, FEESTATUS: memberyf.data.FEESTATUS, FREEDAY: memberyf.data.FREEDAY, FEESTATUS_REF: memberyf.data.FEESTATUS_REF, CTNSTATUS: memberyf.data.CTNSTATUS, VALIDETD: memberyf.data.VALIDETD, ISSTOP: memberyf.data.ISSTOP, BEGINDATE: memberyf.data.BEGINDATE, ENDDATE: memberyf.data.ENDDATE, DATETYPE: memberyf.data.DATETYPE, PRICECLASS: memberyf.data.PRICECLASS, AUDITOPERATOR: memberyf.data.AUDITOPERATOR, AUDITDATE: memberyf.data.AUDITDATE, AUDITNAME: memberyf.data.AUDITNAME, MODIFYTIME: memberyf.data.MODIFYTIME, MODIFYUSERREF: memberyf.data.MODIFYUSERREF, MODIFYUSER: memberyf.data.MODIFYUSER, REASON: memberyf.data.REASON, APPLYTIME: memberyf.data.APPLYTIME, APPLYUSERREF: memberyf.data.APPLYUSERREF }); record.id = NewGuid(); record.internalId = NewGuid(); this.parentWin.storeBodyList.add(record); }; var RENTAMOUNT = this.parentWin.formEdit.getForm().findField('RENTAMOUNT').getValue(); TTLAMOUNT = Add(TTLAMOUNT, RENTAMOUNT, 2); this.parentWin.setEditFieldValue('TTLINUSDCOST', CTNAMOUNT); this.parentWin.setEditFieldValue('TTLCOST', TTLAMOUNT); Ext.Msg.alert('提示', '已加入!'); }, calExchange: function (curr) { var result = 1; if (curr != 'RMB') { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', curr); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; result = ffdata.DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', curr); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; result = dfdata.DEFRATE; } else { } } } return result; }, getConditionProject: function () { var form = this.formSearchProject.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = " b.PRICETYPE='6' AND ISNULL(ISBEST,'0')='1' AND (b.VALIDETD>GETDATE() AND isnull(B.ISSTOP,'')<>'是') and b.BSSTATUS='审核通过' "; var PORTLOAD = form.findField('PORTLOAD').getValue(); sql = sql + getAndConSql(sql, PORTLOAD, " b.PORTLOAD like '%" + PORTLOAD + "%' "); var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, " b.PORTDISCHARGE like '%" + PORTDISCHARGE + "%' "); var PRJECTTYPE = form.findField('PRJECTTYPE').getValue(); sql = sql + getAndConSql(sql, PRJECTTYPE, " b.PRJECTTYPE='" + PRJECTTYPE + "'"); var AGENTNAME = form.findField('AGENTNAME').getValue(); sql = sql + getAndConSql(sql, AGENTNAME, " b.AGENTNAME='" + AGENTNAME + "'"); var GOODTYPE = form.findField('GOODTYPE').getValue(); sql = sql + getAndConSql(sql, GOODTYPE, " b.GOODTYPE='" + GOODTYPE + "'"); var VALIDETD = form.findField('VALIDETD').getRawValue(); sql = sql + getAndConSql(sql, VALIDETD, "b.VALIDETD <='" + VALIDETD + "'"); return sql; }, onSaveGridClick: function (button, event) { if (this.tabpanel.getActiveTab() == this.panelBodyChFee) { this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname + 'bs', this.gridList.columns, this.girdcolums, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelSaleSum) { this.girdcolumssale = DsTruck.SaveGridPanel(USERID, this.formname + 'sale', this.gridListSale.columns, this.girdcolumssale, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelCustSum) { this.girdcolumscust = DsTruck.SaveGridPanel(USERID, this.formname + 'cust', this.gridListCust.columns, this.girdcolumscust, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelDeptSum) { this.girdcolumsdept = DsTruck.SaveGridPanel(USERID, this.formname + 'dept', this.gridListDept.columns, this.girdcolumsdept, 1, true); } }, oninitGridClick: function (button, event) { if (this.tabpanel.getActiveTab() == this.panelBodyChFee) { var agirdcolums = this.initgirdcolums; this.gridList.reconfigure(this.storeList, agirdcolums); this.girdcolums = DsTruck.SaveGridPanel(USERID, this.formname + 'bs', this.gridList.columns, this.initgirdcolums, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelSaleSum) { this.gridListSale.reconfigure(this.storeSaleList, this.initgirdcolumssale); this.girdcolumssale = DsTruck.SaveGridPanel(USERID, this.formname + 'sale', this.gridListSale.columns, this.initgirdcolumssale, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelCustSum) { this.gridListCust.reconfigure(this.storeCustList, this.initgirdcolumscust); this.girdcolumscust = DsTruck.SaveGridPanel(USERID, this.formname + 'cust', this.gridListCust.columns, this.initgirdcolumscust, 1, true); } else if (this.tabpanel.getActiveTab() == this.panelDeptSum) { this.gridListDept.reconfigure(this.storeDeptList, this.initgirdcolumsdept); this.girdcolumsdept = DsTruck.SaveGridPanel(USERID, this.formname + 'dept', this.gridListDept.columns, this.initgirdcolumsdept, 1, true); } } });