/// Ext.namespace('Shipping'); //#region 获取 YYYY-mm-dd 格式的日期 //var xhr = new XMLHttpRequest(); var currdate = new Date(); //xhr.open("HEAD", location.href, true); //xhr.onreadystatechange = function () { // if (xhr.readyState == 4 && xhr.status == 200) { // var datestr = xhr.getResponseHeader("Date"); // currdate = new Date(datestr); // } //} //xhr.send(null); //#endregion Shipping.MsOpCtnrInEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpCtnrInEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpCtnrInEdit, Ext.Panel, { parentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, parentRecord: null, PageSize:500, initUIComponents: function () { this.formname = 'MsCtnrInEdit'; this.CtnrInBodyDel = []; //#region 数据集定义 //空重 this.storeCTNEF = Ext.create('Ext.data.Store', { fields: ['FType', 'NAME'] }); this.storeCTNEF.add({ "FType": 'E', "NAME": "空" }); this.storeCTNEF.add({ "FType": 'F', "NAME": "重" }); this.comboxCTNEF = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCTNEF, valueField: 'FType', displayField: 'NAME', forceSelection: true, name: 'CTNEF' }); //箱型_集装箱列表中的下拉框加载 Ext.regModel('CTNALLMODEL', { fields: [{ name: 'CTN' }] }); this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', { model: 'CTNALLMODEL', proxy: { url: '/MvcShipping/MsOpCtnr/GetCodeCtnList' } }); this.storeCodeCtn.load(); this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCodeCtn, name: 'CTNALL', valueField: 'CTN', displayField: 'CTN' }); //租买箱公司 this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListController' } }); this.storeCustCode.load(); this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '租买公司', store: this.storeCustCode, forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', id: 'CUSTOMERNAME', name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', allowBlank: false }); //租买类型 Ext.define('BLTypemb', { extend: 'Ext.data.Model', fields: [ { name: 'BLType', type: 'string' } ] }); var BLTypeData = [ { "BLType": "买箱" }, { "BLType": "租入" }]; this.storeBLType = Ext.create('Ext.data.Store', { model: 'BLTypemb', data: BLTypeData }); this.comboxBuyType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '租买类型', forceSelection: true, store: this.storeBLType, name: 'BLTYPE', allowBlank: false, valueField: 'BLType', displayField: 'BLType' }); //箱源 Ext.define('CNTRSOURCEmb', { extend: 'Ext.data.Model', fields: [ { name: 'CNTRSOURCE', type: 'string' } ] }); var CNTRSOURCEData = [ { "CNTRSOURCE": "自备箱" }, { "CNTRSOURCE": "长租箱" }, { "CNTRSOURCE": "短租箱" }, { "CNTRSOURCE": "租买箱" }, { "CNTRSOURCE": "ONEWAY" }]; this.storeCNTRSOURCE = Ext.create('Ext.data.Store', { model: 'CNTRSOURCEmb', data: CNTRSOURCEData }); this.comboxCNTRSOURCE = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '箱源', forceSelection: true, store: this.storeCNTRSOURCE, name: 'CNTRSOURCE', allowBlank: false, valueField: 'CNTRSOURCE', displayField: 'CNTRSOURCE' }); this.comboxCNTRSOURCEDetail = Ext.create('DsExt.ux.RefEnumCombox', { forceSelection: true, store: this.storeCNTRSOURCE, name: 'CNTRSOURCE', allowBlank: false, valueField: 'CNTRSOURCE', displayField: 'CNTRSOURCE' }); this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeLoadportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' } }); this.storeCodeLoadport.load(); this.comboxPORT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '买箱地点', store: this.storeCodeLoadport, //forceSelection: true, id: 'PORT', name: 'PORT', valueField: 'PORT', displayField: 'CodeAndName', matchFieldWidth: false //下拉款自适应宽度 // }); this.comboxPORTDetail = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCodeLoadport, //forceSelection: true, id: 'PORTDetail', name: 'PORTDetail', valueField: 'PORT', displayField: 'CodeAndName', matchFieldWidth: false //下拉款自适应宽度 // }); //场站 this.storeYARD = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' } }); this.storeYARD.load(); // this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '放箱场站', store: this.storeYARD, forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'YARD', valueField: 'CustName', displayField: 'CodeAndName' }); this.comboxYARDDetail = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeYARD, forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'YARDDetail', valueField: 'CustName', displayField: 'CodeAndName' }); //人员信息加载 this.storeSaleCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeSaleCode.load(); //揽货人 this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '揽货人', store: this.storeSaleCode, forceSelection: true, name: 'SALE', valueField: 'UserName', displayField: 'CodeAndName', value: SHOWNAME, listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { if (this.SALEORDERDEPTBYOP == 0) this.formHead.getForm().findField('SALEDEPT').setValue(records[0].data.DEPTNAME); } } } }); //人员信息加载 this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeOpCode.load(); //操 作 this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '操作', store: this.storeOpCode, forceSelection: true, name: 'OP', valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true }); //箱动态类型 this.storeCTNSTATUS = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeCTNSTATUS.load({ params: { enumTypeId: 99060 } }); this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefEnumCombox', { store: this.storeCTNSTATUS, name: 'CTNSTATUS', valueField: 'EnumValueName', displayField: 'EnumValueName' }); //应收费用名称 this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefListNew' } }); this.storeFeeNameRef.load(); this.comboxFeeNameRef = Ext.create('DsExt.ux.DCombox', { store: this.storeFeeNameRef, minChars: 1, matchFieldWidth: false, //queryParam: 'Name', lazyRender: false, name: 'DRFEENAME', valueField: 'Name', displayField: 'CodeAndName' }); this.storeFeeNameRefCr = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefListNew' } }); this.storeFeeNameRefCr.load(); //对模糊查询和tab/enter选择的修改封装在 DsExt.ux.DCombox内 其他combox也可以调用 this.comboxFeeNameRefCr = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRefCr, forceSelection: true, queryMode: 'local', minChars: 1, //queryParam: 'Name', lazyRender: false, name: 'CRFEENAME', matchFieldWidth: false, valueField: 'Name', displayField: 'CodeAndName', listeners: { beforequery: function (e) { return FilterCombox(e); }, specialkey: function (field, e) { //将回车13转义成tab9 if (e.getKey() == e.ENTER) { e.keyCode = 9; } if (e.keyCode == 9) { //将combo //alert(field.value); if (field.value == null) { _name = this.store.data.keys[0]; this.setValue(_name); } else { if (field.value.replace(/\s*/g, "") == "") { _name = this.store.data.keys[0]; this.setValue(_name); } } } } } }); //#endregion //#region form定义 //编辑form:formEdit this.formEdit = Ext.widget('form', { // layout: "border", region: 'north', height: 170, frame: true, bodyPadding: 1, trackResetOnLoad: true, fieldDefaults: { margins: '1 1 1 1', labelAlign: 'right', flex: 1, labelWidth: 64, msgTarget: 'qtip' //,split:true }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{//container_1 xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'BSNO', hidden: true, name: 'BSNO' }, { fieldLabel: '买箱单号', flex: 1, name: 'BILLNO', id: 'BILLNO', readOnly:true, disabled:true },this.comboxCustCode, { name: 'BSDATE', id: "BSDATE", fieldLabel: '买箱时间', format: 'Y-m-d', value: Ext.util.Format.date(currdate, 'Y-m-d'), xtype: 'datefield' },{ fieldLabel: '会计期间', flex: 1, name: 'ACCDATE', xtype: 'monthfield', format: 'Y-m', value: Ext.util.Format.date(currdate, 'Y-m'), editable: false, allowBlank: false }, this.comboxCNTRSOURCE, { fieldLabel: '箱型箱量', //flex: 0.6, readOnly: true, name: 'CNTRTOTAL' } ] }//container_1 end , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ this.comboxBuyType, this.comboxPORT, this.comboxYARD, this.comboxOP, this.comboxSALE, { fieldLabel: '生成费用', readOnly: true, // flex: 0.4, name: 'ISCREATEFEEREF' } ] } ] } ] }); //#endregion //#region 编辑 //数据集 this.storeCtnrIn = Ext.create('Ext.data.Store', { model: 'MsOpCtnrDetail', pageSize: this.PageSize, remoteSort: false, pruneModifiedRecords: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpCtnr/GetCtnrDetailList', reader: { id: 'CTNGID', root: 'data', totalProperty: 'totalCount' } } }); var _this = this; this.columns = [ { sortable: true, //1 dataIndex: 'CTNGID', header: '惟一编号', width: 80, hidden: true }, { sortable: true, //1 dataIndex: 'CNTRNO', header: '箱号', width: 120, hidden: false, editor: { xtype: 'textfield' } }, { sortable: true, dataIndex: 'CTNEF', header: '空重', width: 80, editor: this.comboxCTNEF, renderer: function (value, p, record) { return record.data.CTNEFREF; } },{ sortable: true, dataIndex: 'CTNALL', header: '箱型', width: 80, editor: this.comboxCTNALL },{ sortable: true, dataIndex: 'CNTRSOURCE', header: '箱源', width: 80, editor: this.comboxCNTRSOURCEDetail },{ sortable: true, dataIndex: 'CTNSTATUS', header: '当前箱动态', width: 80, editor: this.comboxCTNSTATUS }, { sortable: true, dataIndex: 'CTNSTATUSTIME', header: '箱动态时间', width: 80, editor: { xtype: 'datefield', format: 'Y-m-d', selectOnFocus: true }, renderer: Ext.util.Format.dateRenderer('Y-m-d') }, { sortable: true, dataIndex: 'PORT', header: '当前地点', width: 80, editor: this.comboxPORTDetail }, { sortable: true, dataIndex: 'YARD', header: '当前场站', width: 80, editor: this.comboxYARDDetail }, { sortable: true, dataIndex: 'CRFEENAME', header: '应付费用名称', width: 80, editor: this.comboxFeeNameRefCr }, { sortable: true, dataIndex: 'CR', header: '应付费用', width: 80, editor: { xtype: 'textfield' }, summaryType: 'sum', align: 'right' }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 80, editor: { xtype: 'textfield' } } ]; this.girdcolums = this.columns; this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 if (true) { } this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.formCtnrInBody = new Ext.grid.GridPanel({ store: this.storeCtnrIn, enableHdMenu: false, region: 'center', columnLines: true, //layout: "border", //title: '费用明细', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditing], selModel: this.CheckBoxModel, selType: 'cellmodel', features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], tbar: [{ xtype: 'label', text: '集装箱信息', style: 'font-size:18px', labelColor: '#099', //style:'background-color: #4b9bf5', x: '5%', y: '5%' }, { text: '增加', id: "add1", tooltip: '增加', iconCls: "btnadddetail", handler: function (button, event) { this.onAddCtnrInClick(button, event); }, scope: this }, { text: '删除', id: "del1", tooltip: '删除', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelCtnrInClick(button, event); }, scope: this }, '-', { // id: "saveandclose", text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { // id: "saveandclose", text: "EXCEL导入", iconCls: "btnexportexcel", handler: function (button, event) { this.onImportCtnClick(); }, scope: this }, '-', { text: "保存列表样式", menu: [{ text: "保存", handler: function (button, event) { _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.formCtnrInBody.columns, _this.girdcolums, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列 } }, { text: "初始化", handler: function (menu, event) { _this.formCtnrInBody.reconfigure(_this.storeCtnrIn, _this.columns); _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.formCtnrInBody.columns, _this.columns, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列 } }], scope: this }], columns: this.girdcolums }); this.formCtnrInBody.columns[0] = new Ext.grid.RowNumberer(); this.formCtnrInBody.on('edit', function (editor, e, eOpts) { this.gridAfterEdit(editor, e, eOpts); }, this); //////////////////////////////////////////////明细<<<< CtnrIn列表 >>>>结束 //#endregion parentWin = window.parent.opener; if (parentWin) { var ret = parentWin.OprationSwap(); this.OpStatus = ret[0]; //edit this.StoreList = ret[1]; this.EditRecord = ret[2]; //SelectedRecord } //#region 其他 this.panelFee = new Shipping.FeeEditGrid({ region: 'center', layout: 'border' }); this.panelFee.stroplb = 'op_other'; this.panelFee.StoreCustType.add({ "SCUSTTYPE": "WTDW-委托单位", "CUSTTYPE": "委托单位", "CUSTNAME": "CUSTOMERNAME" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CGS-船公司", "CUSTTYPE": "船公司", "CUSTNAME": "CARRIER" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DCDL-订舱代理", "CUSTTYPE": "订舱代理", "CUSTNAME": "FORWARDER" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "BGH-报关行", "CUSTTYPE": "报关行", "CUSTNAME": "CUSTOMSER" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CD-车队", "CUSTTYPE": "车队", "CUSTNAME": "TRUCKER" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "FHR-发货人", "CUSTTYPE": "发货人", "CUSTNAME": "SHIPPERID" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "SHR-收货人", "CUSTTYPE": "收货人", "CUSTNAME": "CONSIGNEEID" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "TZR-通知人", "CUSTTYPE": "通知人", "CUSTNAME": "NOTIFYPARTYID" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DL-代理", "CUSTTYPE": "代理", "CUSTNAME": "AGENTID" }); this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CZ-场站", "CUSTTYPE": "场站", "CUSTNAME": "YARD" }); this.panelFee.StoreDrOpRange.load({ params: { optype: "modOtherRecvFeeManagement" } }); this.panelFee.StoreCrOpRange.load({ params: { optype: "modOtherPayFeeManagement" } }); this.panelFee.storeFeeNameRef.load({ params: { condition: "" } }); this.panelChFee = new Ext.Panel({ region: 'center', layout: 'border', margin: '0 0', height: 300, //width: 450, items: [/*this.panelChFee_YS, this.panelChFee_YF*/ this.panelFee ] }); //#endregion //公共按钮Toolbar:panelBtn this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { // id: "saveandclose", text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { // id: "saveandclose", text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { // id: "saveandclose", text: "生成费用", handler: function (button, event) { this.CreateCost("0"); }, scope: this }, '-', { // id: "saveandclose", text: "取消费用", handler: function (button, event) { this.CreateCost("1"); }, scope: this },'-', { // id: "saveandclose", text: "关闭", handler: function (button, event) { window.close(); }, scope: this } ] }); //end 按钮Toolbar this.panelTop; //#region//布局 this.panelTop = new Ext.Panel({ region: "north", height: 100, items: [this.panelBtn, this.formEdit] }); this.panelCtnrInBody = new Ext.Panel({ layout: "border", region: 'center', frame: true, split: true, items: [this.formCtnrInBody] }); this.page_1 = new Ext.Panel({ id: "page_1", title: "集装箱信息", layout: "border", region: 'center', items: [this.panelCtnrInBody] }); this.page_2 = new Ext.Panel({ id: "page_2", autoScroll: true, title: "租买箱相关应收应付费用", layout: "border", region: 'center', items: [this.panelChFee ] }); this.MainTab = new Ext.tab.Panel({ layout: "border", region: "center", split: true, items: [this.page_1, this.page_2] }); Ext.apply(this, { items: [this.panelTop, this.MainTab] }); this.InitData(); //#endregion //集中绑定事件 this.formCtnrInBody.on('edit', function (editor, e, eOpts) { this.CtnrInAfterEdit(editor, e, eOpts); }, this); this.cellEditing.on('beforeedit', function (editor, e) { return this.CtnrInBeforeEdit(editor, e); }, this); this.storeCtnrIn.on('beforeload', function (store) { var BSNO = this.EditRecord.get('BSNO'); //Ext.apply(store.proxy.extraParams, { condition: " ASSOCIATEDNO='" + GID + "'" }); }, this); }, //end initUIComponents parentfunction: function (button, event) { var ret1 = window.parent.opener.OprationSwap(); ret1[3](); }, onAddCtnrInClick: function (button, event, type) { var store = null; var data = this.formEdit.getForm().getValues(); store = this.storeCtnrIn; var record = null; var BSNO = ''; var PORT = ''; var YARD = ''; var CRFEENAME = ''; if (this.OpStatus == "add") { PORT = data.PORT; YARD = data.YARD; CNTRSOURCE = data.CNTRSOURCE; } else { BSNO = this.EditRecord.get('BSNO'); PORT = this.EditRecord.get('PORT'); YARD = this.EditRecord.get('YARD'); CNTRSOURCE = this.EditRecord.get('CNTRSOURCE'); } if (this.storeCtnrIn.getCount() > 0) { var memberbody = this.storeCtnrIn.getAt(0); CRFEENAME = memberbody.data.CRFEENAME; } var newid = NewGuid(); record = Ext.create('MsOpCtnrDetail', { BSNO: '*', CTNGID: newid, CTNALL: '', CNTRNO: '', CNTRSOURCE: CNTRSOURCE, CTNSTATUS:data.BLTYPE, CTNSTATUSTIME: data.BSDATE, PORT: PORT, YARD: YARD, CTNEF: '', CTNEFREF: '空', CRFEENAME: CRFEENAME, CUSTNO: '', MBLNO: '', REMARK:'' }); this.storeCtnrIn.add(record); cellediting = this.cellEditing; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: 2 }); }, onDelCtnrInClick: function (button, event, type) { var bsno = this.formEdit.getForm().findField('BSNO').getValue(); var selectedRecords = []; selectedRecords = this.CheckBoxModel.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的集装箱信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要删除选中的集装箱信息吗?', function (btn) { if (btn == 'yes') { if (selectedRecords.length > 0) { var CtnrIndatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台 { this.storeCtnrIn.remove(selectedRecords[i]); } else { CtnrIndatas.push(rec); } } var CtnrInBody = ConvertRecordsToJsonAll(CtnrIndatas); if (CtnrIndatas.length> 0) { Ext.Msg.wait('正在删除...'); Ext.Ajax.request({ waitMsg: '正在删除...', //'正在删除数据...', url: '/MvcShipping/MsOpCtnr/DeleteDetail', params: { data: CtnrInBody, bsno: bsno }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeCtnrIn.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 }); }, scope: this }); //end Ext.Ajax.request } } } }, this); }, getLinenum: function (button, event) { var _L = 0; for (var i = 0; i < this.storeCtnrIn.getCount(); i++) { var _t = parseInt(this.storeCtnrIn.getAt(i).get("LINENUM")); if (_t > _L) { _L = _t; } } _L++; return _L; }, CtnrInAfterEdit: function (editor, e, eOpts) { if (COMPANYID == "" || DEPTGID == "") { alert("登录信息不全,请退出重新登录"); returen; } }, CtnrInBeforeEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (COMPANYID == "" || DEPTGID == "") { alert("登录信息不全,请退出重新登录"); returen; } }, InitData: function () { this.OpStatus = 'add'; var condition = ''; if (parentWin) { var ret = parentWin.OprationSwap(); this.OpStatus = ret[0]; //edit this.StoreList = ret[1]; this.EditRecord = ret[2]; //SelectedRecord } if (this.OpStatus == 'edit') { condition = " BSNO='" + this.EditRecord.get('BSNO') + "'"; this.LoadData(this.OpStatus, condition); } else { this.LoadData(this.OpStatus, condition); } //this.LoadMustBe(); }, //end InitData //载入数据 LoadData: function (OpStatus, condition) { if (COMPANYID == "" || DEPTGID == "") { alert("登录信息不全,请退出重新登录"); return; } this.OpStatus = OpStatus; var _this = this; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpCtnr/GetData', params: { handle: OpStatus, condition: condition }, 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; } var timeStamp = result.timeStamp; timeStamp = timeStamp.replace(/\//g, '-'); //格式化时分秒 var y = ''; var m = ''; var d = ''; var timetemp = timeStamp.split('-'); y = timetemp[0]; if (timetemp[1].length < 2) { m = '0' + timetemp[1]; } else { m = timetemp[1]; } if (timetemp[2].length < 2) { d = '0' + timetemp[2]; } else { d = timetemp[2]; } var timeStampFin = y + '-' + m + '-' + d; TIMESTAMP = timeStampFin; timeStamp = timeStampFin; var data = result.data; if (this.OpStatus == 'add') { } this.Editdata = data; var basicForm = this.formEdit.getForm(); basicForm.setValues(data); this.panelFee.EditRecord = this.EditRecord; this.panelFee.strBSNO = data.BSNO; this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "op_other", condition: "(BSNO = '" + data.BSNO + "' and feetype=1) " } }); this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "op_other", condition: "(BSNO = '" + data.BSNO + "'and feetype=2)" } }); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //request over if (this.OpStatus == 'edit') { var BSNO = this.EditRecord.get('BSNO'); this.storeCtnrIn.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: " mng.BSNO='" + BSNO + "'" }, waitMsg: "正在查询数据...", scope: this }); } }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); var bsno = basicForm.findField('BSNO').value; if (!basicForm.isValid()) { return; } Ext.getCmp('BILLNO').setDisabled(false); var data = this.formEdit.getForm().getValues(); if (COMPANYID == "" || DEPTGID == "") { Ext.MessageBox.alert("提示", "登录信息不全,请退出重新登录"); return; } var CtnrIndatas = []; for (var i = 0; i < this.storeCtnrIn.getCount(); i += 1) { var member = this.storeCtnrIn.getAt(i); member.data.CTNSTATUSTIME = Ext.util.Format.date(member.data.CTNSTATUSTIME, 'Y-m-d').toString(); CtnrIndatas.push(member); } var CtnrInBody = ConvertRecordsToJsonAll(CtnrIndatas); var CtnrInBodyDel = ConvertRecordsToJsonAll(this.CtnrInBodyDel); var _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpCtnr/Save', scope: this, async: false, params: { OpStatus: this.OpStatus, data: Ext.JSON.encode(data), CtnrInBody: CtnrInBody, CtnrInBodyDel: CtnrInBodyDel }, callback: function (options, success, response) { Ext.getCmp('BILLNO').setDisabled(true); if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.OpStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.EditRecord = arrNewRecords[0]; } else if (this.OpStatus == 'edit') { var editp = Ext.create('MsOpCtnrList', returnData); this.EditRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'BSNO') this.EditRecord.set(name, editp.get(name)); } }, this); this.EditRecord.commit(); } this.panelFee.EditRecord = this.EditRecord; this.panelFee.strBSNO = returnData.BSNO; this.storeCtnrIn.commitChanges(); if (type == '0') { this.OpStatus = 'edit'; var BSNO = _this.EditRecord.get('BSNO'); this.storeCtnrIn.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: " mng.BSNO='" + BSNO + "'" }, waitMsg: "正在查询数据...", scope: this }); } else if (type == '1') {//保存并关闭 window.close(); } } 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 }); } //alert('03'); } }); }, //end save CreateCost: function (flag) { var basicForm = this.formEdit.getForm(); var bsno = basicForm.findField('BSNO').value; if (!basicForm.isValid()) { return; } var data = this.formEdit.getForm().getValues(); if (COMPANYID == "" || DEPTGID == "") { Ext.MessageBox.alert("提示", "登录信息不全,请退出重新登录"); return; } var CtnrIndatas = []; for (var i = 0; i < this.storeCtnrIn.getCount(); i += 1) { var member = this.storeCtnrIn.getAt(i); CtnrIndatas.push(member); } var CtnrInBody = ConvertRecordsToJsonAll(CtnrIndatas); var _this = this; Ext.Msg.wait('正在生成费用, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在生成费用...', url: '/MvcShipping/MsOpCtnr/CreateCost', scope: this, async: false, params: { data: Ext.JSON.encode(data), CtnrInBody: CtnrInBody, flag:flag }, callback: function (options, success, response) {{ if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success == true) { Ext.MessageBox.alert('提示', result.Message); this.panelFee.storeDrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 1, optype: "OpCtnMng", condition: "(BSNO = '" + bsno + "' and feetype=1) " } }); this.panelFee.storeCrChFee.load({ params: { billno: this.panelFee.strBSNO, type: 2, optype: "OpCtnMng", condition: "(BSNO = '" + bsno + "'and feetype=2)" } }); this.LoadData(this.OpStatus, "BSNO='" + bsno + "'"); } else { Ext.MessageBox.alert('提示', result.Message); return; } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } } } }); }, //end save LoadMustBe: function () { this.storeMustBe.load({ params: { condition: "BSTYPE='集装箱信息'" }, callback: function (r, options, success) { if (success) { if (this.storeMustBe.getCount() > 0) { for (var j = 0; j < this.storeMustBe.getCount() ; j += 1) { var member = this.storeMustBe.getAt(j); var fieldname = member.data.FIELDNAME; var headfield = this.formEdit.getForm().findField(member.data.FIELDNAME); if (headfield != NaN && headfield != null) { if (member.data.ISMUST == "1") headfield.allowBlank = false; if (member.data.ISCOLOR == "1") headfield.setFieldStyle({ background: '#ffc' }); if (member.data.ISREADONLY == "1") headfield.setReadOnly(true); } }; } else { } } }, scope: this }); }, gridAfterEdit: function (editor, e, eOpts) { //需要自己实现里面的事件 if (e.field == 'CTNEF') { var isctn = e.value; if (isctn == 'F') e.record.set('CTNEFEF', "重"); else e.record.set('CTNEFREF', "空"); } else if (e.field == 'CRFEENAME') { var CRFEENAME = e.record.data['CRFEENAME']; for (var j = 0; j < this.storeCtnrIn.getCount(); j += 1) { var memberbody = this.storeCtnrIn.getAt(j); if (memberbody.data.CRFEENAME == "" || memberbody.data.CRFEENAME == NaN || memberbody.data.CRFEENAME == null) { memberbody.set("CRFEENAME", CRFEENAME); // memberbody.commit(); } }; } }, //#endregion onImportCtnClick: function () { var data = this.formEdit.getForm().getValues(); me = this; var BSNO = ''; var imgform = new Ext.FormPanel({ region: 'center', labelWidth: 20, frame: true, autoScroll: false, border: false, fileUpload: true, items: [{ xtype: 'fileuploadfield', id: 'LoadExcel', name: 'LoadExcel', emptyText: '请选择EXCEL文件', //'请选择EXCEL文件', fieldLabel: 'EXCEL', //'EXCEL', buttontext: '选择文件', //'选择文件', allowBlank: false, width: 200, buttonCfg: { iconCls: 'uploaddialog' }, anchor: '98%' }], buttons: [{ text: '上传', //'上传', type: 'submit', handler: function () { var UserFilePath = Ext.getCmp('LoadExcel').getValue(); if (!CheckFileExt(UserFilePath, /.xls|.xlsx/i)) { Ext.Msg.show({ title:'错误', msg: '请确认上传的文件类型是否为EXCEL文件', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });//'请确认你上传的文件为EXCEL文件!' return; } if (!imgform.form.isValid()) { return; } imgform.form.submit({ url: '/MvcShipping/MsOpCtnr/CtrnFromExcel', waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在上传', method: 'POST', params: { bsno: BSNO }, success: function (form, a) { var result = a.result, dataList = result.data; for (var i = 0; i < dataList.length; i++) { var record = dataList[i]; var newid = NewGuid(); record = Ext.create('MsOpCtnrDetail', { BSNO: '*', CTNGID: newid, CTNALL: record.CTNALL, CNTRNO: record.CNTRNO, CNTRSOURCE: record.CNTRSOURCE, CTNSTATUS: data.BLTYPE, CTNSTATUSTIME: data.BSDATE, PORT: record.PORT, YARD: record.YARD, CTNEF: '', CTNEFREF: '空', CRFEENAME: record.dCRFEENAME, CR: record.CR, CUSTNO: '', MBLNO: '', REMARK: '' }); me.storeCtnrIn.add(record); } me.Save('0'); var win = Ext.getCmp("importWin"); win.close(); }, failure: function (form, action) { form.reset(); Ext.Msg.show({ title: Zi.LAN.ChuoWu, msg: Zi.LAN.ShangChuanGuoChengChuXianCuoWu, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });//'上传过程出现错误!' } }); //imgform.form.submit({ // url: '/MvcShipping/MsOpCtnr/CtrnFromExcel', // waitMsg: '正在上传', //'正在上传', // method: 'POST', // params: { // bsno: BSNO // }, // success: function (f, a) { // var result = a.result, // dataList = result.data; // for (var i = 0; i < dataList.length; i++) { // var record = dataList[i]; // var newid = NewGuid(); // record = Ext.create('MsOpCtnrDetail', { // BSNO: '*', // CTNGID: newid, // CTNALL: record.data.CTNALL, // CNTRNO: record.data.CNTRNO, // CNTRSOURCE: record.data.CNTRSOURCE, // CTNSTATUS: data.BLTYPE, // CTNSTATUSTIME: data.BSDATE, // PORT: record.data.PORT, // YARD: record.data.YARD, // CTNEF: '', // CTNEFREF: '空', // CRFEENAME: record.data.CRFEENAME, // CR: record.data.CR, // CUSTNO: '', // MBLNO: '', // REMARK: '' // }); // this.storeCtnrIn.add(record); // } // var win = Ext.getCmp("importWin"); // win.close(); // Ext.Msg.alert('Success', result.Message); // }, // failure: function (form, action) { // form.reset(); // Ext.Msg.show({ title:'错误', msg:'上传的文件有误', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });//'上传过程出现错误!' // } //}); } }, { text: '关闭', //'关闭', type: 'submit', handler: function () { win.close(this); } }] }); var win = new Ext.Window({ title: "上传EXCEL", //"上传EXCEL", width: 380, height: 120, id:'importWin', modal: true, resizable: false, border: false, items: imgform }); win.show(); return; }, MakeCtnrIn: function (CNTRNO) { var store = null; var data = this.formEdit.getForm().getValues(); store = this.storeCtnrIn; var record = null; if (this.OpStatus == "add") { BSNO = ""; } else { BSNO = this.EditRecord.get('BSNO'); } var newid = NewGuid(); record = Ext.create('MsOpCtnrDetail', { BSNO: newid }); store.add(record); cellediting = this.cellEditing; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: 2 }); this.storeCtnrIn.each(function (record) { if (record.get('BSNO') == newid) { record.set('ACCDATE', Ext.util.Format.date(currdate, 'Y-m')); } }); } //#endregion });