Ext.namespace('Shipping'); Shipping.MsOpLetterYardEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpLetterYardEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpLetterYardEdit, 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.BsNo = getUrlParam('bsno'); this.StoreList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpLetter', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpLetter/GetListData', reader: { id: 'BsNo', root: 'data', totalProperty: 'totalCount' } } }); //权限范围 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' } }); //人员信息加载 this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserLinkRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' } }); this.storeOpCode.load(); //客服 this.comboxDOC = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '单证', store: this.storeOpCode, forceSelection: true, name: 'DOC', valueField: 'UserName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('DOCTEL').setValue(records[0].data.Tel); this.formEdit.getForm().findField('DOCFAX').setValue(records[0].data.Fax); this.formEdit.getForm().findField('DOCEMAIL').setValue(records[0].data.Email); } } } }); //委托单位_联系人 this.storeInfoClientContact = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.InfoClientContactModel', proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' } }); this.comboxInfoClientContact = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'ATTN', store: this.storeInfoClientContact, name: 'HEAD_ATTN', valueField: 'SHOWNAME', displayField: 'SHOWNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeInfoClientContact, 'GID', records[0].data.GID); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(Cargoinfodata.TEL); this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(Cargoinfodata.FAX); } else { // this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(''); // this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(''); } } } } }); //#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: [this.comboxInfoClientContact, { 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 //客户加载_场站 this.storeYARD = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomYardRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomYardRefList' } }); this.storeYARD.load({ params: { condition: "ISYARD='1'"} }); //船公司 this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '提箱场站', store: this.storeYARD, // forceSelection: true, name: 'YARD', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('Address').setValue(records[0].data.ADDR); var data = combo.value; var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')"; this.storeInfoClientContactYard.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContactYard.getCount() > 0) { var member = this.storeInfoClientContactYard.getAt(0); this.comboxInfoClientContactYard.setValue(member.data.SHOWNAME); this.formEdit.getForm().findField('Tel').setValue(member.data.TEL); } else { this.comboxInfoClientContactYard.setValue(''); this.formEdit.getForm().findField('Tel').setValue(''); } } }, scope: this }); } } } }); //委托单位_联系人 this.storeInfoClientContactYard = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.InfoClientContactModel', proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' } }); this.comboxInfoClientContactYard = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '联系人', store: this.storeInfoClientContactYard, name: 'CHIEF', valueField: 'SHOWNAME', displayField: 'SHOWNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('Tel').setValue(records[0].data.TEL); } } } }); //客户加载_场站 this.storeYARD2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomYardRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomYardRefList' } }); //船公司 this.comboxYARD2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '入货场站', store: this.storeYARD, // forceSelection: true, name: 'YARD2', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('Address2').setValue(records[0].data.ADDR); var data = combo.value; var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')"; this.storeInfoClientContactYard2.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContactYard2.getCount() > 0) { var member = this.storeInfoClientContactYard2.getAt(0); this.comboxInfoClientContactYard2.setValue(member.data.SHOWNAME); this.formEdit.getForm().findField('Tel2').setValue(member.data.TEL); } else { this.comboxInfoClientContactYard2.setValue(''); this.formEdit.getForm().findField('Tel2').setValue(''); } } }, scope: this }); } } } }); //委托单位_联系人 this.storeInfoClientContactYard2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.InfoClientContactModel', proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' } }); this.comboxInfoClientContactYard2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '联系人', store: this.storeInfoClientContactYard2, name: 'CHIEF2', valueField: 'SHOWNAME', displayField: 'SHOWNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('Tel2').setValue(records[0].data.TEL); } } } }); //#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: '提箱小票地址', labelWidth: 90, name: 'TXXPURL' }, { xtype: 'button', width: 90, text: '复制链接', //"执行查询", iconCls: "btnrefresh", handler: function (button, event) { var url = _this.formEdit.getForm().findField('TXXPURL').getValue(); copyToClipboard(url); }, scope: this }, { xtype: 'button', width: 90, text: '生成链接', //"执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onCreateTxxpClick(); }, scope: this }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '运踪地址', labelWidth: 90, name: 'TRACKSHARELINK' }, { xtype: 'button', width: 90, text: '复制链接', //"执行查询", iconCls: "btnrefresh", handler: function (button, event) { var url = _this.formEdit.getForm().findField('TRACKSHARELINK').getValue(); copyToClipboard(url); }, scope: this }] },{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'LE_ID', hidden: true, name: 'LE_ID' }, this.comboxDOC, { fieldLabel: '单证电话', name: 'DOCTEL' }, { fieldLabel: '单证传真', name: 'DOCFAX' }, { fieldLabel: '单证EMAIL', name: 'DOCEMAIL' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '主提单号', name: 'MBLNO' }, { fieldLabel: '卸货港', name: 'PORTDISCHARGE' }, { fieldLabel: '船名航次', flex: 2, name: 'VESSELVOYNO' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '开船日期', name: 'ETD' }, { fieldLabel: '目的地', name: 'DESTINATION' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '件重尺', name: 'PKC' }, { xtype: 'textareafield', flex: 3, grow: true, fieldLabel: '货物描述', height: 50, name: 'DESCRIPTION', anchor: '100%' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxYARD, this.comboxInfoClientContactYard, { fieldLabel: '电话', name: 'Tel' }, { fieldLabel: '集装箱', name: 'CNTR' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '地址', flex: 3, name: 'Address' }, { fieldLabel: '提箱时间', format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'TiXiangTime' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxYARD2, this.comboxInfoClientContactYard2, { fieldLabel: '电话', name: 'Tel2' }, { xtype: 'hiddenfield'}] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '地址', flex: 3, name: 'Address2' }, { fieldLabel: '入货时间', format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'RuHuoTime' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '截港日期', format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'CLOSINGDATE' //, //listeners: { // scope: this, // 'select': function (combo, mdate) { // var mydate = new Date(mdate); // var mydatestr = Ext.util.Format.date(mydate, 'Y-m-d 12:00:00'); // combo.setValue(mydatestr); // } //} }, { fieldLabel: '截单日期', format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'CLOSEDOCDATE' // , //listeners: { // scope: this, // 'select': function (combo, mdate) { // var mydate = new Date(mdate); // var mydatestr = Ext.util.Format.date(mydate, 'Y-m-d 12:00:00'); // combo.setValue(mydatestr); // } //} }, { fieldLabel: '截VGM日期', format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'CLOSEVGMDATE' // , //listeners: { // scope: this, // 'select': function (combo, mdate) { // var mydate = new Date(mdate); // var mydatestr = Ext.util.Format.date(mydate, 'Y-m-d 12:00:00'); // combo.setValue(mydatestr); // } //} }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '出口海关', name: 'ExportCustoms' }, { fieldLabel: '海关代码', name: 'CustomsCode' }, { fieldLabel: '报关代码', name: 'DeclarationCode' }] }, { xtype: 'textareafield', grow: true, fieldLabel: '备注', height: 210, 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 }, { id: 'btnESaveAndClose', text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, { id: 'btnESaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, '-', { text: "关闭", handler: function (button, event) { window.close(); }, scope: this }, { text: "新建", handler: function (button, event) { this.LoadData('add', ''); }, scope: this }, '-', { id: 'btnEHistryCopy', text: "历史引入", handler: function (button, event) { DsOpenEditWin('/MvcShipping/MsOpLetter/HistryYardIndex', "入货通知历史引入", "600", "940", "10", "10"); }, scope: this }, { text: "刷新委托信息", handler: function (button, event) { if (this.BsNo == undefined) { this.LoadinitData(); } else { this.LoadInitDataByBsNo(); } }, 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 其他 if (this.BsNo == undefined) { parentWin = window.parent.opener; } else { parentWin = window.parent.opener.panelEdit; } if (this.BsNo == undefined) { this.InitData(); } else { this.MainEditRecord = parentWin.Editdata; this.LoadDataByBsNo(); } //#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('HEAD_TO').setValue(this.MainEditRecord.get('CUSTOMERNAME')); this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.get('BSNO')); var custop = this.MainEditRecord.get('OPERATOR'); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + this.MainEditRecord.get('CUSTOMERNAME') + "')"; this.storeInfoClientContact.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContact.getCount() > 0) { var member = this.storeInfoClientContact.getAt(0); if (custop != '' && custop != null) this.comboxInfoClientContact.setValue(custop); else this.comboxInfoClientContact.setValue(member.data.SHOWNAME); this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(member.data.TEL); this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(member.data.FAX); } } }, scope: this }); 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 }); var doc = this.MainEditRecord.get('DOC'); if (doc != "") { this.storeOpCode.load({ params: { condition: '' }, callback: function (r, options, success) { if (success) { if (this.storeOpCode.getCount() > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeOpCode, 'UserName', doc); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formEdit.getForm().findField('DOCTEL').setValue(Cargoinfodata.Tel); this.formEdit.getForm().findField('DOCFAX').setValue(Cargoinfodata.Fax); this.formEdit.getForm().findField('DOCEMAIL').setValue(Cargoinfodata.Email); } else { } } } }, scope: this }); } this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(this.MainEditRecord.data); this.formEdit.getForm().findField('REMARK').setValue(''); this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.get('VESSEL') + ' ' + this.MainEditRecord.get('VOYNO')); 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')); var yard = this.MainEditRecord.get('YARD'); this.formEdit.getForm().findField('YARD2').setValue(yard); this.formEdit.getForm().findField('CHIEF').setValue(this.MainEditRecord.get('YARDATTN')); this.formEdit.getForm().findField('Tel').setValue(this.MainEditRecord.get('YARDTEL')); this.formEdit.getForm().findField('CHIEF2').setValue(this.MainEditRecord.get('YARDATTN')); this.formEdit.getForm().findField('Tel2').setValue(this.MainEditRecord.get('YARDTEL')); if (yard != '') { this.storeYARD2.load({ params: { condition: "ISYARD='1'" }, callback: function (r, options, success) { if (success) { if (this.storeYARD2.getCount() > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeYARD2, 'CustName', yard); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formEdit.getForm().findField('Address').setValue(Cargoinfodata.ADDR); this.formEdit.getForm().findField('Address2').setValue(Cargoinfodata.ADDR); } else { } } else { this.formEdit.getForm().findField('Address').setValue(''); this.formEdit.getForm().findField('Address2').setValue(''); } } }, scope: this }); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + yard + "')"; this.storeInfoClientContactYard2.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContactYard2.getCount() > 0) { // var member = this.storeInfoClientContactYard2.getAt(0); // if (this.formEdit.getForm().findField('CHIEF').getValue()!='') // this.formEdit.getForm().findField('CHIEF').setValue(member.data.SHOWNAME); // if (this.formEdit.getForm().findField('Tel').getValue() != '') // this.formEdit.getForm().findField('Tel').setValue(member.data.TEL); // if (this.formEdit.getForm().findField('CHIEF2').getValue() != '') // this.formEdit.getForm().findField('CHIEF2').setValue(member.data.SHOWNAME); // if (this.formEdit.getForm().findField('Tel2').getValue() != '') // this.formEdit.getForm().findField('Tel2').setValue(member.data.TEL); } else { // this.formEdit.getForm().findField('CHIEF').setValue(''); // this.formEdit.getForm().findField('Tel').setValue(''); // this.formEdit.getForm().findField('CHIEF2').setValue(''); // this.formEdit.getForm().findField('Tel2').setValue(''); } } }, scope: this }); this.storeInfoClientContactYard.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { } }, scope: this }); } } else { this.storeYARD2.load({ params: { condition: "ISYARD='1'"} }); 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/GetYardData', 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 LoadDataByBsNo: function (condition) { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpLetter/GetData', params: { condition: "BSNO='" + this.BsNo + "' and LETTERNAME='入货通知'" }, 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; if (data == null) { this.opStatus ="add"; this.loadaddData(); } else { this.opStatus = "edit"; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); this.storeYARD2.load({ params: { condition: "ISYARD='1'" } }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpLetter/GetYardData', params: { handle: this.opStatus, condition: "LE_ID='"+data.LE_ID+"'" }, 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.LoadInitByBsNo(); // this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } // this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); this.serialNo = 0; //this.bodyDel = []; }, // end LoadDate loadaddData: function () { this.formHead.getForm().reset(); this.formHead.getForm().findField('HEAD_TO').setValue(this.MainEditRecord.CUSTOMERNAME); this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.BSNO); var custop = this.MainEditRecord.OPERATOR; var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + this.MainEditRecord.CUSTOMERNAME+ "')"; this.storeInfoClientContact.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContact.getCount() > 0) { var member = this.storeInfoClientContact.getAt(0); if (custop != '' && custop != null) this.comboxInfoClientContact.setValue(custop); else this.comboxInfoClientContact.setValue(member.data.SHOWNAME); this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(member.data.TEL); this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(member.data.FAX); } } }, scope: this }); 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 }); var doc = this.MainEditRecord.DOC; if (doc != "") { this.storeOpCode.load({ params: { condition: '' }, callback: function (r, options, success) { if (success) { if (this.storeOpCode.getCount() > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeOpCode, 'UserName', doc); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formEdit.getForm().findField('DOCTEL').setValue(Cargoinfodata.Tel); this.formEdit.getForm().findField('DOCFAX').setValue(Cargoinfodata.Fax); this.formEdit.getForm().findField('DOCEMAIL').setValue(Cargoinfodata.Email); } else { } } } }, scope: this }); } this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(this.MainEditRecord); this.formEdit.getForm().findField('REMARK').setValue(''); this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.VESSEL+ ' ' + this.MainEditRecord.VOYNO); this.formEdit.getForm().findField('PKC').setValue(this.MainEditRecord.PKGS + this.MainEditRecord.KINDPKGS + ' |' + this.MainEditRecord.KGS + 'KGS |' + this.MainEditRecord.CBM + 'CBM'); this.formEdit.getForm().findField('CNTR').setValue(this.MainEditRecord.CNTRTOTAL); var yard = this.MainEditRecord.YARD; this.formEdit.getForm().findField('YARD2').setValue(yard); this.formEdit.getForm().findField('CHIEF').setValue(this.MainEditRecord.YARDATTN); this.formEdit.getForm().findField('Tel').setValue(this.MainEditRecord.YARDTEL); this.formEdit.getForm().findField('CHIEF2').setValue(this.MainEditRecord.YARDATTN); this.formEdit.getForm().findField('Tel2').setValue(this.MainEditRecord.YARDTEL); if (yard != '') { this.storeYARD2.load({ params: { condition: "ISYARD='1'" }, callback: function (r, options, success) { if (success) { if (this.storeYARD2.getCount() > 0) { var Cargoinforecords = DsStoreQueryBy(this.storeYARD2, 'CustName', yard); if (Cargoinforecords.getCount() > 0) { var Cargoinfodata = Cargoinforecords.getAt(0).data; this.formEdit.getForm().findField('Address').setValue(Cargoinfodata.ADDR); this.formEdit.getForm().findField('Address2').setValue(Cargoinfodata.ADDR); } else { } } else { this.formEdit.getForm().findField('Address').setValue(''); this.formEdit.getForm().findField('Address2').setValue(''); } } }, scope: this }); } }, //#endregion LoadinitData: function () { var remarkstr = this.formEdit.getForm().findField('REMARK').getValue(); this.formEdit.getForm().setValues(this.MainEditRecord.data); this.formEdit.getForm().findField('REMARK').setValue(remarkstr); this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.get('VESSEL') + ' ' + this.MainEditRecord.get('VOYNO')); 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')); }, LoadInitDataByBsNo: function () { var remarkstr = this.formEdit.getForm().findField('REMARK').getValue(); this.formEdit.getForm().setValues(this.MainEditRecord); this.formEdit.getForm().findField('REMARK').setValue(remarkstr); this.formEdit.getForm().findField('VESSELVOYNO').setValue(this.MainEditRecord.VESSEL+ ' ' + this.MainEditRecord.VOYNO); this.formEdit.getForm().findField('PKC').setValue(this.MainEditRecord.PKGS + this.MainEditRecord.KINDPKGS + ' |' + this.MainEditRecord.KGS + 'KGS |' + this.MainEditRecord.CBM + 'CBM'); this.formEdit.getForm().findField('CNTR').setValue(this.MainEditRecord.CNTRTOTAL); }, //#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/SaveYard', 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} }); }, LoadInitByBsNo: function () { var CUSTOMERNAME = this.MainEditRecord.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 onCreateTxxpClick: function () { var bsno = this.MainEditRecord.get('BSNO') Ext.Ajax.request({ waitMsg: '', url: '/MvcShipping/MsOpLetter/SendToTxxp', params: { bsno: bsno }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success != true) { Ext.Msg.show({ title: '错误', msg: result.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } else { var data = result.Data; this.formEdit.getForm().findField('TXXPURL').setValue(data); } } else { } }, scope: this }); }, //#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; } if (this.BsNo == undefined) { var op = this.MainEditRecord.get('OP'); var MBLNO = this.MainEditRecord.get('MBLNO') + '入货通知'; var mailproject = this.MainEditRecord.get('MAILPROJECT'); } else { var op = this.MainEditRecord.OP; var MBLNO = this.MainEditRecord.MBLNO + '入货通知'; var mailproject = this.MainEditRecord.MAILPROJECT; } if (mailproject != '' && mailproject != undefined && mailproject != null) { Ext.Msg.wait('正在整理数据...'); Ext.Ajax.request({ waitMsg: '正在生成...', //'正在生成...', url: '/MvcShipping/MsOpSeae/CreateSendMail', params: { bsno: bsNo, mailproject: mailproject, bltype:'入货通知' }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (result.Success) { var printType = 'MSOPLETTERYARD'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_yard 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, '', '', result.Data, bsNo); } else { var printType = 'MSOPLETTERYARD'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_yard 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); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } else { var printType = 'MSOPLETTERYARD'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_yard 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 });