Ext.namespace('Shipping'); Shipping.MsOpSubSeaeOrderAIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpSubSeaeOrderAIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpSubSeaeOrderAIndex, Ext.Panel, { PageSize: 100, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, isShowAdvancedQuery: 0, //是否显示高级查询面板 IsAudit: false, BillType: 2, sqlcontext: '', OrType: 1, initUIComponents: function () { this.formname = "formMsOpSubSeaeOrderAIndex"; //页面名称 //定义数据集 this.storectndisp = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CtnDispModel', proxy: { url: '/CommMng/BasicDataRef/GetCtnDisp' } }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsSubSeaOrderModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSubSeaOrder/GetDataList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); //#region List列表显示信息 Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.girdcolums = [{ sortable: true, dataIndex: 'BSNO', header: 'BSNO', width: 0 }, { sortable: true, dataIndex: 'ORDNO', header: 'ORDNO', width: 120 }, { sortable: true, dataIndex: 'ORSTATUSREF', header: 'STATUS', width: 60 }, { sortable: true, dataIndex: 'SPCHARGE', header: 'SPECIAL CHARGE', renderer: function (value, p, record) { if (value == true) { return "YES" } else { return "NO" } }, width: 60 }, { sortable: true, dataIndex: 'BSDATE', header: 'BSDATE', width: 90 }, { sortable: true, dataIndex: 'ETD', header: 'ETD', width: 90 }, { sortable: true, dataIndex: 'BLFRT', header: 'BLFRT', width: 120 }, { sortable: true, dataIndex: 'CARGOID', header: 'CARGO', width: 60 }, { sortable: true, dataIndex: 'MBLNO', header: 'MBLNO', width: 120 }, { sortable: true, dataIndex: 'GOODSNAME', header: 'GOODS NAME', width: 120 }, { sortable: true, dataIndex: 'PKGS', header: 'PKGS', width: 80 }, { sortable: true, dataIndex: 'KGS', header: 'KGS', width: 80 }, { sortable: true, dataIndex: 'CNTRTOTAL', header: 'CNTR', width: 120 }, { sortable: true, dataIndex: 'INPUTBY', header: 'INPUTBY', width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: 'VESSEL', width: 100 }, { sortable: true, dataIndex: 'VOYNO', header: 'VOYNO', width: 60 }, { sortable: true, dataIndex: 'PORTLOAD', header: 'PORTLOAD', width: 100 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: 'PORTDISCHARGE', width: 100 }, { sortable: true, dataIndex: 'KINDPKGS', header: 'KINDPKGS', width: 60 }]; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "Loading,Wait..." }, trackMouseOver: true, disableSelection: false, selModel: this.GridCheckBoxModel, viewConfig: { autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var Status = record.get('SPCHARGE'); if (Status == true) { return 'feestatus_nopass'; } } }, listeners: { cellclick: function (thisTab, record, item, index, e, eOpts) { if (index == 10) {//设置按钮列 // alert('用户编号=' + this.getStore().getAt(rowIndex).data.usercode); } } }, columns: this.girdcolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: 'Display {0} - {1}Record/Total {2}Records', emptyMsg: "NO DATA" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = 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'; // window.open('/MvcShipping/MsOpSubSeaOrder/EditAgentExport', "ORDERA EDIT", 'width=1200,height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes'); DsOpenEditWin('/MvcShipping/MsOpSubSeaOrder/EditAgentExport'); }, this); //国际港口(进口装货港、出口卸货港) this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' } }); this.storeCodeDisport.load(); this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'PORTLOAD', store: this.storeCodeDisport, forceSelection: true, name: 'PORTLOAD', valueField: 'PORT', displayField: 'PORT' }); //国内港口(出口装货港、进口卸货港) this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' } }); this.storeCodeLoadport.load(); this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'PORTDISCHARGE', store: this.storeCodeLoadport, forceSelection: true, name: 'PORTDISCHARGE', valueField: 'PORT', displayField: 'PORT' }); this.StoreStatus = Ext.create('Ext.data.Store', { fields: ['ID', 'STATUS'] }); this.StoreStatus.add({ "ID": "9", "STATUS": "ENTRY" }); this.StoreStatus.add({ "ID": "1", "STATUS": "POSTED" }); this.StoreStatus.add({ "ID": "2", "STATUS": "REJECTED" }); this.StoreStatus.add({ "ID": "0", "STATUS": "RECEIVE" }); this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreStatus, fieldLabel: 'STATUS', forceSelection: true, name: 'ORSTATUS', valueField: 'ID', displayField: 'STATUS' }); //#endregion //#region formSearch 查询面板 this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.VesselModel', proxy: { url: '/CommMng/BasicDataRef/GetVesselList' } }); this.storeVoyVeg.load({ params: { condition: ""} }); this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'VESSEL', store: this.storeVoyVeg, name: 'VESSEL', valueField: 'VESSEL', flex: 1, displayField: 'VESSEL' }); 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.comboxStatus, { fieldLabel: 'MBLNO', name: 'MblNo' }, { fieldLabel: 'ETD', format: 'Y-m-d', xtype: 'datefield', name: 'ETDbgn' }, { fieldLabel: 'TO', format: 'Y-m-d', xtype: 'datefield', name: 'ETDend' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxPORTLOAD, this.comboxPORTDISCHARGE, this.comboxVoyVeg, { fieldLabel: 'VOYNO', name: 'VOYNO' }] }]//end items(fieldset 1) }]//end root items }); //#endregion formSearch //按钮工具条 _this = this; this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ text: "Add", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; // window.open('/MvcShipping/MsOpSubSeaOrder/EditAgentExport', "ORDERA EDIT", 'width=1200,height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes'); DsOpenEditWin('/MvcShipping/MsOpSubSeaOrder/EditAgentExport'); }, scope: this }, '-', { text: "EDI ", menu: [ { text: "WAIDAI EDI", handler: function (menu, event) { _this.onSaveEDI(); } } ], scope: this }, { text: "Delete", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "Query", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "Reset", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, '-', { id: 'btnSubmitAudit', text: 'Post', tooltip: 'POST', handler: function (button, event) { this.onSubmitAuditClick(); }, scope: this }, '-', { text: "Print", iconCls: 'btnprint', menu: [ { text: "Print All", handler: function (menu, event) { _this.Print(); } }, { text: "Print Select", handler: function (menu, event) { _this.PrintSelect(); } }], scope: this }, '-', { text: "Save Display List", id: "btntest", handler: function (button, event) { this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, true); }, scope: this }] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 100, items: [this.panelBtn, this.formSearch] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.onRefreshClick(); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql, billtype: this.BillType, ortype: this.OrType }); }, this); //#region 生成EDI this.formDownloadShow = Ext.widget('form', { frame: true, region: 'center', height: 100, 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', id: 'downloadfile', defaults: { anchor: '100%' }, items: [{ xtype: 'label', html: '', width: 120, text: '' } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); me = this; this.winDownloadShow = Ext.create('Ext.window.Window', { title: "Download EDI File", width: 450, height: 120, //plain : true, iconCls: "addicon", resizable: false, // 是否可以拖动 // draggable:false, collapsible: true, // 允许缩放条 closeAction: 'close', closable: true, modal: 'true', buttonAlign: "center", bodyStyle: "padding:0 0 0 0", items: [this.formDownloadShow], buttons: [{ text: "Close", minWidth: 70, handler: function () { me.winDownloadShow.close(); } }] }); //#endregion }, //end initUIComponents onRefreshClick: function (button, event) { //var girdcolums = this.gridList.getColumnMode(); var sql = this.getCondition(); this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql, billtype: this.BillType, ortype: this.OrType }, waitMsg: "Data being queried...", scope: this }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: 'Prompt', msg: 'Please Select The BILL!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.ORSTATUS == '0') { Ext.Msg.show({ title: 'Warning', msg: "The BILL Is Posted,Can't Delete !", icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('Prompt', 'Sure To Delete This Record?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('Deleting...'); Ext.Ajax.request({ waitMsg: 'Deleting...', url: '/MvcShipping/MsOpSubSeaOrder/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: 'Prompt', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: 'Error', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: 'Warning', msg: 'The Server Response Error, Please Try Again', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, onSaveEDI: function () { var GidStr = ''; var records = this.GridCheckBoxModel.selected.items; if (records.length == 0) { Ext.Msg.show({ title: '提示', msg: 'Pls Select Bill!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var insert; var bodyAddDatas = []; var j = 0; var Mblno = ''; for (var i = 0; i < records.length; i++) { var rec = records[i]; bodyAddDatas.push(rec); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); var msg = ''; msg = '确定要保存EDI文件吗?'; var strlo = window.location.host; _this = this; // Ext.MessageBox.confirm('提示', msg, function (btn) { // if (btn == 'yes') { Ext.Ajax.request({ waitMsg: 'Changing...', url: '/MvcShipping/MsOpSubSeaOrder/SaveEDIList', params: { headData: jsonbodyAddDatas, mblno: Mblno }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { var downloadfile = Ext.getCmp('downloadfile'); var children = downloadfile.items; if (children) { for (var i = 0, len = children.length; i < len; i++) { downloadfile.remove(children.items[i], true); } } var downloadfiles = '' + result.Message + ''; var htmla = Ext.widget('label', { html: downloadfiles, width: 120, text: '' }); downloadfile.items.add(htmla); this.winDownloadShow.show(); } } else { Ext.MessageBox.alert('The Server Response Error, Please Try Again', response.responseText); } }, scope: this }); // } // }, this); }, onSubmitAuditClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: 'Prompt', msg: 'Please Select Need Post The BILL!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.ORSTATUS != '9' && record.data.ORSTATUS != '2') { Ext.Msg.show({ title: 'Warning', msg: "The BILL Is Posted,Can't Post!", icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } _this = this; Ext.MessageBox.confirm('Prompt', 'Sure To Post This Record?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('POSTING...'); Ext.Ajax.request({ waitMsg: 'POSTING...', url: '/MvcShipping/MsOpSubSeaOrder/SubmitAudit', 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.onRefreshClick(); Ext.Msg.show({ title: 'Prompt', msg: 'Post Successful!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: 'Error', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: 'Warning', msg: 'The Server Response Error, Please Try Again', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, onSubmitAuditBackClick: function () { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: 'Prompt', msg: 'Please Select Need Cancel Post The BILL!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.ORSTATUS != '1') { Ext.Msg.show({ title: 'Warning', msg: "The BILL Is Posted,Can't Post!", icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } _this = this; Ext.MessageBox.confirm('Prompt', 'Sure To Cancel Post This Record?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('Cancel Posting...'); Ext.Ajax.request({ waitMsg: 'Cancel Posting...', url: '/MvcShipping/MsOpSubSeaOrder/SubmitAuditBack', 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.onRefreshClick(); Ext.Msg.show({ title: 'Prompt', msg: 'Cancel Post Successful!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: 'Error', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: 'Warning', msg: 'The Server Response Error, Please Try Again', 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('prompt', 'Query Conditions Assignment Errors,Pls Check。'); return ''; } var sql = ''; //#region formSearch 查询面板 //编号包括(主提单号) var MblNo = form.findField('MblNo').getValue(); sql = sql + getAndConSql(sql, MblNo, "(MBLNO like '%" + MblNo + "%' )"); //状态 var ORSTATUS = form.findField('ORSTATUS').getValue(); sql = sql + getAndConSql(sql, ORSTATUS, "ORSTATUS='" + ORSTATUS + "'"); //到港日期 var ETDbgn = form.findField('ETDbgn').getRawValue(); sql = sql + getAndConSql(sql, ETDbgn, "ETD >='" + ETDbgn + "'"); var ETDend = form.findField('ETDend').getRawValue(); sql = sql + getAndConSql(sql, ETDend, "ETD <='" + ETDend + "'"); // //牌号 // var CNTRTOTAL = form.findField('CNTRTOTAL').getValue(); // sql = sql + getAndConSql(sql, CNTRTOTAL, "CNTRTOTAL like '%" + CNTRTOTAL + "%'"); //装货港 var PORTLOAD = form.findField('PORTLOAD').getValue(); sql = sql + getAndConSql(sql, PORTLOAD, "PORTLOAD like '%" + PORTLOAD + "%'"); //卸货港 var PORTDISCHARGE = form.findField('PORTDISCHARGE').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, "PORTDISCHARGE like '%" + PORTDISCHARGE + "%'"); //船名 var VESSEL = form.findField('VESSEL').getValue(); sql = sql + getAndConSql(sql, VESSEL, "VESSEL like '%" + VESSEL + "%'"); //航次 var VOYNO = form.findField('VOYNO').getValue(); sql = sql + getAndConSql(sql, VOYNO, "VOYNO like '%" + VOYNO + "%'"); return sql; }, setIsShowAdvancedQuery: function () { if (this.isShowAdvancedQuery == 0) { this.panelSearch.show(); this.isShowAdvancedQuery = 1; } else { this.panelSearch.hide(); this.isShowAdvancedQuery = 0; } }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.IsAudit; ret[4] = this.BillType; ret[5] = this.OrType; return ret; }, Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsOpSubSeaOrder/GetDataListStr', scope: this, params: { condition: _this.sqlcontext, billtype: _this.BillType, ortype: _this.OrType }, 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 = 'MSSEAORDERLLIST'; 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 feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('ORDNO') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var printType = 'MSSEAORDERLISTSELECT'; var sql1 = "select * from op_sub_seaorder WHERE ORDNO IN (" + feeGidSql + ") ORDER BY BSDATE desc "; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });