Ext.namespace('DsTruck'); DsTruck.approvalEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.approvalEdit.superclass.constructor.call(this); }; Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; } var xhr = new XMLHttpRequest(); var currdate = new Date(); if (!xhr) { //...其他生成xmlhttprequest方法 } xhr.open("HEAD", location.href, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var datestr = xhr.getResponseHeader("Date"); currdate = new Date(datestr); // alert(currdate.format('yyyy-MM-dd')); } } xhr.send(null); Ext.extend(DsTruck.approvalEdit, Ext.Panel, { parentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, storeCargociq: null, initUIComponents: function () { //#region 枚举参照相关 //表参照相关 this.storeCountry = Ext.create('DsExt.ux.RefTableStore', { model: 'ConutryRef', proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' } }); this.storeCountry.load({ params: { condition: ""} }); this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '进口国', store: this.storeCountry, name: 'Countryid', valueField: 'countryid', displayField: 'country_idandname' }); this.storeport = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeport.load({ params: { enumTypeId: 10} }); this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '受理机构', store: this.storeport, name: 'SLJG' }); this.storestop = Ext.create('DsExt.ux.RefEnumStore', {}); this.storestop.load({ params: { enumTypeId: 0} }); this.comboxstop = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '是否停用', store: this.storestop, name: 'isdeleted' }); this.storeCompany = Ext.create('DsExt.ux.RefTableStore', { model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' } }); this.storeCompany.load({ params: { condition: ""} }); this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '用证公司', store: this.storeCompany, name: 'company', valueField: 'gid', displayField: 'name' }); this.storedepot = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storedepot.load({ params: { condition: " ISWAREHOUSE=1"} }); this.comboxdepot = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '关联仓库', store: this.storedepot, name: 'depot', valueField: 'CustName', displayField: 'KFCodename' }); this.storeCargo = Ext.create('DsExt.ux.RefTableStore', { model: 'CargoRef', proxy: { url: '/CommMng/BasicDataRef/GetCargoRefList' } }); this.storeCargo.load({ params: { condition: ""} }); this.comboxCargo = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'HS代码', id: "cargoinfo_id", store: this.storeCargo, name: 'cargoinfo_id', valueField: 'id', displayField: 'codeandname', autoselect: true }); this.comboxCargo.addListener('select', function (combo, record, index) { var s = " cargoinfoid=" + combo.value; //alert(s); //this.storeCargociq.removeAll(); this.storeCargociq.load({ params: { condition: s} }); //this.comboxCargociq.setValue('请选择'); this.comboxCargociq.clearValue(); }, this); this.storeCargociq = Ext.create('DsExt.ux.RefTableStore', { model: 'CargociqRef', proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' } }); //this.storeCargociq.load({ params: { condition: ""} }); this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: 'CIQ代码', store: this.storeCargociq, name: 'cargociq_id', valueField: 'id', displayField: 'codeandname', autoselect: true //ciq代码 }); //商品规格 20160420 this.storeSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeSPECIFICATIONS.load({ params: { enumTypeId: 34} }); this.comboxSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumCombox', { store: this.storeSPECIFICATIONS, fieldLabel: '商品规格', forceSelection: true, name: 'SPECIFICATIONS', id: "SPECIFICATIONS", valueField: 'EnumValueName', displayField: 'EnumValueName', //0203290090_其他冻藏猪肉 listeners: { focus: function (field, eOpts) { var basicForm = this.formEdit.getForm(); var HSNAME = Ext.getCmp("cargoinfo_id").getRawValue(); if (HSNAME != "0203290090_其他冻藏猪肉") { alert("0203290090以外的商品不能修改规格"); Ext.getCmp("SPECIFICATIONS").readOnly = true; } else { Ext.getCmp("SPECIFICATIONS").readOnly = false; } }, blur: function (field, eOpts) { var basicForm = this.formEdit.getForm(); var HSNAME = Ext.getCmp("cargoinfo_id").getRawValue(); if (HSNAME != "0203290090_其他冻藏猪肉") { //alert("0203290090以外的商品不能修改规格"); Ext.getCmp("SPECIFICATIONS").setValue(""); } else { //Ext.getCmp("SPECIFICATIONS").readOnly = false; } }, scope: this } }); /*{ xtype: 'checkbox', id: "isEnd", hidden: true, fieldLabel: '运行完成', name: 'isEnd', listeners: { focus: function (field, eOpts) { var basicForm = this.formEdit.getForm(); var TruckNo = basicForm.findField('TruckNo').getValue(); if (TruckNo == "") { alert("未进行派车不能完结"); Ext.getCmp("isEnd").readOnly = true; } else { Ext.getCmp("isEnd").readOnly = false; } }, blur: function (field, eOpts) { var basicForm = this.formEdit.getForm(); var TruckNo = basicForm.findField('TruckNo'); if (field.value == true) { TruckNo.readOnly = true; TruckNo.show(); } else { TruckNo.readOnly = false; TruckNo.show() } }, scope: this } }*/ //#endregion //编辑form this.formEdit = Ext.widget('form', { // layout: "border", region: 'center', // height: 200, frame: true, bodyPadding: 5, 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: [ this.comboxCompany , this.comboxport, //受理机构/目的港 { fieldLabel: '许可证号', name: 'APPNO' }, { fieldLabel: '申请单号', name: 'SQDH' }, { fieldLabel: 'id', name: 'id', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'gid', name: 'gid', flex: 0, hidden: true, margins: '0' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCargo, this.comboxCargociq, { fieldLabel: '商品名称', name: 'AppName' }, this.comboxSPECIFICATIONS] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCountry, { fieldLabel: '额度(吨)', allowBlank: false, name: 'Weight' }, { fieldLabel: '已经使用', allowBlank: false, name: 'usedweight' }, { fieldLabel: '已核销未使用', allowBlank: false, name: 'JustWriteoffs' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '未核销(吨)', name: 'remain', disabled: true }, { fieldLabel: '已核销(吨)', name: 'used', disabled: true }, { fieldLabel: '未核销未配证(吨)', name: 'canbeused', disabled: true }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '有效期', format: 'Y-m-d', xtype: 'datefield', renderer: Ext.util.Format.dateRenderer('Y-m-d'), name: 'ValidDate' }, this.comboxdepot, this.comboxstop] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '备注', name: 'REMARK' }] }] }//end fieldset 1 ]//end root items }); //end this.formEdit //按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: "savebtn", text: "保存", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: "saveandclose", text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, { id: "saveandnew", text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, '-', { id: "closebtn", text: "关闭", handler: function (button, event) { window.close(); }, scope: this } ] }); //end 按钮Toolbar //////只显示不编辑:许可证的使用情况 //结果集 this.storeUsing = Ext.create('Ext.data.Store', { model: 'Usingmb', remoteSort: false, proxy: { type: 'ajax', url: '/Import/approval/GetUsing', reader: { id: 'id', root: 'data', totalProperty: 'totalCount' } } }); /* this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { enableTextSelection: true }, columns: [new Ext.grid.RowNumberer()], bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) });*/ //表格 Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 40 }); this.UsingGrid = new Ext.grid.GridPanel({ store: this.storeUsing, enableHdMenu: false, title: '使用情况', region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { stripeRows: true, enableTextSelection: true }, columns: [new Ext.grid.RowNumberer(), { sortable: true, dataIndex: 'weight', header: '使用重量(吨)', width: 80 }, { sortable: true, dataIndex: 'cancellationRef', header: '使用情况', width: 80 }, { sortable: true, dataIndex: 'cancellation_date', header: '核销时间', width: 80 }, { sortable: true, dataIndex: 'ContractNo', header: '合同序列号', width: 130 }, { sortable: true, dataIndex: 'HTH', header: '合同号', width: 110 }, { sortable: true, dataIndex: 'ArrivalDate', header: '到港日期', width: 80 }, { sortable: true, dataIndex: 'seller', header: '用证/贸易商', width: 80 }, { sortable: true, dataIndex: 'buyer', header: '购货方', width: 80 }, { sortable: true, dataIndex: 'cargoname', header: '货名', width: 100 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 100 }, { sortable: true, dataIndex: 'code', header: 'HS代码', width: 100 }, { sortable: true, dataIndex: 'name', header: 'HS名称', width: 140 }, { sortable: true, dataIndex: 'ciqcode', header: 'CIQ代码', width: 80 }, { sortable: true, dataIndex: 'ciqname', header: 'CIQ名称', width: 80 }, { sortable: true, dataIndex: 'MainstateRef', header: '合同状态', width: 80 } ] }); this.UsingGrid.addListener('itemdblclick', function (dataview, record, item, index, e, b) { // alert('0....' + dataview.toString() + ',' + record.toString() + ',' + item.toString() + ',' + index.toString() + ',' + e.toString() + ',' + b.toString()); this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/Import/XXH/Edit', '', 650, 1150); //alert("DBL"); }, this); ////// //布局 this.editpanel = new Ext.Panel({ region: 'north', items: [this.formEdit] }); this.usingpanel = new Ext.Panel({ region: 'center', title: '使用情况列表', items: [this.UsingGrid] }); Ext.apply(this, { items: [ this.panelBtn, this.editpanel, this.UsingGrid ] }); parentWin = window.parent.opener; this.InitData(); }, //end initUIComponents Loadciq: function (cargoinfoid) { var s = " cargoinfoid=" + cargoinfoid; //alert(s); this.storeCargociq.load({ params: { condition: s} }); }, InitData: function () { this.opStatus = 'add'; var condition = ''; // alert("1:"+parentWin.toString()); if (parentWin) { var ret = parentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; // alert("3:" + ret[0].toString() + "," + ret[1].toString() + "," + ret[2].toString()); } if (this.opStatus == 'edit') { //alert(this.editRecord.get('id') + ' ' + this.editRecord.get('cargoinfo_id')) var hscode = this.editRecord.get('cargoinfo_id') this.Loadciq(hscode); condition = " a.id='" + this.editRecord.get('id') + "'"; } this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { // alert(condition); this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/Import/approval/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; } var data = result.data; this.formEdit.getForm().reset(); // if (data.ex_ == "") { data.OilLrDate = currdate.format('yyyy-MM-dd') }; this.formEdit.getForm().setValues(data); var sql = 'app_id=' + data.id; if (this.opStatus != 'add') { this.storeUsing.load({ params: { start: 0, limit: 500, sort: '', condition: sql }, //params: { condition: sql }, waitMsg: "正在查询数据...", scope: this }); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); //var sql = this.getCondition(); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!this.formEdit.getForm().isValid()) { return; } basicForm.findField('id').setDisabled(false); var data = this.formEdit.getForm().getValues(); basicForm.findField('id').setDisabled(true); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/Import/approval/Save', 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]; this.opStatus = 'edit'; } else if (this.opStatus == 'edit') { var editp = Ext.create('approvalmb', 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 { 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 OprationSwap: function () { var ret = new Array(); ret[0] = 'edit'; ret[1] = ""; ret[2] = this.SelectedRecord; return ret; } });