Ext.namespace('Shipping'); Shipping.MsOpSocCtnBsIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpSocCtnBsIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpSocCtnBsIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', selectbsno: '', sortfield: '', sortdire: '', initUIComponents: function () { this.formname = "MsOpSocCtnBsIndex"; //页面名称 //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpSocCtnBs', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSocCtn/GetBsDataList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 50 }); _this = this; this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: '每页记录数', labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.initgirdcolums = [{ sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 80 }, { sortable: true, dataIndex: 'MBLNO', header: '提单号', width: 80 }, { sortable: true, dataIndex: 'BSSTATUS', header: '状态', width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: '船名', width: 80 }, { sortable: true, dataIndex: 'VOYNO', header: '航次', width: 80 }, { sortable: true, dataIndex: 'ETD', header: '开船日期', width: 80 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 80 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 80 }, { sortable: true, dataIndex: 'TRANSPORT', header: '中转港', width: 80 }, { sortable: true, dataIndex: 'ETA', header: '到港日期', width: 80 }, { sortable: true, dataIndex: 'AGENT', header: '代理', width: 80 }, { sortable: true, dataIndex: 'RTCTNDATE', header: '返箱日期', width: 80 }, { sortable: true, dataIndex: 'RTCTNYARD', header: '返箱地点', width: 80 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: '创建人', width: 80 }, { sortable: true, dataIndex: 'CREATETIME', header: '创建日期', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSERREF', header: '修改人', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '修改日期', width: 80 }]; this.girdcolums = this.initgirdcolums; //定义Grid this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _this = this; 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, viewConfig: { enableTextSelection: true, //允许复制数据 autoFill: true }, // paging bar on the bottom bbar: [Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }), this.Pagenum] }); /////////////以下部分为获取存储的gridpanel显示样式 this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridList.reconfigure(this.storeList, this.girdcolums); this.gridList.columns[0] = new Ext.grid.RowNumberer(); //////////////////////////// this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsOpSocCtn/BsEdit', record.data.BSNO); }, this); this.gridList.addListener('sortchange', function (ct, column, direction, eOpts) { this.sortfield = column.dataIndex; this.sortdire = direction; }, this); //#region formSearch 查询条件 _this = this; this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportListRm' } }); this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '卸货港', //'卸货港', store: this.storeCodeDisport, name: 'PORTDISCHARGE', valueField: 'PORT', queryMode: 'remote', minChars: 2, queryParam: 'PORT', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeBSSTATUS = Ext.create('Ext.data.Store', { fields: ['FSTATUS', 'NAME'] }); this.storeBSSTATUS.add({ "FSTATUS": "新建", "NAME": "新建" }); this.storeBSSTATUS.add({ "FSTATUS": "正在执行", "NAME": "正在执行" }); this.storeBSSTATUS.add({ "FSTATUS": "已完成", "NAME": "已完成" }); this.storeBSSTATUS.add({ "FSTATUS": "已作废", "NAME": "已作废" }); this.comboxBSSTATUS = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '状态', store: this.storeBSSTATUS, valueField: 'FSTATUS', displayField: 'NAME', forceSelection: true, name: 'BSSTATUS', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.VesselModel', proxy: { url: '/CommMng/BasicDataRef/GetVesselList' } }); this.storeVoyVeg.load(); this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '船名', //'船 名', store: this.storeVoyVeg, name: 'VESSEL', valueField: 'VESSEL', displayField: 'VESSEL', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 45, msgTarget: 'qtip' }, items: [{ xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '提单号', name: 'MBLNO', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxVoyVeg, { fieldLabel:'航次', name: 'VOYNO', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxPORTDISCHARGE, this.comboxBSSTATUS,{ xtype: 'button', width: 90, text: "查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置", xtype: 'button', width: 90, iconCls: "btnreset", handler: function (button, event) { this.onClearSql(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 }] }] }] }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/MvcShipping/MsOpSocCtn/BsEdit'); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "状态更新", iconCls: 'btnprint', menu: [ //{ // text: "已完成", // handler: function (menu, event) { // _this.onLockClick('已完成'); // } //}, { text: "已作废", handler: function (menu, event) { _this.onLockClick('已作废'); } }], 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 }, '-', { text: "打印", iconCls: 'btnprint', menu: [ { text: "全部", handler: function (menu, event) { _this.Print(); } }, { text: "选择打印", handler: function (menu, event) { _this.PrintSelect(); } }], scope: this }, '-' ,{ text:'导出EXCEL', //"EXCEL模板导出", iconCls: "btnexportexcel", handler: function (button, event) { _this.onExportClick(); }, scope: this }] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 70, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m'); this.sqlcontext = ""; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: _this.sqlcontext }, waitMsg: "正在查询数据...", scope: this }); this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: _this.sqlcontext }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onDsQuery: function () { //var girdcolums = this.gridList.getColumnMode(); var sql = this.sqlcontext; this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; 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]; if (record.data.BSSTATUS != '新建') { Ext.Msg.show({ title: '警告', msg: '当前状态,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } // Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpSocCtn/DeleteBs', 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); }, onLockClick: function (type) { 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var record = selections[i]; //if (type == '1') { // if (record.data.BSSTATUS != '新建') { // Ext.Msg.show({ title: '警告', msg: '当前状态,不允许' + typestr + '!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); // return; // } //} //if (type == '0') { // if (record.data.BSSTATUS != '正在执行') { // Ext.Msg.show({ title: '警告', msg: '当前状态,不允许' + typestr + '!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); // return; // } //} bodyAddDatas.push(record); } // var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.MessageBox.confirm('提示', '确定' + type + '该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在锁定数据...'); Ext.Ajax.request({ waitMsg: '正在锁定数据...', url: '/MvcShipping/MsOpSocCtn/LockBsList', params: { data: jsonbodyAddDatas, type: type }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.reload(); 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); }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, //onDeleteClick getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var MBLNO = form.findField('MBLNO').getValue(); sql = sql + getAndConSql(sql, MBLNO, "MBLNO like '%" + MBLNO + "%'"); var VESSEL = form.findField('VESSEL').getValue(); sql = sql + getAndConSql(sql, VESSEL, "VESSEL='" + VESSEL + "'"); var VOYNO = form.findField('VOYNO').getValue(); sql = sql + getAndConSql(sql, VOYNO, "VOYNO like '%" + VOYNO + "%'"); var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, "PORTDISCHARGE= '" + PORTDISCHARGE + "'"); var BSSTATUS = form.findField('BSSTATUS').getValue(); sql = sql + getAndConSql(sql, BSSTATUS, "BSSTATUS= '" + BSSTATUS + "'"); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.selectbsno; ret[4] = 'op_socctn'; ret[5] = this.storePLList; return ret; }, Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsOpSocCtn/GetBsDataListStr', scope: this, params: { condition: _this.sqlcontext, printstr: 'true' }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MSOPSOCCTNBSLIST'; var sql1 = returnstr; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, PrintSelect: function () { _this = this; if (this.storeList.getCount() == 0) { return; } 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; } var sortstr = ''; if (this.sortfield != '' && this.sortdire != '') { sortstr = this.sortfield + ' ' + this.sortdire; } if (sortstr == "") sortstr = "CREATETIME " var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('BSNO') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var bsno = '11111'; var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length != 0) { var record = selections[0]; bsno = record.data.BSNO; } var printType = 'MSOPSOCCTNBSLISTSELECT'; var sql1 = "select * from op_socctn_bs WHERE BSNO IN (" + feeGidSql + ") order by " + sortstr; var sql2 = "select * from op_socctn_bs where BSNO='" + bsno + "'"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onExportClick: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var bsno = '11111'; var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length != 0) { var record = selections[0]; bsno = record.data.GID; } var sortstr = ''; if (this.sortfield != '' && this.sortdire != '') { sortstr = this.sortfield + ' ' + this.sortdire; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcContainer/MsOpSocCtn/GetBsDataListStr', scope: this, params: { condition: _this.sqlcontext, printstr: 'true', sort: sortstr }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MSOPSOCCTN'; var sql1 = returnstr; sql1 = sql1.replace(/\+/g, "@@@") if (sql1 != '') { GridExportBySql(sql1, this.formname, 'SOC箱订舱信息.xls'); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } });