Ext.namespace('Shipping'); Shipping.MsOpSocCtnIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpSocCtnIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpSocCtnIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', selectbsno: '', sortfield: '', sortdire: '', initUIComponents: function () { this.formname = "MsOpSocCtnIndex"; //页面名称 //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpSocCtnContract', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSocCtn/GetDataList', 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: 'CONTRACTNO', header: '合同号', width: 80 }, { sortable: true, dataIndex: 'CONTRACTDATE', header: '合同日期', width: 80 }, { sortable: true, dataIndex: 'BSSTATUS', header: '状态', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '箱东', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERATTN', header: '箱东联系人', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERATTN', header: '箱东联系方式', width: 80 }, { sortable: true, dataIndex: 'CLOSEFEEDATE', header: '付款时间', width: 120 }, { sortable: true, dataIndex: 'CLOSEDOCDATE', header: '合同完成时间', width: 120 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 80 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 80 }, { sortable: true, dataIndex: 'RENT', header: '押金', width: 80 }, { sortable: true, dataIndex: 'RETURNDEPOSITDATE', header: '押金返回日期', width: 80 }, { sortable: true, dataIndex: 'DEPOSIT', header: '租金合计', width: 80 }, { sortable: true, dataIndex: 'CNTRTOTAL', 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/Edit', 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.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' } }); //委托单位 this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '箱东', store: this.storeCustCode, forceSelection: true, queryMode: 'remote', minChars: 1, queryParam: 'CODENAME', name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { //specialkey: function (field, e) { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeLoadportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' } }); this.storeCodeLoadport.load(); this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '装货港', //'装货港', store: this.storeCodeLoadport, name: 'PORTLOAD', valueField: 'PORT', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { //specialkey: function (field, e) { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeCtnModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' } }); this.storeCodeCtn.load(); this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '箱型', //'箱型', store: this.storeCodeCtn, forceSelection: true, name: 'CTNALL', valueField: 'CTN', displayField: 'CTN', 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.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.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: 'CONTRACTNO', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxCustCode, this.comboxCTNALL, this.comboxPORTLOAD, 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/Edit'); }, 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 bodyAddDatas = []; for (var i = 0; i < selections.length; i++) { var record = selections[i]; if (record.data.BSSTATUS != '新建') { Ext.Msg.show({ title: '警告', msg: '当前状态,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } bodyAddDatas.push(record); } // var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpSocCtn/Delete', params: { data: jsonbodyAddDatas }, 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); }, 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/LockList', 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 onUpOpStatusClick: function (menu, event, type) { var selections = this.GridCheckBoxModel.selected.items; if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var BSNOStr = ''; for (var i = 0; i < selections.length; i++) { var rec = selections[i]; var BSNO = "'" + rec.data.BSNO + "'"; if (BSNOStr == '') BSNOStr = BSNO; else { BSNOStr = BSNOStr + ',' + BSNO; } } if (BSNOStr == '') { Ext.Msg.show({ title: '提示', msg: '没有要更新的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } else { this.selectbsno = " BSNO IN (" + BSNOStr + ")"; window.open('/MvcShipping/MsOpStatus/PiLiang', "PILIANGOPSTATUS", 'width=1200,height=600,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes'); } }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var CONTRACTNO = form.findField('CONTRACTNO').getValue(); sql = sql + getAndConSql(sql, CONTRACTNO, "CONTRACTNO like '%" + CONTRACTNO + "%'"); var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "CUSTOMERNAME='" + CUSTOMERNAME + "'"); var PORTLOAD = form.findField('PORTLOAD').getValue(); sql = sql + getAndConSql(sql, PORTLOAD, "PORTLOAD= '" + PORTLOAD + "'"); var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, "PORTDISCHARGE= '" + PORTDISCHARGE + "'"); var CTNALL = form.findField('CTNALL').getValue(); sql = sql + getAndConSql(sql, CTNALL, "CTNALL= '" + CTNALL + "'"); 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/GetDataListStr', 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 = 'MSOPSOCCTNLIST'; 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 = 'MSOPSOCCTNLISTSELECT'; var sql1 = "select * from op_socctn_contract WHERE BSNO IN (" + feeGidSql + ") order by " + sortstr; var sql2 = "select * from op_socctn_contract 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/GetDataListStr', 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 }); } } }); } });