Ext.namespace('Shipping'); var HistryAdd =1; Shipping.MsOpSeaeModuleIndex = function (config, addtype) { Ext.applyIf(this, config); HistryAdd = addtype; this.initUIComponents(); window.Shipping.MsOpSeaeModuleIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpSeaeModuleIndex, Ext.Panel, { PageSize: 30, ParentWin: null, OpStatus: 'add', OprationStatus: null, //仅当弹出界面时使用 EditRecord: null, initUIComponents: function () { this.bstype = getUrlParam('bstype'); var mainform = window.parent.opener._this; if (mainform) { //this.MainEditRecord = new Object(); this.MainEditRecord = mainform.editRecord; this.BsNo = this.MainEditRecord.get("BSNO"); //this.MainEditRecord=mainform.Editdata; //this.BsNo = this.MainEditRecord.BSNO; } Ext.define('CodeOpTemplateDetail', { extend: 'Ext.data.Model', fields: [ { name: 'GID', type: 'string' }, { name: 'LINKGID', type: 'string' }, { name: 'FIELDNAME', type: 'string' }, { name: 'DEFVALUE', type: 'string' } ] }); //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpSeaeModuleModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSeaeModule/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //#region 主grid this.initgirdcolums = [{ sortable: true, dataIndex: 'TEMPLATE', header: '模板名称', width: 130 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 50 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 130 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 130 }, { sortable: true, dataIndex: 'SHIPPER', header: '发货人', width: 130 }, { sortable: true, dataIndex: 'CONSIGNEE', header: '收货人', width: 130 }, { sortable: true, dataIndex: 'GOODSNAME', header: '品名', width: 130 }, { sortable: true, dataIndex: 'CARGOID', header: '货物标识', width: 130 }, { sortable: true, dataIndex: 'INPUTBY', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'INPUTBYDATE', header: '录入日期', width: 86 }]; this.girdcolums = this.initgirdcolums; this.gridListCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, split: true, enableHdMenu: false, region: 'north', height:120, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selModel: this.gridListCheckBoxModel, viewConfig: { autoFill: true, enableTextSelection: true }, columns: this.girdcolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); //this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 //this.gridList.reconfigure(this.storeList, this.girdcolums); //this.gridList.columns[1] = new Ext.grid.RowNumberer(); this.gridList.addListener('itemclick', function (dataview, record, item, index, e, b) { this.opStatus == 'edit'; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(record.data); }, this); //#endregion //#region 固定费用明细表 //#region formSearch //#region formSearch枚举参照相关 //客户加载_委托单位 this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} }); //委托单位 _this = this; this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '委托单位', store: this.storeCustCode, forceSelection: true, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //#endregion _this = this; this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCustCode, { fieldLabel: '模板名称', name: 'TEMPLATE', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } ] }] }] }); //#endregion formSearch //#region 编辑formEdit 基本信息 this.formEdit = Ext.widget('form', { region: 'north', //width: 680, //height: 1000, frame: true, bodyPadding: 5, layout: 'anchor', trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 70, msgTarget: 'qtip' }, items: [{ xtype: 'fieldset', defaultType: 'textfield', layout: 'hbox', defaults: { anchor: '96%' }, items: [{ xtype: 'container', layout: 'anchor', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: 'GID', name: 'GID', flex: 0, hidden: true, margins: '0' },{ xtype: 'textareafield', grow: true, fieldLabel: '发货人', labelWidth: 50, height: 80, name: 'SHIPPER', anchor: '100%' }, { xtype: 'textareafield', grow: true, fieldLabel: '收货人', labelWidth: 50, height: 80, name: 'CONSIGNEE', anchor: '100%' }, { xtype: 'textareafield', grow: true, fieldLabel: '通知人', labelWidth: 50, height: 80, name: 'NOTIFYPARTY', anchor: '100%' } ] }, { xtype: 'container', layout: 'anchor', flex: 1.2, defaultType: 'textfield', items: [{ xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '模板名称', // flex: 1.5, name: 'TEMPLATE' }, { fieldLabel: '委托单位', readOnly:true, name: 'CUSTOMERNAME' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '装货港', name: 'PORTLOAD', // flex: 1.5 }, { fieldLabel: '装港代码', // flex: 0.5, name: 'PORTLOADID' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '卸货港', // flex: 1.5, name: 'PORTDISCHARGE' }, { fieldLabel: '卸港代码', // flex: 0.5, name: 'PORTDISCHARGEID' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '目的地', // flex: 1.5, name: 'DESTINATION' }, { fieldLabel: '目的代码', // flex: 0.5, name: 'DESTINATIONID' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '交货地', // flex: 1.5, name: 'PLACEDELIVERY' }, { fieldLabel: '交货代码', // flex: 0.5, name: 'PLACEDELIVERYID' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '收货地', // flex: 1.5, name: 'PLACERECEIPT' }, { fieldLabel: '收货代码', // flex: 0.5, name: 'PLACERECEIPTID' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '件数', name: 'PKGS' }, { fieldLabel: '包装', name: 'KINDPKGS' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [{ fieldLabel: '毛重', name: 'KGS' }, { fieldLabel: '尺码', name: 'CBM' }] } ] } ] }, { xtype: 'container', layout: 'anchor', flex: 1, defaultType: 'textfield', defaults: { anchor: '99%' }, items: [{ xtype: 'container', defaultType: 'textfield', layout: 'hbox', items: [{ xtype: 'container', layout: 'anchor', flex: 1, defaultType: 'textfield', items: [{ xtype: 'label', html: 'Seal No.(封志号)
Marks & Nos.(标记与号码) ' }, { xtype: 'textareafield', grow: true, height: 120, name: 'MARKS', anchor: '100%' } ] }, { xtype: 'container', layout: 'anchor', flex: 3, defaultType: 'textfield', items: [{ xtype: 'container', defaultType: 'textfield', layout: 'hbox', defaults: { anchor: '100%' }, items: [{ xtype: 'label', html: '     Description of Goods
     (包装种类与货名)' }, { fieldLabel: '品名', name: 'GOODSNAME' }, this.comboxCargoid, { fieldLabel: 'HS编码', name: 'HSCODE' }] }, { xtype: 'textareafield', grow: true, fieldLabel: '  ', labelSeparator: '', labelWidth: 20, height: 120, name: 'DESCRIPTION', anchor: '100%' }] } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '件数大写', name: 'TOTALNO' }] }, { xtype: 'container', defaultType: 'textfield', layout: 'hbox', items: [{ fieldLabel: '签单方式', labelWidth: 60, name: 'ISSUETYPE' }, { fieldLabel: '签单地点', labelWidth: 60, name: 'ISSUEPLACE' }, { fieldLabel: '提单份数', labelWidth: 60, name: 'NOBILL' }, { fieldLabel: '副本份数', labelWidth: 60, name: 'COPYNOBILL' }] }, { xtype: 'container', defaultType: 'textfield', layout: 'hbox', items: [{ fieldLabel: '签单方式', name: 'BLFRT' }, { fieldLabel: '预付地点', name: 'PREPARDAT' }, { fieldLabel: '到付地点', name: 'PAYABLEAT' }, { fieldLabel: '运输条款', name: 'SERVICE' }] }, { xtype: 'container', defaultType: 'textfield', layout: 'hbox', items: [{ fieldLabel: '冷藏通风量', name: 'REEFERF' }, { fieldLabel: '设置温度', name: 'TEMPSET' }, this.comboxTemp, { fieldLabel: '最低温度', name: 'TEMPMIN' }, { fieldLabel: '最高温度', name: 'TEMPMAX' }] }, { xtype: 'container', defaultType: 'textfield', layout: 'hbox', items: [{ fieldLabel: '危险品等级', flex: 1, labelWidth: 70, name: 'DCLASS' }, { fieldLabel: '危险品编号', flex: 1, labelWidth: 70, name: 'DUNNO' }, { fieldLabel: '危险品页号', flex: 1, labelWidth: 70, name: 'DPAGE' }, { fieldLabel: '危险品标签', flex: 1, labelWidth: 70, name: 'DLABEL' }, { fieldLabel: '危险品联系人', flex: 1, labelWidth: 90, name: 'LINKMAN' }] }, { xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [ { xtype: 'textareafield', grow: true, flex: 2, fieldLabel: '备注', //'备注', height: 30, name: 'REMARK', anchor: '100%' } ] }] } ] }); //end this.formEdit //#endregion //#region 按钮ToolBar //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ text: "调入模板信息", handler: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); for (var i in selections) { var record = selections[i]; parentWin.formEdit.getForm().findField('SHIPPER').setValue(record.data.SHIPPER); parentWin.formEdit.getForm().findField('CONSIGNEE').setValue(record.data.CONSIGNEE); parentWin.formEdit.getForm().findField('NOTIFYPARTY').setValue(record.data.NOTIFYPARTY); parentWin.formEdit.getForm().findField('MARKS').setValue(record.data.MARKS); parentWin.formEdit.getForm().findField('DESCRIPTION').setValue(record.data.DESCRIPTION); parentWin.formEdit.getForm().findField('PORTLOADID').setValue(record.data.PORTLOADID); parentWin.formEdit.getForm().findField('PORTLOAD').setValue(record.data.PORTLOAD); parentWin.formEdit.getForm().findField('PORTDISCHARGEID').setValue(record.data.PORTDISCHARGEID); parentWin.formEdit.getForm().findField('PORTDISCHARGE').setValue(record.data.PORTDISCHARGE); parentWin.formEdit.getForm().findField('KGS').setValue(record.data.KGS); parentWin.formEdit.getForm().findField('PLACERECEIPT').setValue(record.data.PLACERECEIPT); parentWin.formEdit.getForm().findField('PLACEDELIVERYID').setValue(record.data.PLACEDELIVERYID); parentWin.formEdit.getForm().findField('PLACEDELIVERY').setValue(record.data.PLACEDELIVERY); parentWin.formEdit.getForm().findField('DESTINATIONID').setValue(record.data.DESTINATIONID); parentWin.formEdit.getForm().findField('DESTINATION').setValue(record.data.DESTINATION); parentWin.formEdit.getForm().findField('NOBILL').setValue(record.data.NOBILL); parentWin.formEdit.getForm().findField('ISSUETYPE').setValue(record.data.ISSUETYPE); parentWin.formEdit.getForm().findField('ISSUEPLACE').setValue(record.data.ISSUEPLACE); parentWin.formEdit.getForm().findField('BLFRT').setValue(record.data.BLFRT); parentWin.formEdit.getForm().findField('PREPARDAT').setValue(record.data.PREPARDAT); parentWin.formEdit.getForm().findField('PAYABLEAT').setValue(record.data.PAYABLEAT); parentWin.formEdit.getForm().findField('SERVICE').setValue(record.data.SERVICE); parentWin.formEdit.getForm().findField('GOODSNAME').setValue(record.data.GOODSNAME); parentWin.formEdit.getForm().findField('PKGS').setValue(record.data.PKGS); parentWin.formEdit.getForm().findField('KINDPKGS').setValue(record.data.KINDPKGS); parentWin.formEdit.getForm().findField('CBM').setValue(record.data.CBM); parentWin.formEdit.getForm().findField('TOTALNO').setValue(record.data.TOTALNO); parentWin.formEdit.getForm().findField('REMARK').setValue(record.data.REMARK); parentWin.formEdit.getForm().findField('PLACERECEIPTID').setValue(record.data.PLACERECEIPTID); parentWin.formEdit.getForm().findField('COPYNOBILL').setValue(record.data.COPYNOBILL); parentWin.formEdit.getForm().findField('HSCODE').setValue(record.data.HSCODE); parentWin.formEdit.getForm().findField('CARGOID').setValue(record.data.CARGOID); parentWin.formEdit.getForm().findField('DCLASS').setValue(record.data.DCLASS); parentWin.formEdit.getForm().findField('DUNNO').setValue(record.data.DUNNO); parentWin.formEdit.getForm().findField('REEFERF').setValue(record.data.REEFERF); parentWin.formEdit.getForm().findField('TEMPID').setValue(record.data.TEMPID); parentWin.formEdit.getForm().findField('TEMPSET').setValue(record.data.TEMPSET); parentWin.formEdit.getForm().findField('TEMPMAX').setValue(record.data.TEMPMAX); parentWin.formEdit.getForm().findField('TEMPMIN').setValue(record.data.TEMPMIN); parentWin.formEdit.getForm().findField('HUMIDITY').setValue(record.data.HUMIDITY); parentWin.formEdit.getForm().findField('DPAGE').setValue(record.data.DPAGE); parentWin.formEdit.getForm().findField('DLABEL').setValue(record.data.DLABEL); parentWin.formEdit.getForm().findField('LINKMAN').setValue(record.data.LINKMAN); } window.closeAction = 'destroy'; window.close(); }, scope: this },{ id: 'btnESave', text: "保存模板", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, '-', { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, '-', { text: "删除模板", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }] }); //end 按钮Toolbar //#endregion //#endregion //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 75, items: [this.panelBtn,this.formSearch] }); this.panelpage = new Ext.Panel({ layout: "border", region: 'center', animate: true, autoScroll: true, frame: false, items: [ this.formEdit ] }); Ext.apply(this, { items: [this.panelTop, this.gridList, this.panelpage] }); //#endregion parentWin = window.parent.opener.panelEdit; //#region 事件绑定 this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeList.on('load', function (store, records) { if (store.getCount() > 0) { this.gridList.getSelectionModel().select(0); //this.gridListCheckBoxModel.selectAll(); } }, this); //#endregion //#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示) if (this.bstype == "add") { this.LoadData(); } else { this.onAutoRefresh(); } //#endregion }, //end initUIComponents LoadData: function () { this.opStatus = 'add'; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(this.MainEditRecord.data); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var TEMPLATE = this.formEdit.getForm().findField('TEMPLATE').getValue(); if (TEMPLATE == '') { Ext.Msg.show({ title: '提示', msg: '模板名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); 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/MsOpSeaeModule/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]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsOpSeaeModuleModel', 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 }); } } }); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpSeaeModule/Delete', params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); 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 }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, //onDeleteClick onAutoRefresh: function () { var sql = ''; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; //客户名称 var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "B.CUSTOMERNAME='" + CUSTOMERNAME + "'"); var TEMPLATE = form.findField('TEMPLATE').getValue(); sql = sql + getAndConSql(sql, TEMPLATE, " (TEMPLATE like '%" + TEMPLATE + "%') "); return sql; } });