Ext.namespace('Shipping'); Shipping.MsCodeGoodsEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCodeGoodsEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCodeGoodsEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', storeList: null, EditRecord: null, feeType: 0, StoreFee: null, initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.CodeGoodsEdit = getUrlParam('CodeGoodsEdit'); //#region 编辑form //枚举参照相关(编辑form) this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeLoadportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' } }); this.storeCodeDisport.load(); this.storeCodeDisportxh = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' } }); this.storeCodeDisportxh.load(); this.storeCodeDisportzz = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeDisportModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' } }); this.storeCodeDisportzz.load(); //场站 this.storeYARD = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' } }); this.storeYARD.load(); //装货港 this.PORTLOAD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '装货港', store: this.storeCodeDisport, forceSelection: true, name: 'PORTLOAD', valueField: 'EDICODE', displayField: 'CodeAndName' }); //卸货港 this.PORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '卸货港', store: this.storeCodeDisportxh, forceSelection: true, name: 'PORTDISCHARGE', valueField: 'EDICODE', displayField: 'CodeAndName' }); //中转港 this.ENTREPORT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '中转港', store: this.storeCodeDisportzz, forceSelection: true, name: 'ENTREPORT', valueField: 'EDICODE', displayField: 'CodeAndName' }); //场站 this.YARDID = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '默认场站(码头)', store: this.storeYARD, forceSelection: true, name: 'YARDID', valueField: 'CustName', displayField: 'CodeAndName' }); //表参照相关(编辑form) //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 5, autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { //anchor: '100%' }, items: [ { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: 'VOID', name: 'VOID', hidden:true }, { fieldLabel: '船名代码', name: 'VSID', hidden:true }, { fieldLabel: '船名', name: 'VESSEL', readOnly:true }, { fieldLabel: '航次', name: 'VOYNO', hidde:true }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.PORTLOAD , { fieldLabel: '开船日期', name: 'ETD', format: 'Y-m-d', xtype: 'datefield', flex: 1, renderer: Ext.util.Format.dateRenderer('Y-m-d') }] },{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.ENTREPORT,{ fieldLabel: '截港日期', name: 'CLOSINGDATE', format: 'Y-m-d', xtype: 'datetimefield', flex: 1, renderer: Ext.util.Format.dateRenderer('Y-m-d') } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.PORTDISCHARGE,{ fieldLabel: '预抵日期', name:'ETA', format: 'Y-m-d', xtype: 'datefield', flex: 1, renderer: Ext.util.Format.dateRenderer('Y-m-d') }] },{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.YARDID,{ fieldLabel: 'ATD', name: 'ATD', format: 'Y-m-d', xtype: 'datefield', flex: 1, renderer: Ext.util.Format.dateRenderer('Y-m-d') }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: '截单时间', name: 'CLOSEDOCDATE', format: 'Y-m-d H:i', xtype: 'datetimefield', flex: 1, renderer: Ext.util.Format.dateRenderer('Y-m-d') }, { xtype: 'hiddenfield', flex: 1 }] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, '-', { text: "复制新建", handler: function (button, event) { var basicForm = this.formEdit.getForm(); this.opStatus = 'add'; }, scope: this } ] }); //end 按钮Toolbar //#endregion //#region 明细表 //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 360, width:100, items: [this.panelBtn, this.formEdit] }); Ext.apply(this, { items: [this.panelTop, this.paneldetail] }); //#endregion //绑定查询窗体 //初始化数据 this.ParentWin = window.parent.opener; this.InitData(); }, //end initUIComponents InitData: function () { var basicForm = this.formEdit.getForm(); this.opStatus = 'add'; var condition = ''; if (this.ParentWin) { var ret = this.ParentWin.OprationSwap(); this.opStatus = ret[3]; this.storeList = ret[4]; this.editRecord = ret[5]; } if (this.opStatus=='add') { basicForm.findField('VESSEL').setValue(this.editRecord.vessel); basicForm.findField('VSID').setValue(this.editRecord.vsid); }else { condition =this.editRecord.data.VSID; this.LoadData(this.opStatus, condition); } }, //end InitData一个笔形成之后 LoadData: function (opstatus, condition) { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsCodeVesselSet/GetFootData', 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 data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; var cargoid = 0; if (this.opStatus == 'edit') { cargoid = this.editRecord.get('PORTID'); } }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = basicForm.getValues(); data.DM_ID = NewGuid(); basicForm.findField('VOID').setValue(data.DM_ID); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsCodeVesselSet/SaveFoot', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data) }, 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.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { Ext.Msg.alert('提示','添加成功'); var arrNewRecords = this.storeList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { this.opStatus='edit'; Ext.Msg.alert('提示','修改成功'); this.storeList.reload(); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else { 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 onAddDetailClick: function (button, event, type) { this.addDetail(type); }, //end onAddDetailClick onDelDetailClick: function (button, event, type) { this.deleteDetail(type); }, //onDelDetailClick gridAfterEdit: function (editor, e, eOpts) { }, addDetail: function (type) { var newSerialno = 0; store = this.storeBodyList; var record = Ext.create('MsCodeGoodsDetail', { GID: '', LINKGID: '', GOODSDETAILNAME: "", GOODSDETAILPKGS: 0 }); store.add(record); this.gridListCellEditing.startEditByPosition({ row: 2, column: 1 }); }, });