Ext.namespace('Shipping'); Shipping.MsOpLetterChangeEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpLetterChangeEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpLetterChangeEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, Editdata: null, MainEditRecord: null, initUIComponents: function () { this.serialNo = 0; //this.bodyDel = []; this.itemindex = 1; //权限范围 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreOpRange.load({ params: { optype: "modOrderManagement"} }); this.storeFM = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserLinkRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' } }); //#region 编辑formHead 基本信息 this.formHead = Ext.widget('form', { region: 'north', frame: true, bodyPadding: 5, collapsed: false, collapsible: true, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 70, msgTarget: 'qtip' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BSNO', hidden: true }, { fieldLabel: 'LE_ID', hidden: true, name: 'LE_ID' }, { fieldLabel: 'INPUTTIME', hidden: true, name: 'INPUTTIME' }, { fieldLabel: 'LETTERNAME', hidden: true, name: 'LETTERNAME', value: '电放保函' }, { fieldLabel: 'TO', name: 'HEAD_TO' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'ATTN', name: 'HEAD_ATTN' }, { fieldLabel: 'ATTN电话', name: 'HEAD_ATTNTEL' }, { fieldLabel: 'ATTN传真', name: 'HEAD_ATTNFAX' }, { xtype: 'hiddenfield'}] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'FROM', name: 'INPUTBY' }, { fieldLabel: 'FROM电话', name: 'HEAD_FMTEL' }, { fieldLabel: 'FROM传真', name: 'HEAD_FMFAX' }, { fieldLabel: 'EMAIL', name: 'HEAD_FMEMAIL' }] } ]//end items(fieldset 1) }); //end this.formEdit //#endregion //#region 编辑formEdit 更改通知 this.formEdit = Ext.widget('form', { region: 'north', height: 460, frame: true, bodyPadding: 5, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 70, msgTarget: 'qtip' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'LE_ID', hidden: true, name: 'LE_ID' } , { fieldLabel: '船名航次', name: 'VESSELVOYNO' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '提单号', name: 'MBLNO' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '卸货港', name: 'PORTDISCHARGE' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '开船日期', name: 'ETD' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '件重尺', name: 'PKC' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '箱型箱量', name: 'CNTR' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, fieldLabel: '更改项目', height: 120, name: 'ProName', anchor: '100%' }, { xtype: 'textareafield', grow: true, fieldLabel: '原内容', height: 120, name: 'ProOld', anchor: '100%' }, { xtype: 'textareafield', grow: true, fieldLabel: '现内容', height: 120, name: 'ProNew', anchor: '100%' }] }, { xtype: 'textareafield', grow: true, fieldLabel: '备注', height: 60, name: 'REMARK', anchor: '100%' } ]//end items(fieldset 1) }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ id: 'btnESave', text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: "关闭", handler: function (button, event) { window.close(); }, scope: this }, { text: "新建", handler: function (button, event) { this.LoadData('add', ''); }, scope: this }, '-', { text: "打印", iconCls: "btnprint", handler: function (button, event) { this.Print(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 框架结构 this.panelpage = new Ext.Panel({ title: '更改通知详细信息', layout: "border", region: 'center', animate: true, autoScroll: true, // containerScroll: true, frame: false, items: [this.formEdit] }); Ext.apply(this, { items: [this.panelBtn, this.formHead, this.panelpage] }); //#endregion //#region 其他 parentWin = window.parent.opener; this.InitData(); //#endregion }, //end initUIComponents //#region 加载事件 InitData: function () { this.opStatus = 'add'; var condition = ''; _this = this; if (parentWin) { var ret = parentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; this.MainEditRecord = ret[3]; } if (this.opStatus == 'edit') { condition = "LE_ID='" + this.editRecord.get('LE_ID') + "'"; } this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; //this.bodyDel = []; this.opStatus = opstatus; if (this.opStatus == 'add') { this.formHead.getForm().reset(); this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.get('BSNO')); this.formHead.getForm().findField('INPUTBY').setValue(SHOWNAME); this.storeFM.load({ params: { condition: '' }, callback: function (r, options, success) { if (success) { if (this.storeFM.getCount() > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeFM, 'UserName', SHOWNAME); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formHead.getForm().findField('HEAD_FMTEL').setValue(Cargoinfodata.Tel); this.formHead.getForm().findField('HEAD_FMFAX').setValue(Cargoinfodata.Fax); this.formHead.getForm().findField('HEAD_FMEMAIL').setValue(Cargoinfodata.Email); } else { } } } }, scope: this }); this.formEdit.getForm().reset(); this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.get('VESSEL') + ' ' + this.MainEditRecord.get('VOYNO')); this.formEdit.getForm().findField('MBLNO').setValue(this.MainEditRecord.get('MBLNO') ); this.formEdit.getForm().findField('PORTDISCHARGE').setValue(this.MainEditRecord.get('PORTDISCHARGE')); this.formEdit.getForm().findField('PKC').setValue(this.MainEditRecord.get('PKGS') + this.MainEditRecord.get('KINDPKGS') + ' |' + this.MainEditRecord.get('KGS') + 'KGS |' + this.MainEditRecord.get('CBM') + 'CBM'); this.formEdit.getForm().findField('CNTR').setValue(this.MainEditRecord.get('CNTRTOTAL')); this.formEdit.getForm().findField('ETD').setValue(this.MainEditRecord.get('ETD')); } else { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpLetter/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; } data = result.data; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); // this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpLetter/GetChangeData', 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; } data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); this.LoadInit(); // this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } }, // end LoadDate //#endregion //#region 保存 Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = this.formHead.getForm().getValues(false, false, false); var body = this.formEdit.getForm().getValues(false, false, false); // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpLetter/SaveChange', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: Ext.JSON.encode(body) }, 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.formHead.getForm().reset(); this.formHead.getForm().setValues(returnData); // if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; var editp = Ext.create('MsOpLetter', returnData); this.formEdit.getForm().findField('LE_ID').setValue(editp.get('LE_ID')); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsOpLetter', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else if (type == '2') { this.LoadData('add', ''); } } 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 //#region LoadInit: function () { var CUSTOMERNAME = this.MainEditRecord.get('CUSTOMERNAME'); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + CUSTOMERNAME + "')"; this.storeInfoClientContact.load({ params: { condition: s} }); var YARD = this.formEdit.getForm().findField('YARD').getValue(); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD + "')"; this.storeInfoClientContactYard.load({ params: { condition: s} }); var YARD2 = this.formEdit.getForm().findField('YARD2').getValue(); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD2 + "')"; this.storeInfoClientContactYard2.load({ params: { condition: s} }); }, //#endregion //#region 编辑时按钮等的状态 GetEditStatus: function () { var canedit = false; //var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue(); var BSSTATUS = this.formHead.getForm().findField('BSSTATUSREF').getValue(); var inputby = this.formHead.getForm().findField('INPUTBY').getValue(); var op = this.formHead.getForm().findField('OP').getValue(); _this = this; if (BSSTATUS == '锁定') { canedit = false; this.setSaveBtnStatus(canedit); } else { this.StoreOpRange.load({ params: { optype: "modOrderManagement" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op); if (records.getCount() > 0) { canedit = true; } else { var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', inputby); if (recordins.getCount() > 0) { canedit = true; } else { canedit = false; } } } else { canedit = false; } _this.setSaveBtnStatus(canedit); } } }); } }, setSaveBtnStatus: function (enable) { var btnESave = Ext.getCmp('btnESave'); var btnESaveAndClose = Ext.getCmp('btnESaveAndClose'); var btnESaveAndNew = Ext.getCmp('btnESaveAndNew'); var btnEAddDetail = Ext.getCmp('btnadddetail'); var btnEDeleteDetail = Ext.getCmp('btndeldetail'); if (enable) { btnESave.enable(); btnESaveAndClose.enable(); btnESaveAndNew.enable(); btnEAddDetail.enable(); btnEDeleteDetail.enable(); } else { btnESave.disable(); btnESaveAndClose.disable(); btnESaveAndNew.disable(); btnEAddDetail.disable(); btnEDeleteDetail.disable(); } }, //#endregion //#region 打印 Print: function () { var basicForm = this.formHead.getForm(); var billNo = basicForm.findField('LE_ID').value; var bsNo = basicForm.findField('BSNO').value; if (billNo == '*' || billNo == '' || billNo == NaN) { Ext.Msg.show({ title: '错误', msg: '更改通知还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var op = this.MainEditRecord.get('OP'); var MBLNO = this.MainEditRecord.get('MBLNO') + '更改通知'; var printType = 'MSOPLETTERCHANGE'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_change WHERE LE_ID = '" + billNo + "'"; var sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_seae WHERE BSNO = '" + bsNo + "'"; var sql4 = "SELECT [user].USERNAME,[user].CODENAME,[user].PASSWORD,[user].SHOWNAME,[user].ENROLLTIME,[user].CREATEUSER,[user].MODIFIEDUSER, [user].MODIFIEDTIME, [user].ISDELETED, [user].ISDISABLE, user_baseinfo.GID,user_baseinfo.USERID,user_baseinfo.COMPANYNAME, user_baseinfo.DEPTNAME, user_baseinfo.OFFICEPHONE, user_baseinfo.HOMEPHONE, user_baseinfo.MOBILE, user_baseinfo.FAX, user_baseinfo.EMAIL1, user_baseinfo.EMAIL2, user_baseinfo.HOMEADDRESS, user_baseinfo.REMARK, user_baseinfo.EMERGUSER, user_baseinfo.EMERGPHONE,user_baseinfo.EMERGEMAIL, user_baseinfo.POSTCODE, user_baseinfo.QQ, user_baseinfo.MSN, user_baseinfo.FINANCESOFTCODE FROM [user] INNER JOIN user_baseinfo ON [user].GID = user_baseinfo.USERID where [user].SHOWNAME='" + op + "' "; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, MBLNO, '', '', '', bsNo); } // #endregion });