Ext.namespace('Shipping'); Shipping.MsOpCtnDetailEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpCtnDetailEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpCtnDetailEdit, Ext.Panel, { parentWin: null, editRecord: null, LocalData:null, initUIComponents: function () { this.serialNo = 0; this.itemindex = 1; //#region 加载父类值 parentWin = window.parent.opener; if (parentWin) { var ret = parentWin.OprationSwapOpCtnDetail(); this.editRecord = ret[0]; this.LocalData = ret[1]; } //#endregion //#region 下拉框信息加载 //箱型_集装箱列表中的下拉框加载 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' }); //件数包装_集装箱列表中的下拉框加载 this.storeCodePackage = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodePackageModel', proxy: { url: '/CommMng/BasicDataRef/GetCodePackageList' } }); this.storeCodePackage.load(); this.comboxKINDPKGS_CTN = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '件数包装', store: this.storeCodePackage, forceSelection: true, name: 'KINDPKGS', valueField: 'PKGS', displayField: 'PKGS' }); //#endregion //#region 集装箱-主列表 SI this.storeList = Ext.create('Ext.data.Store', { model: 'Booking_Ctn', async: false, remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/BookingConfirm/GetBookingCtnList', reader: { id: 'CTN_ID', root: 'data', totalProperty: 'totalCount' } } }); this.storeLocalCtnList = Ext.create('Ext.data.Store', { model: 'MsOpSeaeDetail', async: false, remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSeae/GetBodyList', reader: { id: 'CTN_ID', root: 'data', totalProperty: 'totalCount' } } }); this.girdcolums = [{ sortable: true, dataIndex: 'CTN_ID', header: '编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'CTNCODE', header: '序号', width: 35 }, { dataIndex: 'CTNALL', header: '箱型', width: 70, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'CTNNUM', header: '箱量', width: 50, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'CNTRNO', header: '箱号', width: 100, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'SEALNO', header: '封号', width: 80, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }, { sortable: true, dataIndex: 'PKGS', header: '件数', width: 80, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; }, align: 'right', summaryType: 'sum', summaryRenderer: Ext.util.Format.numberRenderer() }, { dataIndex: 'KINDPKGS', header: '件数包装', width: 120, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'KGS', header: '重量', width: 100, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; }, align: 'right', summaryType: 'sum', summaryRenderer: Ext.util.Format.numberRenderer('00.0000'), summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 4, '', true); return value; } }, { dataIndex: 'CBM', header: '尺码', width: 100, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; }, align: 'right', summaryType: 'sum', summaryRenderer: Ext.util.Format.numberRenderer('00.0000'), summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 4, '', true); return value; } }, { dataIndex: 'TAREWEIGHT', header: '箱皮重', width: 100, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; }, align: 'right', summaryType: 'sum', summaryRenderer: Ext.util.Format.numberRenderer('00.0000'), summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 4, '', true); return value; } }, { dataIndex: 'REMARK', header: '备注', width: 150, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer(value, meta, record, a, b, parentstore, c); return result; } }]; //定义Grid this.gridListMain = new Ext.grid.GridPanel({ title: '主提单号:' + this.editRecord.data.MBLNO.toString() + ' 集装箱信息', store: this.storeList, enableHdMenu: false, //region: 'west', region: 'north', height: 400, frame: true, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolums, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], tbar: [{ text: '预览打印',hidden:true, tooltip: '预览打印', id: "btnprint", iconCls: "btnprint", handler: function (button, event) { this.Print(button, event); }, scope: this }, { xtype: 'label', id: "morerecord", hidden: true, html: "注意!本地业务内的集装箱信息多于SI当中的" }, { xtype: 'label', id: "lessrecord", hidden: true, html: "注意!本地业务内的集装箱信息少于SI当中的" }] }); _this = this; this.gridListMain.addListener('itemclick', function (dataview, record, item, index, e, b) { _bsno = this.LocalData.get("BSNO"); if (this.editRecord.get('ISMULTI') == "true") _bsno = this.LocalData.get("AS_ID"); this.storeLocalCtnDetailList.load({ params: { condition: "CTN_ID in(select CTN_ID from op_ctn where BSNO ='" + _bsno + "')" }, callback: function (options, success, response) { _this.storeBodyList.load({ params: { condition: "CTN_ID='" + record.data.CTN_ID + "'" }, scope: this }); } , scope: this }); }, this); this.gridListMain.on("cellclick", function (grid, rowIndex, colIndex, record, event) { var rec = grid.getSelectionModel().getSelection()[0]; var column = grid.getHeaderAtIndex(colIndex); var FieldName = column.dataIndex; if (!_this.needFind(FieldName)) return; //var value = rowIndex.outerText; var value = rec.get(FieldName); var CNTRNO = rec.get("CNTRNO"); if (_this.FindDiffenet_record(CNTRNO, FieldName, value)) { var _localvalue = _this.FindLocal_value(CNTRNO, FieldName); if (_this.winAccess) { _this.winAccess.close(); _this.winAccess = null; } _this.winAccess = new Shipping.Diffwin({ }); _this.winAccess._sivalue = value + ""; _this.winAccess._localvalue = _localvalue; _this.winAccess.show(); return; } }); //#endregion //#region 集装箱-多品名明细表 SI this.storeBodyList = Ext.create('Ext.data.Store', { model: 'Booking_Ctn_Detailmb', remoteSort: false, async: false, proxy: { type: 'ajax', url: '/MvcShipping/BookingConfirm/GetBookingCtnDetailList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.storeLocalCtnDetailList = Ext.create('Ext.data.Store', { model: 'MsOpCtnDetail', remoteSort: false, async: false, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSeae/GetOpCtnDetailList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.girdcolums2 = [{ sortable: true, dataIndex: 'GID', header: '编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'CTN_ID', header: 'CTN编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'PKGS', header: '件数', width: 80, align: 'right', renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; }, summaryType: 'sum', summaryRenderer: Ext.util.Format.numberRenderer() }, { dataIndex: 'KINDPKGS', header: '包装', width: 120, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'KGS', header: '重量', width: 100, align: 'right', renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 4, '', true); return value; } }, { dataIndex: 'CBM', header: '尺码', width: 100, align: 'right', renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 4, '', true); return value; } }, { dataIndex: 'HSCODE', header: 'HS编码', width: 100, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'DESCRIPTION', readOnly: true, header: '货物描述(品名)', width: 200, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; } }, { dataIndex: 'MARKS',readOnly:true, header: '唛头', width: 200, renderer: function (value, meta, record, a, b, parentstore, c) { result = _this.gridCellrenderer_detail(value, meta, record, a, b, parentstore, c); return result; } }]; //this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { // clicksToEdit: 1 //}); this.gridList = new Ext.grid.GridPanel({ title: '多品名信息', store: this.storeBodyList, enableHdMenu: false, //region: 'north', region: 'west', width: 900, frame: true, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, //plugins: [this.gridListCellEditing], selType: 'cellmodel', columns: this.girdcolums2, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], tbar: [{ text: '添加明细',hidden:true, tooltip: '添加明细', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { //this.onAddDetailClick(button, event); }, scope: this }, { id: 'btnESave',hidden:true, text: "保存明细", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: '删除明细', hidden: true, tooltip: '删除明细', id: "btndeldetail", iconCls: "btndeletedetail", handler: function (button, event) { //this.onDelDetailClick(button, event); }, scope: this }, '-', { text: '引入EXCEL数据', hidden: true, handler: function (button, event) { this.onImportCtnDetailClick(button, event); }, scope: this }, { xtype: 'label', id: "morerecord_detail", hidden: true, html: "注意!本地业务内的多品名明细信息多于SI当中的" }, { xtype: 'label', id: "lessrecord_detail", hidden: true, html: "注意!本地业务内的多品名明细信息少于SI当中的" }] }); this.gridList.on("cellclick", function (grid, rowIndex, colIndex, record, event) { var rec = grid.getSelectionModel().getSelection()[0]; var column = grid.getHeaderAtIndex(colIndex); var FieldName = column.dataIndex; if (!_this.needFind_detail(FieldName)) return; //var value = rowIndex.outerText; var value = rec.get(FieldName); var HSCODE = rec.get("HSCODE"); if (_this.FindDiffenet_record_detail(HSCODE, FieldName, value)) { var _localvalue = _this.FindLocal_value_detail(HSCODE, FieldName); if (_this.winAccess) { _this.winAccess.close(); _this.winAccess = null; } _this.winAccess = new Shipping.Diffwin({ }); _this.winAccess._sivalue = value + ""; _this.winAccess._localvalue = _localvalue; _this.winAccess.show(); return; } }); this.gridList.addListener('itemclick', function (dataview, record, item, index, e, b) { this.formEdit.getForm().findField('DESCRIPTION').setValue(record.data.DESCRIPTION); this.formEdit.getForm().findField('MARKS').setValue(record.data.MARKS); }, this); //#endregion //#region 编辑formEdit 基本信息 this.formEdit = Ext.widget('form', { title: '货物描述(品名)与唛头信息', region: 'center', frame: true, border: false, trackResetOnLoad: true, items: [{ fieldLabel: 'GID', name: 'GID', hidden: true }, { xtype: 'label', flex: 1, id: 'DESCRIPTIONSTR', html: "" }, { xtype: 'textareafield', grow: true, //字段是否自动伸展和收缩,默认为false labelSeparator: '', //标签分隔字符 name: 'DESCRIPTION', height: 170, anchor: '100%', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'blur': function blur(combo, eOpts, obj) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length > 0) { this.SetShipperLable('DESCRIPTION', 35); selections[0].set('DESCRIPTION', combo.value); } this.formEdit.getForm().findField('DESCRIPTION') .setValue(combo.value.toUpperCase()); } // } }, { xtype: 'label', flex: 1, id: 'MARKSSTR', html: "" }, { xtype: 'textareafield', grow: true, //字段是否自动伸展和收缩,默认为false labelSeparator: '', //标签分隔字符 name: 'MARKS', height: 170, anchor: '100%', enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'blur': function blur(combo, eOpts, obj) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length > 0) { this.SetShipperLable('MARKS', 24); selections[0].set('MARKS', combo.value); } this.formEdit.getForm().findField('MARKS') .setValue(combo.value.toUpperCase()); } // } }] }); //#endregion //#region 框架结构 Ext.apply(this, { border: false, items: [this.gridListMain, this.gridList, this.formEdit] }); //#endregion //#region 加载列表 this.Loaddata(); //#endregion }, Loaddata: function () { if (this.editRecord.get('ISMULTI') == "true") { //同一提单号多条提单确认 有提单列表项 this.storeLocalCtnList.load({ params: { condition: " BSNO = '" + this.LocalData.get("AS_ID") + "' " }, callback: function (options, success, response) { _bsno = _this.editRecord.get("SINO"); _this.storeList.load({ params: { condition: " ORDNO='" + _bsno + "'" }, scope: this }); }, scope: this }); } else { //单一提单号 单一提单确认 无提单列表项 this.storeLocalCtnList.load({ params: { condition: " BSNO = '" + this.LocalData.get("BSNO") + "' " }, callback: function (options, success, response) { _bsno = _this.editRecord.get("SINO"); _this.storeList.load({ params: { condition: " ORDNO='" + _bsno + "'" }, scope: this }); }, scope: this }); } }, //#region 保存明细 Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } // var selections = this.gridListMain.getSelectionModel().getSelection(); var sCTN_ID = selections[0].data.CTN_ID; var iPKGS = selections[0].data.PKGS; var dKGS = selections[0].data.KGS; var dCBM = selections[0].data.CBM; // var data = this.formEdit.getForm().getValues(false, false, false); var bodydatas = []; var iPKGS2 = 0; var dKGS2 = 0; var dCBM2 = 0; for (var i = 0; i < this.storeBodyList.getCount(); i += 1) { iPKGS2 += this.storeBodyList.getAt(i).get("PKGS"); dKGS2 = Add(dKGS2, this.storeBodyList.getAt(i).get("KGS")); var ctncbm=this.storeBodyList.getAt(i).get("CBM"); dCBM2 = Add(dCBM2, parseFloat(ctncbm).toFixed(4)); var member = this.storeBodyList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJsonAll(bodydatas); // //if (iPKGS2 > iPKGS) { // Ext.Msg.show({ title: '错误', msg: "多品名中 件数总和 超出 集装箱件数!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; //} //if (dKGS2 > dKGS) { // Ext.Msg.show({ title: '错误', msg: "多品名中 重量总和 超出 集装箱重量!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; //} //if (dCBM2 > dCBM) { // Ext.Msg.show({ title: '错误', msg: "多品名中 立方数总 超出 集装箱立方数!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); // return; //} // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpSeae/SaveOpCtnDetail', scope: this, params: { body: jsonBody, pkgs: iPKGS, kgs: dKGS, cbm: dCBM }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.storeBodyList.load({ params: { condition: "CTN_ID='" + sCTN_ID + "'" }, scope: this }); } 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 }); } } }); }, //end save //#endregion ///用于标记SI数据行数多于或者少于本地数据 SetDiff_store: function () { BENDI = this.storeLocalCtnList.count(); SI = this.storeBodyList.count(); if (BENDI > SI) { Ext.getCmp("morerecord").show(); } if (BENDI < SI) { Ext.getCmp("lessrecord").show(); } }, SetDiff_store_detail: function () { BENDI = this.storeLocalCtnList.count(); SI = this.storeBodyList.count(); if (BENDI > SI) { Ext.getCmp("morerecord_detail").show(); } if (BENDI < SI) { Ext.getCmp("lessrecord_detail").show(); } }, needFind: function (FieldName) { result = false; CtnDiffField.each(function (record) { if (record.get("FieldName") == FieldName) { result = true; } }); return result; }, FindDiffenet_record: function (CNTRNO, FieldName, FieldValue) { result = true; this.storeLocalCtnList.each(function (record) { if (record.get("CNTRNO") == CNTRNO) { LocalValue = record.get(FieldName); if (FieldName == "TAREWEIGHT") { LocalValue = getFloat(LocalValue, 4); } if (LocalValue + "" == FieldValue + "") { result = false; } else result = true; } }); return result; }, FindLocal_value: function (CNTRNO, FieldName) { result = "NaN"; this.storeLocalCtnList.each(function (record) { if (record.get("CNTRNO") == CNTRNO) { LocalValue = record.get(FieldName); if (FieldName == "TAREWEIGHT") { LocalValue = getFloat(LocalValue, 4); } result = LocalValue + ""; } }); return result; }, gridCellrenderer: function (value, meta, record, a, b, parentstore, c) { headname = _this.girdcolums[b].dataIndex; if (!_this.needFind(headname)) { return value; } else { isdifferent = _this.FindDiffenet_record(record.get("CNTRNO"), headname, value); if (isdifferent) { meta.tdCls = 'feestatus_nopass'; } return value; } }, needFind_detail: function (FieldName) { result = false; CtnDetailDiffField.each(function (record) { if (record.get("FieldName") == FieldName) { result = true; } }); return result; }, FindDiffenet_record_detail: function (HSCODE, FieldName, FieldValue) { result = true; this.storeLocalCtnDetailList.each(function (record) { if (record.get("HSCODE") == HSCODE) { if (record.get(FieldName) + "" == FieldValue + "") { result = false; } else result = true; } }); return result; }, FindLocal_value_detail: function (HSCODE, FieldName) { result = "NaN"; this.storeLocalCtnDetailList.each(function (record) { if (record.get("HSCODE") == HSCODE) { result = record.get(FieldName) + ""; } }); return result; }, gridCellrenderer_detail: function (value, meta, record, a, b, parentstore, c) { headname = _this.girdcolums2[b].dataIndex; if (!_this.needFind_detail(headname)) { return value; } else { isdifferent = _this.FindDiffenet_record_detail(record.get("HSCODE"), headname, value); if (isdifferent) { meta.tdCls = 'feestatus_nopass'; } return value; } }, //#region 打印 Print: function () { var billNo = this.editRecord.data.BSNO.toString(); var selectedRecords = this.gridListMain.getSelectionModel().getSelection(); var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('CTN_ID') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; if (feeGidSql == '') feeGidSql = 'aaaaa' var printType = 'MSOPSEAECTNDETAIL'; var sql1 = "SET LANGUAGE 'us_english' SELECT d.CTN_ID,d.PKGS,d.KINDPKGS,d.KGS,d.CBM,d.HSCODE,d.DESCRIPTION,d.MARKS,c.CNTRNO,c.SEALNO,b.MBLNO,c.BSNO FROM op_ctn_detail d left join op_ctn c on (c.CTN_ID=d.CTN_ID) left join op_seae b on (b.BSNO=c.BSNO) WHERE c.BSNO = '" + billNo + "' order by d.CTN_ID,d.ID "; var sql2 = "SET LANGUAGE 'us_english' SELECT d.CTN_ID,d.PKGS,d.KINDPKGS,d.KGS,d.CBM,d.HSCODE,d.DESCRIPTION,d.MARKS,c.CNTRNO,c.SEALNO,b.MBLNO,c.BSNO FROM op_ctn_detail d left join op_ctn c on (c.CTN_ID=d.CTN_ID) left join op_seae b on (b.BSNO=c.BSNO) WHERE c.BSNO = '" + billNo + "' AND c.CTN_ID IN (" + feeGidSql + ") order by d.CTN_ID,d.ID "; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, ''); }, //#endregion //#region 判断一行字符数是否超标 SetShipperLable: function (fieldname, len) { var basicForm = this.formEdit.getForm(); var field = basicForm.findField(fieldname); var SHIPPERSTR = Ext.getCmp(fieldname + 'STR'); var str = Billstrnum(field.getValue(), len); SHIPPERSTR.setText(str, false); } //#endregion });