Ext.namespace('Shipping'); Shipping.YardPriceHistryFee = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.YardPriceHistryFee.superclass.constructor.call(this); }; Ext.extend(Shipping.YardPriceHistryFee, Ext.Panel, { PageSize: 10, ParentWin: null, feeType: 0, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, StoreFee: null, StoreFeeUnit: null, StoreFeeCust: null, EditRecord: null, initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpPrice', remoteSort: true, proxy: { type: 'ajax', url: '/MvcContainer/MsOpPrice/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: '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: 'COUNTRY', header: '国家', width: 100 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '港口', width: 100 }, { sortable: true, dataIndex: 'YARD', header: '场站', width: 100 }, { sortable: true, dataIndex: 'FEETYPE', header: '费用类别', width: 140 }, { sortable: true, dataIndex: 'REMARKS', header: '备注', width: 200 }, { sortable: true, dataIndex: 'INPUTBYREF', header: '录入人', width: 100 }, { sortable: true, dataIndex: 'INPUTTIME', 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 = this; //明细表表格相关 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.storeBodyList = Ext.create('Ext.data.Store', { model: 'MsOpPriceItems', remoteSort: true, proxy: { type: 'ajax', url: '/MvcContainer/MsOpPrice/GetPriceItemsList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); 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.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridListBody = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.feeGridCheckBoxModel, selType: 'cellmodel', 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: 'CUSTOMERNAME', header: '付款方', width: 110 }, { sortable: true, dataIndex: 'FEENAME', header: '费用名称', width: 140 }, { sortable: true, dataIndex: 'GOODSNAME', header: '品名', width: 140 }, { sortable: true, dataIndex: 'CTNSTATUS', header: '箱状态', width: 80 }, { sortable: true, dataIndex: 'FREEDAY', header: '免堆天数', renderer: Ext.util.Format.numberRenderer('00'), align: 'right', width: 60 }, { 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: 'VALIDETD', header: '有效日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 130 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 250 }], // 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枚举参照相关 //客户加载_场站 this.storeYARD = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeYARD.load({ params: { condition: "ISYARD='1'"} }); //场站 this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '场站', store: this.storeYARD, forceSelection: true, name: 'YARD', valueField: 'CustName', displayField: 'CodeAndName' }); this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' } }); this.storeCodeDisport.load(); this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '港口', store: this.storeCodeDisport, name: 'PORTDISCHARGE', valueField: 'PORT', queryMode: 'local', displayField: 'PORT', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCountry = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeCountry', proxy: { url: '/MvcShipping/MsCodeCountry/GetDataList' } }); this.storeCountry.load({ params: { condition: ""} }); this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '国家', store: this.storeCountry, name: 'COUNTRY', valueField: 'COUNTRY', displayField: 'COUNTRY' }); //#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: [this.comboxPORTDISCHARGE, this.comboxYARD, this.comboxCountry, { fieldLabel: '录入日期', format: 'Y-m-d', xtype: 'datefield', name: 'ETDbgn', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到', format: 'Y-m-d', xtype: 'datefield', name: 'ETDend', 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 }, { xtype: 'button', width: 90, text: "高级查询", iconCls: "btnmore", handler: function (button, event) { var sql = this.getCondition(); var winAccess = new Shipping.DsQuery({ }); winAccess.StoreList = this.storeList; winAccess.formname = this.formname; winAccess.condition = sql; winAccess.show(); return; }, scope: this }] } ]//end items(fieldset 1) }]//end root items }); //#endregion formSearch //#region 按钮ToolBar //#endregion //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 55, items: [this.formSearch] }); this.panelBody = new Ext.Panel({ title: '运价详细信息', layout: "border", region: 'center', animate: true, // autoScroll: true, // containerScroll: true, frame: false, items: [this.gridListBody] }); Ext.apply(this, { items: [this.panelTop, this.gridList, this.panelBody] }); //#endregion this.parentWin = window.parent.opener._this; if (this.parentWin) { this.PRICETYPE = this.parentWin.thispricetype; this.StoreFee = this.parentWin.storeBodyList; this.EditRecord = this.parentWin.editRecord; } //#region 事件绑定 this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); 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.GID; this.storeBodyList.load({ params: { condition: "LINKGID='" + bsno + "'"} }); }, this); //#endregion //#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示) this.onRefreshClick(); //#endregion // this.SetBtnRight(); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql, pricetype: this.PRICETYPE }, waitMsg: "正在查询数据...", scope: this }); }, onAddDetailClick: function (button, event) { 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]; record = Ext.create('MsOpPriceItems', { GID: NewGuid(), LINKGID: '*', ITEMSNO: memberyf.data.ITEMSNO, FEENAME: memberyf.data.FEENAME, UNIT: memberyf.data.UNIT, UNITPRICE: memberyf.data.UNITPRICE, CURRENCY: memberyf.data.CURRENCY, CHANGERATE: memberyf.data.CHANGERATE, GOODSNAME: memberyf.data.GOODSNAME, FEESTATUS: 1, FEESTATUS_REF: '录入状态', FREEDAY: memberyf.data.FREEDAY, GOODSNAME: memberyf.data.GOODSNAME, CTNSTATUS: memberyf.data.CTNSTATUS, VALIDETD: memberyf.data.VALIDETD, REMARKS: memberyf.data.REMARKS }); record.id = NewGuid(); record.internalId = NewGuid(); this.StoreFee.add(record); }; window.closeAction = 'destroy'; window.close(); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = " b.PRICETYPE='" + this.PRICETYPE + "' AND b.GID in (select LINKGID from op_price_items) "; var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, " b.PORTDISCHARGE like '%" + PORTDISCHARGE + "%' "); var YARD = form.findField('YARD').getValue(); sql = sql + getAndConSql(sql, YARD, " b.YARD='" + YARD + "'"); var COUNTRY = form.findField('COUNTRY').getValue(); sql = sql + getAndConSql(sql, COUNTRY, " b.COUNTRY='" + COUNTRY + "'"); var expDateBgn = form.findField('ETDbgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "b.INPUTTIME >='" + expDateBgn + "'"); var expDateEnd = form.findField('ETDend').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "b.INPUTTIME <='" + expDateEnd + " 23:59:59'"); return sql; } });