Ext.namespace('DsTruck'); DsTruck.approvalIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.approvalIndex.superclass.constructor.call(this); }; Ext.extend(DsTruck.approvalIndex, Ext.Panel, { PageSize: 500, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { this.storeList = Ext.create('Ext.data.Store', { model: 'approvalmb', remoteSort: true, pageSize: this.PageSize, proxy: { type: 'ajax', url: '/Import/approval/GetDataList', reader: { id: 'id', root: 'data', totalProperty: 'totalCount' } } }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.formname = "Approval"; //#region 定义Grid this.column = [{ sortable: true, id: '', dataIndex: 'companyname', header: '用证公司', width: 80 }, { sortable: true, id: '', dataIndex: 'portRef', header: '受理机构', width: 80 }, { sortable: true, id: '', dataIndex: 'SLJG', header: '受理机构id', hidden: true, width: 80 }, { sortable: true, id: '', dataIndex: 'Country', header: '进口国', width: 80 }, { sortable: true, id: '', dataIndex: 'portRef', header: '目的港', width: 80 }, { sortable: true, id: '', dataIndex: 'SQDH', header: '申请单号', width: 80 }, { sortable: true, id: '', dataIndex: 'APPNO', header: '许可证号', width: 80 }, { sortable: true, id: '', dataIndex: 'AppName', header: '商品名称', width: 80 }, { sortable: true, id: '', dataIndex: 'SPECIFICATIONS', header: '商品规格', width: 80 }, { sortable: true, id: '', dataIndex: 'Weight', header: '额度(吨)', width: 80 }, { sortable: true, id: '', dataIndex: 'remain', header: '未核销额度(吨)', width: 80 }, { sortable: true, id: '', dataIndex: 'canbeused', header: '未核销且未配证额度(吨)', width: 100 }, { sortable: true, id: '', dataIndex: 'used', header: '已核销重量(吨)', width: 80 }, { sortable: true, id: '', dataIndex: 'selected', header: '已配证未核销重量(吨)', width: 100 }, { sortable: true, id: '', dataIndex: 'ValidDate', header: '有效期', width: 80 }, { sortable: true, id: '', dataIndex: 'code', header: 'HS代码', width: 100 }, { sortable: true, id: '', dataIndex: 'name', header: 'HS名称', width: 100 }, { sortable: true, id: '', dataIndex: 'ciqcode', header: 'CIQ代码', width: 100 }, { sortable: true, id: '', dataIndex: 'ciqname', header: 'CIQ名称', width: 100 }, { sortable: true, id: '', dataIndex: 'REMARK', header: '备注', width: 100 }]; this.Pagenum = Ext.create('Ext.form.field.Number', { name: 'bottles', fieldLabel: '每页记录数', labelAlign: 'right', value: this.PageSize, maxValue: 100000, width: 180, minValue: 0, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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: "没有数据" }), this.Pagenum] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/Import/approval/Edit'); }, this); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(GID, this.formname, this.column); this.column.unshift(new Ext.grid.RowNumberer()); this.gridList.reconfigure(this.storeList, this.column); //////////////////////////// //#endregion //搜索条件模块 //#region formSearch //表参照 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', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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', value: '0', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); 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: 'port', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); var _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.comboxCompany , this.comboxCountry, { fieldLabel: '许可证号', name: 'APPNO', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '备注', name: 'REMARK', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } } ] } ]//end items(fieldset 1) }, //end fieldset 1 {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxport, { fieldLabel: '商品名称', name: 'AppName', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '业务编号', name: 'BSNO', listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxstop/*, { fieldLabel: '从 数量(吨)', name: 'Weight_min' }, { fieldLabel: '到 数量(吨)', name: 'Weight_max' }*/ ] } ]//end items(fieldset 2) }, //end fieldset 2 {//fieldset 3 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [/*{ fieldLabel: '从有效期', format: 'Y-m-d', xtype: 'datefield', name: 'ValidDate_min' }, { fieldLabel: '到有效期', format: 'Y-m-d', xtype: 'datefield', name: 'ValidDate_max' }, this.comboxstop*/ ] } ]//end items(fieldset 3) }//end fieldset 3 ]//end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin("/Import/approval/Edit"); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onResetClick(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", handler: function (button, event) { //this.column = DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, false); var tempcolumns = this.gridList.columns; DsTruck.SaveGridPanel(GID, this.formname, tempcolumns, this.column, 1, false); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 100, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.PageSize = this.Pagenum.getValue(); this.storeList.pageSize = this.PageSize; this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, 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: '/Import/approval/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 onResetClick: function (button, event) { this.formSearch.getForm().reset(); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var APPNO = form.findField('APPNO').getValue(); sql = sql + getAndConSql(sql, APPNO, "a.APPNO like '%" + APPNO + "%'"); var company = form.findField('company').getValue(); sql = sql + getAndConSql(sql, company, "a.company = '" + company + "'"); var Countryid = form.findField('Countryid').getValue(); sql = sql + getAndConSql(sql, Countryid, "a.Countryid like '%" + Countryid + "%'"); var port = form.findField('port').getValue(); sql = sql + getAndConSql(sql, port, "a.SLJG = " + port); var BSNO = form.findField('BSNO').getValue(); sql = sql + getAndConSql(sql, BSNO, "a.id in(select app_id from Import_appstate where contractno in(select bsno from v_op_bs where custno like '%" + BSNO + "%' or MBLNO like '%" + BSNO + "%' or HBLNO like '%" + BSNO + "%'))"); var AppName = form.findField('AppName').getValue(); sql = sql + getAndConSql(sql, AppName, "a.AppName like '%" + AppName + "%'"); var isdeleted = form.findField('isdeleted').getValue(); sql = sql + getAndConSql(sql, isdeleted, "a.isdeleted = " + isdeleted + ""); var REMARK = form.findField('REMARK').getValue(); sql = sql + getAndConSql(sql, REMARK, "a.REMARK like '%" + REMARK + "%'"); //isdeleted return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } // alert(this.OprationStatus.ToString()); // alert(this.storeList.toString()); // alert(this.SelectedRecord.toString()); });