Ext.namespace('Shipping'); Shipping.MsOpLetterTruckEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpLetterTruckEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpLetterTruckEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, Editdata: null, MainEditRecord: null, oplb: '', 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' } }); //客户加载_车队 this.storeTRUCKER = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeTRUCKER.load({ params: { condition: "ISTRUCK='1'"} }); //车队 this.comboxTRUCKER = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.TRUCKER, store: this.storeTRUCKER, name: 'HEAD_TO', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('TRUCK').setValue(combo.value); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "')"; this.storeInfoClientContact.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContact.getCount() > 0) { var member = this.storeInfoClientContact.getAt(0); 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); } else { this.comboxInfoClientContact.setValue(''); this.formHead.getForm().findField('HEAD_ATTNTEL').setValue(''); this.formHead.getForm().findField('HEAD_ATTNFAX').setValue(''); } } }, scope: this }); } } } }); //委托单位_联系人 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(''); } } } } }); this.StoreTRUCKSTATUS = Ext.create('Ext.data.Store', { fields: ['BLTYPE'] }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "待派车" }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "提交派车" }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "已发单" }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "已接单" }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "已派车" }); this.StoreTRUCKSTATUS.add({ "BLTYPE": "派车中" }); this.comboxTRUCKSTATUS = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.TRUCKSTATUS, store: this.StoreTRUCKSTATUS, forceSelection: true, name: 'TRUCKSTATUS', valueField: 'BLTYPE', displayField: 'BLTYPE', value: '待派车' }); //#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: Zi.LAN.TRUCKLETTER }, this.comboxTRUCKER] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxInfoClientContact, { fieldLabel: Zi.LAN.HEAD_ATTNTEL, name: 'HEAD_ATTNTEL' }, { fieldLabel: Zi.LAN.HEAD_ATTNFAX , name: 'HEAD_ATTNFAX' }, { xtype: 'hiddenfield'}] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'FROM', name: 'INPUTBY' }, { fieldLabel: Zi.LAN.HEAD_FMTEL, name: 'HEAD_FMTEL' }, { fieldLabel: Zi.LAN.HEAD_FMFAX, 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: Zi.LAN.YARD, store: this.storeYARD, // forceSelection: true, name: 'YARD', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { 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('YARDTEL').setValue(member.data.TEL); } else { this.comboxInfoClientContactYard.setValue(''); this.formEdit.getForm().findField('YARDTEL').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: Zi.LAN.YARDATTN, store: this.storeInfoClientContactYard, name: 'YARDATTN', valueField: 'SHOWNAME', displayField: 'SHOWNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('YARDTEL').setValue(records[0].data.TEL); } } } }); //客户加载_场站 this.storeYARD2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomYardRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomYardRefList' } }); this.storeYARD2.load({ params: { condition: "ISYARD='1'"} }); //船公司 this.comboxYARD2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.RETURNYARD, store: this.storeYARD, // forceSelection: true, name: 'RETURNYARD', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { 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('RETURNTEL').setValue(member.data.TEL); } else { this.comboxInfoClientContactYard2.setValue(''); this.formEdit.getForm().findField('RETURNTEL').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: Zi.LAN.YARDATTN, store: this.storeInfoClientContactYard, name: 'RETURNATTN', valueField: 'SHOWNAME', displayField: 'SHOWNAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('RETURNTEL').setValue(records[0].data.TEL); } } } }); var companyname = Zi.LAN.companyname; if (this.oplb == "海运进口" || this.oplb == "空运进口") { companyname = Zi.LAN.companyname2; } //客户加载_工厂 this.storeFactry = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeFactry', proxy: { url: '/MvcShipping/MsCodeFactry/GetDataList' } }); this.storeFactry.load(); //工厂 this.comboxFactry = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: companyname, store: this.storeFactry, name: 'FACTRYNAME', valueField: 'FACTRYNAME', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var FACTRYADDR = this.formEdit.getForm().findField('FACTRYADDR'); FACTRYADDR.setValue(records[0].data.FACTRYADDR); var FACTRYATTN = this.formEdit.getForm().findField('FACTRYATTN'); FACTRYATTN.setValue(records[0].data.FACTRYATTN); var FACTRYTEL = this.formEdit.getForm().findField('FACTRYTEL'); FACTRYTEL.setValue(records[0].data.FACTRYTEL); } } } }); //#region 编辑formEdit 派车通知 this.formEdit = Ext.widget('form', { region: 'north', height: 320, 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: 'TRUCK', hidden: true, name: 'TRUCK' }, { fieldLabel: 'OTHERFEE', hidden: true, name: 'OTHERFEE' }, { fieldLabel: 'CUSTOMERNAME', hidden: true, name: 'CUSTOMERNAME' } , { fieldLabel: Zi.LAN.CTNS , name: 'CTNS' } , { fieldLabel: Zi.LAN.TRUCKFEE , xtype: 'numberfield', name: 'TRUCKFEE', value: 0 } , { fieldLabel: Zi.LAN.PAYTYPE, name: 'PAYTYPE' },{ fieldLabel: Zi.LAN.TRUCKDATE, format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'TRUCKDATE' } ] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxYARD, this.comboxInfoClientContactYard, { fieldLabel: Zi.LAN.TEL, name: 'YARDTEL' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxFactry] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.FACTRYADDR, name: 'FACTRYADDR' }, { fieldLabel: Zi.LAN.FACTRYTIME, labelWidth: 80, name: 'FACTRYTIME' }] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.FACTRYATTN, name: 'FACTRYATTN' }, { fieldLabel: Zi.LAN.FACTRYTEL, name: 'FACTRYTEL' }, { fieldLabel: Zi.LAN.RETRUNYARDTIME, name: 'RETRUNYARDTIME' }] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxYARD2, this.comboxInfoClientContactYard2, { fieldLabel: Zi.LAN.TEL, name: 'RETURNTEL' }] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.CLOSINGDATE, format: 'Y-m-d', flex: 1, xtype: 'datetimefield', name: 'CLOSINGDATE' }, { fieldLabel: Zi.LAN.CARGODATE, format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'CARGODATE' }, this.comboxTRUCKSTATUS] }, { xtype: 'textareafield', grow: true, fieldLabel: Zi.LAN.TRUCKDETAIL, height: 60, name: 'TRUCKDETAIL', anchor: '100%' }, { xtype: 'textareafield', grow: true, fieldLabel: Zi.LAN.REMARK , height: 100, name: 'REMARK', anchor: '100%' }, { xtype: 'textfield', hidden: true, fieldLabel: '件数', name: 'PKGS', anchor: '100%' }, { xtype: 'textfield', hidden: true, fieldLabel: '重量', name: 'KGS', anchor: '100%' }, { xtype: 'textfield', hidden: true, fieldLabel: '尺码', name: 'CBM', anchor: '100%' } ]//end items(fieldset 1) }); //end this.formEdit //#endregion //#region 按钮Toolbar var menu1 = new Ext.menu.Menu({ id: 'basicMenu', items: [{ text: Zi.LAN.CtnPc , handler: function (button, event) { this.SavePC(); }, scope: this }, { text: Zi.LAN.TruckPc, handler: function (button, event) { this.SavePC_SH(); }, scope: this }] }); this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ id: 'btnESave', text: Zi.LAN.btnESave, iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: 'btnESaveAndClose', text: Zi.LAN.btnESaveAndClose, handler: function (button, event) { this.Save('1'); }, scope: this }, { id: 'btnESaveAndNew', text: Zi.LAN.btnESaveAndNew, handler: function (button, event) { this.Save('2'); }, scope: this }, '-', { text: Zi.LAN.btnClose, handler: function (button, event) { window.close(); }, scope: this }, { text: Zi.LAN.btnNew, handler: function (button, event) { this.LoadData('add', ''); }, scope: this }, { text: Zi.LAN.LoadInt, handler: function (button, event) { this.LoadinitData(); }, scope: this }, '-', { id: 'btnEHistryCopy', text: Zi.LAN.HistryInput, handler: function (button, event) { DsOpenEditWin('/MvcShipping/MsOpLetter/HistryTruckIndex', "派车通知历史引入", "600", "940", "10", "10"); }, scope: this }, '-', { text: Zi.LAN.CreatePc, menu: menu1, scope: this }, '-', { text: Zi.LAN.Print, iconCls: "btnprint", handler: function (button, event) { this.Print(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 框架结构 Ext.define('MsOpSeaeDetail', { extend: 'Ext.data.Model', fields: [ { name: 'GID', type: 'string' }, { name: 'LE_ID', type: 'string' }, { name: 'FACTRYTIME', type: 'string' }, { name: 'FACTRYATTN', type: 'string' }, { name: 'FACTRYTEL', type: 'string' }, { name: 'FACTRYADDR', type: 'string' }, { name: 'FACTRYNAME', type: 'string' } ] }); this.storeDetailList = Ext.create('Ext.data.Store', { model: 'MsOpSeaeDetail', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpLetter/GetLetterDetailList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridListDetail = new Ext.grid.GridPanel({ store: this.storeDetailList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', tbar: [ { text: Zi.LAN.btnadddetail , //'增加明细', tooltip: Zi.LAN.btnadddetail , //'增加明细', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { this.addDetail(); }, scope: this }, '-', { text: Zi.LAN.btndeletedetail, //'删除明细', tooltip: Zi.LAN.btndeletedetail, //'删除明细', id: "btndeldetail", iconCls: "btndeletedetail", handler: function (button, event) { this.deleteDetail(); }, scope: this }], columns: [{ sortable: true, dataIndex: 'GID', header: '编号', hidden: true, width: 0 }, { dataIndex: 'FACTRYNAME', header: Zi.LAN.companyname, //'重量', width: 220, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'FACTRYADDR', header: Zi.LAN.FACTRYADDR, //'重量', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'FACTRYTIME', header: Zi.LAN.FACTRYTIME, editor: { xtype: 'datetimefield', format: 'Y-m-d', allowBlank: false, selectOnFocus: true }, renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), width: 130 }, { dataIndex: 'FACTRYATTN', header: Zi.LAN.FACTRYATTN, //'重量', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'FACTRYTEL', header: Zi.LAN.FACTRYTEL, //'重量', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }] }); this.storeDetailList.on('beforeload', function (store) { var billNo = this.formEdit.getForm().findField('LE_ID').getValue(); var condition = "LE_ID='" + billNo + "'"; Ext.apply(store.proxy.extraParams, { condition: condition }); }, this); this.panelBodyCtn = new Ext.Panel({ // title: '集装箱信息', //'集装箱信息', layout: "border", height: 120, region: 'center', flex: 1, margin: '5 20', frame: true, items: [this.gridListDetail] }); this.panelpage = new Ext.Panel({ title: Zi.LAN.PCDETAIL, layout: "border", region: 'center', animate: true, autoScroll: true, // containerScroll: true, frame: false, items: [this.formEdit, this.panelBodyCtn] }); 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]; this.oplb = ret[4]; } 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('TRUCKER')); this.formHead.getForm().findField('BSNO').setValue(this.MainEditRecord.get('BSNO')); var trucker = this.MainEditRecord.get('TRUCKER'); if (trucker != '') { var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + trucker + "')"; this.storeInfoClientContact.load({ params: { condition: s }, callback: function (r, options, success) { if (success) { if (this.storeInfoClientContact.getCount() > 0) { var member = this.storeInfoClientContact.getAt(0); 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 }); this.formEdit.getForm().reset(); var yard = this.MainEditRecord.get('YARD'); this.formEdit.getForm().findField('CTNS').setValue(this.MainEditRecord.get('CNTRTOTAL')); this.formEdit.getForm().findField('YARD').setValue(yard); this.formEdit.getForm().findField('RETURNYARD').setValue(yard); this.formEdit.getForm().findField('YARDATTN').setValue(this.MainEditRecord.get('YARDATTN')); this.formEdit.getForm().findField('YARDTEL').setValue(this.MainEditRecord.get('YARDTEL')); this.formEdit.getForm().findField('RETURNATTN').setValue(this.MainEditRecord.get('YARDATTN')); this.formEdit.getForm().findField('RETURNTEL').setValue(this.MainEditRecord.get('YARDTEL')); var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d'); this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr); if (yard != '' && this.MainEditRecord.get('YARDATTN')=='') { 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); this.formEdit.getForm().findField('YARDATTN').setValue(member.data.SHOWNAME); this.formEdit.getForm().findField('YARDTEL').setValue(member.data.TEL); this.formEdit.getForm().findField('RETURNATTN').setValue(member.data.SHOWNAME); this.formEdit.getForm().findField('RETURNTEL').setValue(member.data.TEL); } else { this.formEdit.getForm().findField('YARDATTN').setValue(''); this.formEdit.getForm().findField('YARDTEL').setValue(''); this.formEdit.getForm().findField('RETURNATTN').setValue(''); this.formEdit.getForm().findField('RETURNTEL').setValue(''); } } }, scope: this }); } this.formEdit.getForm().findField('REMARK').setValue(''); } 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.formEdit.getForm().findField('CUSTOMERNAME').setValue(this.MainEditRecord.get('CUSTOMERNAME')); this.storeDetailList.load({ params: { condition: "LE_ID='" + data.LE_ID + "'" } }); this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsOpLetter/GetTruckData', 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 }); } //20160219 获取业务主表内的件数重量尺码,用于在生成散货派车单时传递 //this.formEdit.getForm().findField('PKGS').setValue(this.MainEditRecord.get('PKGS')); //this.formEdit.getForm().findField('KGS').setValue(this.MainEditRecord.get('KGS')); //this.formEdit.getForm().findField('CBM').setValue(this.MainEditRecord.get('CBM')); }, // 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); var bodydatas = []; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); bodydatas.push(member); } var jsonBodyCtn = ConvertRecordsToJsonAll(bodydatas); // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpLetter/SaveTruck', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: Ext.JSON.encode(body), detail: jsonBodyCtn }, 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(); } var LE_ID = this.formHead.getForm().findField('LE_ID').getValue(); for (var j = 0; j < this.storeDetailList.getCount(); j += 1) { var memberbody = this.storeDetailList.getAt(j); memberbody.set("LE_ID", LE_ID); memberbody.commit(); }; if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else if (type == '2') { this.LoadData('add', ''); } this.GetEditStatus(); } 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 SavePC: function () { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var url = '/MvcShipping/MsOpLetter/SavePC'; if (this.oplb == '空运出口' || this.oplb == '空运出口') { url = '/MvcShipping/MsOpLetter/SaveAirPC'; } var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue(); if (TRUCKSTATUS != "待派车") { Ext.Msg.show({ title: '警告', msg: '只有在待派车状态才允许生成派车单 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } _this = this; var data = this.formHead.getForm().getValues(false, false, false); var body = this.formEdit.getForm().getValues(false, false, false); var bs = this.MainEditRecord.data; // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: url, scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: Ext.JSON.encode(body), bs: Ext.JSON.encode(bs), oplb: _this.oplb }, 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(); } this.opStatus = 'edit'; 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 }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save SavePC_SH: function () { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var url = '/MvcShipping/MsOpLetter/SavePC_SH'; if (this.oplb == '空运出口' || this.oplb == '空运出口') { url = '/MvcShipping/MsOpLetter/SaveAirPC_SH'; } var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue(); if (TRUCKSTATUS != "待派车") { Ext.Msg.show({ title: '警告', msg: '只有在待派车状态才允许生成派车单 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } _this = this; var data = this.formHead.getForm().getValues(false, false, false); var body = this.formEdit.getForm().getValues(false, false, false); var bs = this.MainEditRecord.data; // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: url, scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: Ext.JSON.encode(body), bs: Ext.JSON.encode(bs), oplb: _this.oplb }, 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(); } this.opStatus = 'edit'; 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 }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save //#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('RETURNYARD').getValue(); var s = " ISOPERATOR=1 and LINKID in (select gid from [info_client] where SHORTNAME='" + YARD2 + "')"; this.storeInfoClientContactYard2.load({ params: { condition: s} }); }, LoadinitData: function () { var yard = this.MainEditRecord.get('YARD'); this.formEdit.getForm().findField('CTNS').setValue(this.MainEditRecord.get('CNTRTOTAL')); this.formEdit.getForm().findField('YARD').setValue(yard); this.formEdit.getForm().findField('RETURNYARD').setValue(yard); var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d'); this.formEdit.getForm().findField('TRUCKDATE').setValue(mydatestr); }, //#endregion addDetail: function () { var record = Ext.create('MsOpSeaeDetail', { GID: NewGuid(), LE_ID: '*', FACTRYTIME: '', FACTRYATTN: '', FACTRYTE: '', FACTRYADDR: '', FACTRYNAME: '' }); this.storeDetailList.add(record); var n = this.storeDetailList.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 }); }, deleteDetail: function () { var selectedRecords = this.gridListDetail.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.LE_ID == "" || rec.data.LE_ID == "*")//如果是新增但没有保存的数据,没有必要提交到后台 { this.storeDetailList.remove(selectedRecords[i]); } else { Ext.MessageBox.confirm('提示', '确定要删除此记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在操作数据'); Ext.Ajax.request({ waitMsg: '正在操作数据', //'正在删除数据...', url: '/MvcShipping/MsOpLetter/DeleteLetterDetail', params: { data: Ext.JSON.encode(rec.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeDetailList.remove(rec); 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); } //this.storeBodyList.remove(selectedRecords[i]); } }, //#region 编辑时按钮等的状态 GetEditStatus: function () { var canedit = false; //var bsStatus = this.formHead.getForm().findField('BSSTATUS').getValue(); var inputby = this.formHead.getForm().findField('INPUTBY').getValue(); var TRUCKSTATUS = this.formEdit.getForm().findField('TRUCKSTATUS').getValue(); if (TRUCKSTATUS != '待派车') { canedit = false; this.setSaveBtnStatus(canedit); } else { this.setSaveBtnStatus(true); } _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 = 'MSOPLETTERTRUCK'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter WHERE LE_ID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM op_letter_truck WHERE LE_ID = '" + billNo + "'"; var sql3 = ""; if (this.oplb == "海运进口") sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_seai WHERE BSNO = '" + bsNo + "'"; else if (this.oplb == "空运进口") sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_airi WHERE BSNO = '" + bsNo + "'"; else if (this.oplb == "空运出口") sql3 = "SET LANGUAGE 'us_english' SELECT * FROM op_aire WHERE BSNO = '" + bsNo + "'"; else 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 });