Ext.namespace('Shipping'); Shipping.MsCodeRailwayPortEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCodeRailwayPortEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCodeRailwayPortEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) this.StorePORTTYPE = Ext.create('Ext.data.Store', { fields: ['PORTTYPEID','PORTTYPE'] }); this.StorePORTTYPE.add({"PORTTYPEID": "F","PORTTYPE": "境外站" }); this.StorePORTTYPE.add({ "PORTTYPEID": "C", "PORTTYPE": "境内站" }); this.comboxPORTTYPE = Ext.create('DsExt.ux.RefTableCombox', { store: this.StorePORTTYPE, fieldLabel: '站点类型', forceSelection: true, name: 'PORTTYPE', valueField: 'PORTTYPEID', displayField: 'PORTTYPE', value: 'F' }); this.formBasic = Ext.widget('form', { region: 'north', title: '基本资料', frame: true, bodyPadding: 0, collapsed: false, collapsible: true, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 110, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '口岸代码', name: 'PORTID' }, { fieldLabel: '口岸英文名', name: 'PORTENAME' }, { fieldLabel: '口岸中文名', name: 'PORTCNAME' }] },{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '所在省', name: 'PROVINCE' }, { fieldLabel: '所在城市', name: 'CITYCNAME' }, { fieldLabel: '城市英文', name: 'CITYENAME' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '铁路局', name: 'RAILBUREAU' }, { xtype: 'checkboxfield', fieldLabel: '是否常用', flex: 1, inputValue: true, labelAlign: 'right', name: 'ISOFTEN' }, this.comboxPORTTYPE] }, { xtype: 'textareafield', grow: true, fieldLabel: '港口详细资料', height: 60, name: 'PORTDETAIL', anchor: '100%' } ]//end root items }] }); // this.formPort = Ext.widget('form', { region: 'north', title: '距口岸距离', frame: true, bodyPadding: 0, collapsed: false, collapsible: true, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 110, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'Alashankou/Dostyk', name: 'DTALSHANKOU' }, { fieldLabel: 'Manzhouli/Zabaikalsk', name: 'DTMANZHOULI' }, { fieldLabel: 'Erlian/Dzhaminuud', name: 'DTERLIAN' } ]//end items(fieldset 1) }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ { fieldLabel: 'SuiFenhe/Grodekovo', name: 'DTSUIFENHE' },{ fieldLabel: 'Dandong/Sinuiju', name: 'DTDANDONG' }, { fieldLabel: 'Pingxiang', name: 'DTPINGXIANG' } ]//end items(fieldset 1) }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: 'Horgos', name: 'DTHORGOS' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' } ]//end items(fieldset 1) } ]//end root items }] }); // this.formWork = Ext.widget('form', { region: 'north', title: '处理能力', frame: true, bodyPadding: 0, collapsed: false, collapsible: true, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 110, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '处理能力', name: 'WORKPOWER' } ]//end items(fieldset 1) }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'checkboxfield', fieldLabel: "20'", inputValue: true, flex: 1, labelAlign: 'right', name: 'IS20' }, { xtype: 'checkboxfield', fieldLabel: "40'", inputValue: true, flex: 1, labelAlign: 'right', name: 'IS40' }, { xtype: 'checkboxfield', fieldLabel: "48'", inputValue: true, flex: 1, labelAlign: 'right', name: 'IS48' }, { xtype: 'checkboxfield', fieldLabel: "50'", inputValue: true, flex: 1, labelAlign: 'right', name: 'IS50' } ]//end items(fieldset 1) }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'checkboxfield', fieldLabel: "干散货箱", inputValue: true, flex: 1, labelAlign: 'right', name: 'ISBULK' }, { xtype: 'checkboxfield', fieldLabel: "罐箱", inputValue: true, flex: 1, labelAlign: 'right', name: 'ISTANK' }, { xtype: 'checkboxfield', fieldLabel: "Flatrack", inputValue: true, flex: 1, labelAlign: 'right', name: 'ISFLAT' }, { xtype: 'checkboxfield', fieldLabel: "D.S.Car", inputValue: true, flex: 1, labelAlign: 'right', name: 'ISDSCAR' } ]//end items(fieldset 1) } ]//end root items }] }); // this.formRemarks = Ext.widget('form', { region: 'north', title: '备注', frame: true, bodyPadding: 0, collapsed: false, collapsible: true, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 110, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, height: 60, name: 'REMARKS', anchor: '100%' } ]//end items(fieldset 1) } ]//end root items }] }); // //编辑form this.formEdit = Ext.widget('form', { region: 'north', frame: true, bodyPadding: 0, autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 110, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [this.formBasic, this.formPort, this.formWork, this.formRemarks ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit //#endregion //#region 按钮Toolbar 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 } ] }); //end 按钮Toolbar //#endregion //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 650, items: [this.panelBtn, this.formEdit] }); Ext.apply(this, { items: [this.panelTop] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener.thisport; //初始化数据 this.InitData(); //绑定事件 }, //end initUIComponents InitData: function () { this.opStatus = 'add'; var condition = ''; if (this.ParentWin) { var ret = this.ParentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; } if (this.opStatus == 'edit') condition = " GID='" + this.editRecord.get('GID') + "'"; 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/MsOpRailway/GetPortData', 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 }); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } basicForm.findField('GID').setDisabled(false); var data = basicForm.getValues(); basicForm.findField('GID').setDisabled(true); if (this.opStatus == 'add') { data.GID = NewGuid(); } Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpRailway/SavePort', 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') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsCodeRailwayPort', 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'; basicForm.findField('GID').setDisabled(true); } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); basicForm.findField('GID').setDisabled(false); } } 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 });