Ext.namespace('Shipping'); Shipping.MsOpLetterIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpLetterIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpLetterIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, EditRecord: null, BsNo: "", oplb: '', initUIComponents: function () { //定义数据集 var mainform = window.parent.panelEdit; if (mainform == undefined) { parentWin = window.parent.opener; if (parentWin) { var ret = parentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.EditRecord = ret[2]; this.oplb = ret[4]; } this.BsNo = this.EditRecord.get('BSNO'); } else { this.EditRecord = mainform.editRecord; this.BsNo = this.EditRecord.get('BSNO'); this.oplb = mainform.stroplb; } this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpLetter', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpLetter/GetListData', reader: { id: 'BsNo', root: 'data', totalProperty: 'totalCount' } } }); this.girdcolums = [{ sortable: true, dataIndex: 'LE_ID', header: 'LE_ID', hidden: true, width: 150 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 150 }, { sortable: true, dataIndex: 'LETTERNAME', header: '函电名称', width: 120 }, { sortable: true, dataIndex: 'INPUTBY', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'INPUTTIME', header: '录入日期', width: 80 } ]; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolums, bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); _this = this; this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { _this.SelectedRecord = record; _this.OprationStatus = 'edit'; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; if (record.data.LETTERNAME == '入货通知') openUrl = "../../MvcShipping/MsOpLetter/YardEdit"; //window.open('/MvcShipping/MsOpLetter/YardEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no"); else if (record.data.LETTERNAME == '派车通知') openUrl = "../../MvcShipping/MsOpLetter/TruckEdit"; //window.open('/MvcShipping/MsOpLetter/TruckEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no"); else if (record.data.LETTERNAME == '电放保函') openUrl = "../../MvcShipping/MsOpLetter/SurEdit"; //window.open('/MvcShipping/MsOpLetter/SurEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no"); else if (record.data.LETTERNAME == '更改通知') openUrl = "../../MvcShipping/MsOpLetter/ChangeEdit"; //window.open('/MvcShipping/MsOpLetter/ChangeEdit', "函电", "height=" + (window.screen.availHeight - 155) + ", width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no"); window.open(openUrl, openType, openSet); }, this); //查询工具条 _this; this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", menu: [ { text: "入货通知", handler: function (menu, event) { _this.OprationStatus = 'add'; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; openUrl = "../../MvcShipping/MsOpLetter/YardEdit"; window.open(openUrl, openType, openSet); } }, { text: "派车通知", handler: function (menu, event) { _this.OprationStatus = 'add'; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; openUrl = "../../MvcShipping/MsOpLetter/TruckEdit"; window.open(openUrl, openType, openSet); } }, { text: "电放保函", handler: function (menu, event) { _this.OprationStatus = 'add'; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; openUrl = "../../MvcShipping/MsOpLetter/SurEdit"; window.open(openUrl, openType, openSet); } }, { text: "更改通知", handler: function (menu, event) { _this.OprationStatus = 'add'; var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2 var openType = "_blank"; var openUrl = ""; openUrl = "../../MvcShipping/MsOpLetter/ChangeEdit"; window.open(openUrl, openType, openSet); } }], scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "刷新", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 30, items: [this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.onRefreshClick(); this.storeList.on('beforeload', function (store) { var sql = "BSNO='" + this.BsNo + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = "BSNO='" + this.BsNo + "'"; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpLetter/Delete', params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, //onDeleteClick OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.EditRecord; ret[4] = this.oplb; return ret; } });