Ext.namespace('Shipping'); Shipping.MsCodeCtnTkAddIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCodeCtnTkAddIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCodeCtnTkAddIndex, Ext.Panel, { OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', PageSize: 50, MainEditRecord: null, storeBodyCtnList: null, initUIComponents: function () { this.formname = "formCodeCtnTkAddIndex"; //页面名称 //定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'MsCodeCtnTk', pageSize: this.PageSize, remoteSort: true, proxy: { type: 'ajax', url: '/MvcContainer/MsCodeCtnTk/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.storeDCLASS = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeDCLASS.load({ params: { enumTypeId: 97027} }); this.comboxDCLASS = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeDCLASS, fieldLabel: '危险品等级', name: 'DCLASS', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeIMDG = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeIMDG.load({ params: { enumTypeId: 97026} }); this.comboxIMDG = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeIMDG, fieldLabel: 'IMDG', name: 'IMDG', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.initgirdcolums = [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'COMPANYID', header: 'COMPANYID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'CTNNO', header: '箱号', width: 200 }, { sortable: true, dataIndex: 'TANKVOLUMN', header: '容积', width: 100 }, { sortable: true, dataIndex: 'CTNPROP', header: '箱属', width: 200 }, { sortable: true, dataIndex: 'OWNERCTN', header: '罐东', width: 200 }, { sortable: true, dataIndex: 'INSPECTION_EXPIRE_DATE', header: '年检到期日', width: 100 }, { sortable: true, dataIndex: 'INENDDATE', header: '保险到期日', width: 100 }, { sortable: true, dataIndex: 'CURPORT', header: '当前地区', width: 100 }, { sortable: true, dataIndex: 'CURSTATOIN', header: '当前位置', width: 100 }, { sortable: true, dataIndex: 'PREGOODNAME', header: '前装货', width: 100 }, { sortable: true, dataIndex: 'MADEDATE', header: '生产日期', width: 100 }, { sortable: true, dataIndex: 'MADEFACTORY', header: '生产厂家', width: 100 }, { sortable: true, dataIndex: 'NAMEPLATE', header: '铭牌信息', width: 200 }, { sortable: true, dataIndex: 'TANKWALLTHICK', header: '罐壁厚度', width: 100 }, { sortable: true, dataIndex: 'HEADTHICK', header: '封头厚度', width: 100 }, { sortable: true, dataIndex: 'TAREWEIGHT', header: '皮重', width: 100 }, { sortable: true, dataIndex: 'MAXWORKINGGPRESSURE', header: '最大允许压力', width: 100 }, { sortable: true, dataIndex: 'TESTINGGPRESSURE', header: '试验压力', width: 200 }, { sortable: true, dataIndex: 'DESIGNTEMPERATURE', header: '设计温度', width: 200 }, { sortable: true, dataIndex: 'TRAILPEDAL', header: '步道踏板', width: 100 }, { sortable: true, dataIndex: 'AIRVALVE', header: '空气阀', width: 100 }, { sortable: true, dataIndex: 'SAFETYVALVE', header: '安全阀', width: 100 }, { sortable: true, dataIndex: 'TOPVALVE', header: '顶阀', width: 100 }, { sortable: true, dataIndex: 'BOTTOMVALVE', header: '底阀', width: 100 }, { sortable: true, dataIndex: 'EXSITSIPHONPIPE', header: '虹吸管', width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'EXSITPRESSUREGAUGE', header: '压力表', width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'EXSITTOPOVERFLOWBOX', header: '顶部溢流盒盖', width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'EXSITINTOOVERFLOWBOX', header: '人孔溢流盒盖', width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'EXSITBOTTONVALVEDUSTCOVER', header: '底部阀门防尘罩', width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'STEAMPIPE', header: '蒸汽管', width: 100 }, { sortable: true, dataIndex: 'REMARKS', header: '备注', width: 200 }, { sortable: true, dataIndex: 'INPUTBYREF', header: '录入人', width: 100 }, { sortable: true, dataIndex: 'INPUTTIME', header: '录入时间', width: 100 }, { sortable: true, dataIndex: 'CTNSTATUS', header: '是否可用', width: 100 } ]; this.girdcolums = this.initgirdcolums; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _this = this; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.GridCheckBoxModel, columns: this.girdcolums , // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.girdcolums.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.girdcolums); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; var openSet = "height=500, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 500) / 2 + ",Left= " + (screen.width - 600) / 2 var openType = record.data.GID; var openUrl = "/MvcContainer/MsCodeCtnTk/Edit"; window.open(openUrl, openType, openSet); // DsOpenEditWin('/MvcContainer/MsCodeCtnTk/Edit', record.data.GID); }, this); //#region formSearch 查询面板 //客户加载_委托单位 this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCode.load({ params: { condition: " 1=1 "} }); //委托单位 _this = this; this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '罐东', store: this.storeCustCode, forceSelection: true, name: 'OWNERCTN', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCTNPROP = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeCTNPROP.load({ params: { enumTypeId: 97030} }); this.comboxCTNPROP = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCTNPROP, fieldLabel: '箱属', name: 'CTNPROP', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeIsDebit = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeIsDebit.add({ "DC": "1", "NAME": "是" }); this.storeIsDebit.add({ "DC": "2", "NAME": "否" }); this.comboxIsDebit = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '启用不能去航线', store: this.storeIsDebit, valueField: 'DC', displayField: 'NAME', value: '1', forceSelection: true, name: 'ISDEBIT', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeIsDebitGOOD = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeIsDebitGOOD.add({ "DC": "1", "NAME": "是" }); this.storeIsDebitGOOD.add({ "DC": "2", "NAME": "否" }); this.comboxIsDebitGOOD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '启用互斥', store: this.storeIsDebitGOOD, valueField: 'DC', displayField: 'NAME', value: '1', forceSelection: true, name: 'ISDEBITGOOD', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCTNSTATUS = Ext.create('Ext.data.Store', { fields: ['NAME'] }); this.storeCTNSTATUS.add({ "NAME": "可用"}); this.storeCTNSTATUS.add({ "NAME": "不可用" }); this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '是否可用', store: this.storeCTNSTATUS, valueField: 'NAME', displayField: 'NAME', value: '可用', forceSelection: true, name: 'CTNSTATUS', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); _this = this; 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: 'CTNNO', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxCTNPROP, this.comboxCustCode, this.comboxIsDebit, this.comboxIsDebitGOOD , this.comboxCTNSTATUS , { 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 //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { }, scope: this }, '-', { text: '确认添加', tooltip: '确认添加', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { this.addDetail(); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存", handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.InitGrid(_this.initgirdcolums); _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 75, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.sqlcontext = ''; this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: _this.sqlcontext }); }, this); this.parentWin = window.parent.opener._this; if (this.parentWin) { this.storeBodyCtnList = this.parentWin.storeBodyCtnList; this.MainEditRecord = this.parentWin.editRecord; } this.onRefreshClick(); }, //end initUIComponents InitGrid: function (grid) { var agirdcolums = grid; this.gridList.reconfigure(this.storeList, agirdcolums); }, 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 }); }, onDsQuery: function () { var sql = this.sqlcontext; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, addDetail: function () { var selectedRecords = []; var storeadd = null; selectedRecords = this.GridCheckBoxModel.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要添加的罐箱明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } for (var i = 0; i < selectedRecords.length; i++) { var memberyf = selectedRecords[i]; var newsort = this.storeBodyCtnList.getCount() + 1; var QUANTITY = 1; var AMOUNT = memberyf.data.UNITPRICE; if (this.MainEditRecord.get('CTNALL') == memberyf.data.UNIT) { QUANTITY = this.MainEditRecord.get('CTNNUM'); AMOUNT = Mul(memberyf.data.UNITPRICE, QUANTITY); } var selectrecords = DsStoreQueryBy(this.storeBodyCtnList, 'CTNNO', memberyf.data.CTNNO); if (selectrecords.length<=0) { var record = Ext.create('MsOpCtnApplyCtnItems', { GID: '*', LINKGID: '*', PRICETYPE: '1', ITEMSNO: newsort, CTNNO: memberyf.data.CTNNO, CTNPROP: memberyf.data.CTNPROP, INSPECTION_EXPIRE_DATE: memberyf.data.INSPECTION_EXPIRE_DATE, INSURANCE_EXPIRE_DATE: memberyf.data.INSURANCE_EXPIRE_DATE, OWNERCTN: memberyf.data.OWNERCTN, CURPORT: memberyf.data.CURPORT, CURSTATOIN: memberyf.data.CURSTATOIN, TANKVOLUMN: memberyf.data.TANKVOLUMN, PREGOODNAME: memberyf.data.PREGOODNAME, REMARKS: '' }); this.storeBodyCtnList.add(record); } }; Ext.Msg.alert('提示', '已加入!'); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } //var sql = " c.CTNSTATUS='可用' and (c.ISSTOPUSE=0 OR c.ISSTOPUSE IS NULL) "; var sql = "(c.ISSTOPUSE=0 OR c.ISSTOPUSE IS NULL) "; var CTNSTATUS = form.findField('CTNSTATUS').getValue(); sql = sql + getAndConSql(sql, CTNSTATUS, " c.CTNSTATUS = '" + CTNSTATUS + "' "); var CTNNO = form.findField('CTNNO').getValue(); sql = sql + getAndConSql(sql, CTNNO, " c.CTNNO like '%" + CTNNO + "%' "); var CTNPROP = form.findField('CTNPROP').getValue(); sql = sql + getAndConSql(sql, CTNPROP, "c.CTNPROP='" + CTNPROP + "'"); var OWNERCTN = form.findField('OWNERCTN').getValue(); sql = sql + getAndConSql(sql, OWNERCTN, "c.OWNERCTN='" + OWNERCTN + "'"); var ISDEBIT = form.findField('ISDEBIT').getValue(); if (ISDEBIT == '1') { sql = sql + getAndConSql(sql, ISDEBIT, " NOT EXISTS (SELECT 1 from Code_CtnTkNoLaneItems where Code_CtnTkNoLaneItems.LINKGID=c.GID AND LANEGID NOT IN (SELECT LANEGID from code_disport where PORT='" + this.MainEditRecord.get('PORTDISCHARGE') + "')) "); } var ISDEBITGOOD = form.findField('ISDEBITGOOD').getValue(); if (ISDEBITGOOD == '1') { sql = sql + getAndConSql(sql, ISDEBITGOOD, " NOT EXISTS (SELECT 1 from v_code_ctntk where v_code_ctntk.CTNNO=c.CTNNO AND PREGOODNAME IN (SELECT REJECTNAME from v_code_msds_rejection where MSDSNAME='" + this.MainEditRecord.get('GOODSNAME') + "')) "); } return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });