Ext.namespace('Shipping'); Shipping.MsOpApplyServiceIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsOpApplyServiceIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsOpApplyServiceIndex, Ext.Panel, { PageSize: 30, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storecodeservice = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeOpService', proxy: { url: '/MvcShipping/MsCodeOpService/GetDataList' } }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpApplyService', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpApplyService/GetDataViewList', reader: { id: 'BsNo', root: 'data', totalProperty: 'totalCount' } } }); this.girdcolums = [{ sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 150 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 120 }, { sortable: true, dataIndex: 'CUSTOMNO', header: '报关单号', width: 120 }, { sortable: true, dataIndex: 'BSDATE', header: '录入日期', width: 80 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 80 }, { sortable: true, dataIndex: 'MBLNO', header: '提单号', width: 80 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 80 }, { sortable: true, dataIndex: 'SERVICETYPE', header: '服务项目', width: 80 }, { sortable: true, dataIndex: 'STATUS', header: '服务状态', width: 80 }, { sortable: true, dataIndex: 'OP', header: '服务操作员', width: 80 }, { sortable: true, dataIndex: 'STARTDATETIME', header: '开始时间', width: 80 }, { sortable: true, dataIndex: 'PLANENDTIME', header: '计划完成时间', width: 80 }, { sortable: true, dataIndex: 'ENDDATETIME', header: '完成时间', width: 80 }, { sortable: true, dataIndex: 'ENDOP', header: '完成人', width: 80 }, { sortable: true, dataIndex: 'BSTYPE', header: '业务类型', hidden: true, width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: '船名', width: 100 }, { sortable: true, dataIndex: 'VOYNO', header: '航次', width: 40 }, { sortable: true, dataIndex: 'ETD', header: '开船日期', width: 60 }, { sortable: true, dataIndex: 'ETA', header: '到港日期', width: 60 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 80 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 80 }, { sortable: true, dataIndex: 'AOP', header: '业务操作', width: 80 }, { sortable: true, dataIndex: 'SALE', header: '销售', width: 80 }, { sortable: true, dataIndex: 'CUSTOMSER', header: '报关行', width: 80 }, { sortable: true, dataIndex: 'BSSOURCE', header: '业务来源', width: 100 }, { sortable: true, dataIndex: 'BSSOURCEDETAIL', header: '来源明细', width: 80 }, { sortable: true, dataIndex: 'CUSTOMDATE', header: '报关日期', width: 100 }, { sortable: true, dataIndex: 'INSPECTIONNO', header: '商检单号', width: 100 }, { sortable: true, dataIndex: 'INSPECTIONDATE', header: '商检日期', hidden: true, width: 80 }, { sortable: true, dataIndex: 'INVNO', header: '发票号', width: 80 }, { sortable: true, dataIndex: 'CONTRACTNO', header: '合同号', width: 160 }, { sortable: true, dataIndex: 'ARCOUNTRY', header: '货源国别', width: 80 }, { sortable: true, dataIndex: 'GOODSOURCE', header: '货源地', width: 80 }, { sortable: true, dataIndex: 'DOCNO', header: '批准文号', width: 80 }, { sortable: true, dataIndex: 'TRADETYPE', header: '贸易方式', width: 80 }, { sortable: true, dataIndex: 'BSSTATUS', header: '业务锁定', width: 100 }, { sortable: true, dataIndex: 'FEESTATUS', header: '费用锁定', width: 100 } ]; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, viewConfig: { autoFill: true, getRowClass: function (record, rowIndex, rowParams, store) { var Status = record.get('STATUS'); var plandate = record.get('PLANENDTIME'); if (Status == '未完成') { var myDate = new Date(); var mytime = myDate.toLocaleTimeString(); if (mytime > plandate) { return 'feestatus_nopass'; } } } }, columns: this.girdcolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsOpApplyService/Edit'); }, this); //#region formSearch //#region formSearch枚举参照相关 //#endregion this.storecodeservice = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeOpService', proxy: { url: '/MvcShipping/MsCodeOpService/GetDataList' } }); this.storecodeservice.load({ params: { condition: "OPTYPE='5'"} }); this.comboxBsType = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '服务项目', store: this.storecodeservice, valueField: 'OPField', displayField: 'SERVICENAME', name: 'SERVICE' }); this.StoreStatus = Ext.create('Ext.data.Store', { fields: ['STATUS'] }); this.StoreStatus.add({ "STATUS": "未完成" }); this.StoreStatus.add({ "STATUS": "已完成" }); this.comboxStatus = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '服务状态', store: this.StoreStatus, valueField: 'STATUS', displayField: 'STATUS', name: 'STATUS' }); 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: [{ fieldLabel: '委托编号', name: 'BsNo' }, { fieldLabel: '报关单号', name: 'CustomNo' }, { fieldLabel: '从报关日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateBgn' }, { fieldLabel: '到报关日期', format: 'Y-m-d', xtype: 'datefield', name: 'ExpDateEnd' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxBsType, this.comboxStatus, { fieldLabel: '提单号', name: 'MblNo' }, { fieldLabel: '委托单位', name: 'CustName' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ /* { text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/MvcShipping/MsOpApplyService/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) { }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 110, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.InitGrid(); this.onRefreshClick(); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents InitGrid: function () { }, onRefreshClick: function (button, event) { // var girdcolums = this.gridList.getColumnMode(); var sql = this.getCondition(); 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]; if (record.data.BSSTATUS == '1') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } if (record.data.FEESTATUS == '1') { Ext.Msg.show({ title: '警告', msg: '费用已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpApply/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 getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var billNo = form.findField('BsNo').getValue(); sql = sql + getAndConSql(sql, billNo, "s.BsNo like '%" + billNo + "%'"); var customNo = form.findField('CustomNo').getValue(); sql = sql + getAndConSql(sql, customNo, "A.CUSTOMNO like '%" + customNo + "%'"); var BsType = form.findField('SERVICE').getValue(); sql = sql + getAndConSql(sql, BsType, "S.OPField= '" + BsType + "'"); var BsStatus = form.findField('STATUS').getValue(); sql = sql + getAndConSql(sql, BsStatus, "S.STATUS= '" + BsStatus + "'"); var MblNo = form.findField('MblNo').getValue(); sql = sql + getAndConSql(sql, MblNo, "A.MblNo like '%" + MblNo + "%'"); var custName = form.findField('CustName').getValue(); sql = sql + getAndConSql(sql, custName, "A.CUSTOMERNAME like '%" + custName + "%'"); var expDateBgn = form.findField('ExpDateBgn').getRawValue(); sql = sql + getAndConSql(sql, expDateBgn, "A.CUSTOMDATE >='" + expDateBgn + "'"); var expDateEnd = form.findField('ExpDateEnd').getRawValue(); sql = sql + getAndConSql(sql, expDateEnd, "A.CUSTOMDATE <='" + expDateEnd + "'"); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });