var hitColumn; var accdatebgn = ""; var accdateend = ""; Ext.namespace('Shipping'); Shipping.MsRptOpProfitYearCompareIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsRptOpProfitYearCompareIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsRptOpProfitYearCompareIndex, Ext.Panel, { PageSize: 2000, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '1=2', bslistsortfield: '', bslistsortdire: '', salelistsortfield: '', salelistsortdire: '', custlistsortfield: '', custlistsortdire: '', oplistsortfield: '', oplistsortdire: '', bssourcelistsortfield: '', bssourcelistsortdire: '', bssourcedetaillistsortfield: '', bssourcedetaillistsortdire: '', isloadover: false, initUIComponents: function () { Ext.Ajax.timeout = 120000; this.formname = 'MsRptOpProfitYearCompareIndex'; this.isquery = false; //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, fields: [ { name: 'MONTHNAME', type: 'string' }, { name: 'ZL1', type: 'number' } ], remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsRptOpProfitCompare/SumYearListData', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); Ext.define('Ext.grid.column.Actiontextcolumn', { extend: 'Ext.grid.column.Column', alias: ['widget.actiontextcolumn'], defaultRenderer: function (value) { var me = this; prefix = Ext.baseCSSPrefix; scope = me.origScope || me; // if (value == "") { // } // else value = value + ''; // value = ''; return value; }, processEvent: function (type, view, cell, recordIndex, cellIndex, e, record, row) { var me = this; if (type == 'click') { me.handler.call(me.scope || me.origScope || me, view, recordIndex, cellIndex, e, record, row); } } }); //定义Grid this.initgirdcolums = [{ sortable: true, dataIndex: 'MONTHNAME', header: '月份', width: 110 }, { sortable: true, dataIndex: 'MONTHNUM', header: '数据', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, align: 'right', width: 120 } ]; // this.girdcolums = this.initgirdcolums; this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname + 'bs', this.initgirdcolums, 1); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, features: [{ ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性 }], columns: this.girdcolums, // listeners:{ // 'itemclick':function(view,record,item,index,e){ // var rec = view.getStore().getAt(index); // alert(rec.get('MONTHNAME')); // } // }, // 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 + 'bs', this.girdcolums, 1); // this.gridList.reconfigure(this.storeList, this.girdcolums); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; var month = record.data.MONTHNAME; }, this); _this = this; this.piechart = Ext.create('Ext.chart.Chart', { id: 'chartCmp', xtype: 'chart', style: 'background:#fff', animate: true, shadow: true, store: this.storeList, axes: [{ type: 'Numeric', position: 'left', fields: ['ZL1'], label: { renderer: Ext.util.Format.numberRenderer('0,0') }, title: '数据', grid: true, minimum: 0 }, { type: 'Category', position: 'bottom', fields: ['MONTHNAME'], title: '年度月份' }], series: [{ type: 'column', axis: 'left', highlight: true, tips: { trackMouse: true, width: 140, height: 28, renderer: function (storeItem, item) { this.setTitle(storeItem.get('MONTHNAME') + ': ' + storeItem.get('ZL1')); } }, label: { display: 'insideEnd', 'text-anchor': 'middle', field: 'ZL1', renderer: Ext.util.Format.numberRenderer('0.00'), orientation: 'vertical', color: '#333' }, xField: 'MONTHNAME', yField: 'ZL1' }] }); //#region formSearch //#region formSearch枚举参照相关 _this = this; this.StoreOpLb = Ext.create('DsExt.ux.RefEnumStore', {}); this.StoreOpLb.load({ params: { enumTypeId: 96005} }); this.comboxOpLb = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxOpLbID', fieldLabel: '业务类型', store: this.StoreOpLb, forceSelection: true, name: 'PS_OPLB', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeBsType.load({ params: { enumTypeId: 96004} }); this.comboxBsType = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxBsTypeID', fieldLabel: '运输类型', store: this.storeBsType, name: 'PS_BSTYPE', valueField: 'EnumValueName', displayField: 'EnumValueName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeSalesCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeSalesCode.load(); this.comboxSalesCode = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxSalesCodeID', fieldLabel: '揽货人', store: this.storeSalesCode, forceSelection: true, name: 'PS_SALE', valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.comboxOp = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '操 作', store: this.storeSalesCode, forceSelection: true, name: 'PS_OP', valueField: 'UserName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} }); this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxCustCodeID', fieldLabel: '委托单位', store: this.storeCustCode, forceSelection: true, name: 'PS_CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //业务来源 this.storeSource = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.SourceModel', proxy: { url: '/CommMng/BasicDataRef/GetSource' } }); this.storeSource.load(); this.storeSourceDetail = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.SourceDetailModel', proxy: { url: '/CommMng/BasicDataRef/GetSourceDetail2' } }); this.comboxBSSOURCE = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxBSSOURCEID', fieldLabel: '业务来源', store: this.storeSource, forceSelection: true, name: 'BSSOURCE', valueField: 'SourceName', displayField: 'SourceName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeSource, 'SourceID', records[0].data.SourceID); if (recs.getCount() > 0) { var data = recs.getAt(0).data; var s = "SOURCEID='" + data.SourceID + "'"; this.storeSourceDetail.load({ params: { condition: s} }); } else { var BSSOURCEDETAIL = this.formSearch.getForm().findField('BSSOURCEDETAIL'); BSSOURCEDETAIL.setValue(''); } } } } }); this.storeSourceDetail.load(); this.comboxBSSOURCEDETAIL = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '贸易条款', store: this.storeSourceDetail, forceSelection: true, name: 'BSSOURCEDETAIL', valueField: 'SourceDetail', displayField: 'SourceDetail', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.storeLANE = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.Lane', proxy: { url: '/CommMng/BasicDataRef/GetCodeLaneList' } }); this.storeLANE.load(); this.comboxLANE = Ext.create('DsExt.ux.RefTableCombox', { id: 'comboxLANEID', fieldLabel: '航线', store: this.storeLANE, // forceSelection: true, name: 'LANE', valueField: 'LANE', displayField: 'LANE', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); Ext.define('SubComp', { extend: 'Ext.data.Model', fields: [ { name: 'GID', type: 'string' }, { name: 'NAME', type: 'string' }, { name: 'ENNAME', type: 'string' } ] }); this.StoreSubComp = Ext.create('DsExt.ux.RefTableStore', { model: 'SubComp', proxy: { url: '/MvcShipping/MsBaseInfo/GetCompanyEN' } }); this.StoreSubComp.load({ params: { condition: ""} }); this.comboxSubComp = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '所属公司', store: this.StoreSubComp, name: 'SUBCOMP', valueField: 'GID', displayField: 'NAME', enableKeyEvents: true, listeners: { keyup: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.StoreYear = Ext.create('Ext.data.Store', { fields: ['OpLb'] }); this.StoreYear.add({ "OpLb": "2015" }); this.StoreYear.add({ "OpLb": "2016" }); this.StoreYear.add({ "OpLb": "2017" }); this.StoreYear.add({ "OpLb": "2018" }); this.StoreYear.add({ "OpLb": "2019" }); this.StoreYear.add({ "OpLb": "2020" }); this.StoreYear.add({ "OpLb": "2021" }); this.StoreYear.add({ "OpLb": "2022" }); this.StoreYear.add({ "OpLb": "2023" }); this.StoreYear.add({ "OpLb": "2024" }); this.StoreYear.add({ "OpLb": "2025" }); this.comboxYearFrm = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '对比年度从', store: this.StoreYear, forceSelection: true, name: 'FrmYear', valueField: 'OpLb', displayField: 'OpLb' }); this.comboxYearTo = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '对比年度至', store: this.StoreYear, forceSelection: true, name: 'ToYear', valueField: 'OpLb', displayField: 'OpLb' }); this.StoreCompareType = Ext.create('Ext.data.Store', { fields: ['OpLb'] }); this.StoreCompareType.add({ "OpLb": "会计期间" }); this.StoreCompareType.add({ "OpLb": "业务日期" }); this.comboxCompareType = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '期间类型', store: this.StoreCompareType, forceSelection: true, name: 'COMTYPE', value:'业务日期', valueField: 'OpLb', displayField: 'OpLb' }); //客户加载_船公司 this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' } }); //船公司 this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '船公司', //'船公司', store: this.storeCARRIER, forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'CARRIER', valueField: 'CustName', displayField: 'CodeAndName' }); //#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: [ { xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', flex: 1, defaultType: 'textfield', items: [this.comboxYearFrm, this.comboxYearTo, this.comboxCompareType, { xtype: 'radiogroup', fieldLabel: '分析内容', id: 'rdOBJNUM', columns: 5, flex: 2, vertical: true, items: [ { id: 'rdoGain', boxLabel: '利润', name: 'OBJNUM', inputValue: '利润', checked: true }, { id: 'rdoArrearage', boxLabel: '欠费', name: 'OBJNUM', inputValue: '欠费' }, { id: 'rdoTeu', boxLabel: 'TEU', name: 'OBJNUM', inputValue: 'TEU' }, { id: 'rdoKgs', boxLabel: '毛重', name: 'OBJNUM', inputValue: '毛重' }, { id: 'rdoNetW', boxLabel: '计费重', name: 'OBJNUM', inputValue: '计费重' } ], listeners: { change: function (rd, newValue, oldValue, eOpts) { if (_this.isquery) _this.onRefreshClick(); } } }, this.comboxSubComp ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxOpLb, this.comboxCARRIER, this.comboxSalesCode, this.comboxCustCode, this.comboxBSSOURCE, this.comboxLANE ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //#endregion formSearch //查询工具条 this.CheckSaveQuery = new Ext.form.Checkbox({ fieldLabel: '记忆查询条件', checked: true, width: 120 }); _this = this; this.SearchBtn = new Ext.Button({ text: '隐藏查询', handler: function () { if (_this.SearchBtn.text == '隐藏查询') { _this.panelSearch.hide(); _this.SearchBtn.setText("显示查询"); } else { _this.panelSearch.show(); _this.SearchBtn.setText("隐藏查询"); } } }); this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); var isvisible = true; var issavevalue = false; if (_this.SearchBtn.text == '隐藏查询') isvisible = true else isvisible = false; if (this.CheckSaveQuery.checked) issavevalue = true saveQuerySetting(this.formname, this.formSearch, isvisible, issavevalue); }, scope: this }, '-', this.SearchBtn, { xtype: 'button', width: 90, text: "清空条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, this.CheckSaveQuery ] }); LoadQueryData(this.formname, this.formSearch, this.CheckSaveQuery); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 29, items: [this.panelBtn] }); this.panelSearch = new Ext.Panel({ layout: "border", region: "north", height: 96, items: [this.formSearch] }); this.panelBodyChFee = new Ext.Panel({ title: '明细数据', layout: "border", region: 'south', height: 238, margin: '0 0', frame: true, split: true, collapsible: true, items: [this.gridList] }); this.panelchart = new Ext.Panel({ title: '图表', layout: "border", region: 'center', margin: '0 0', frame: true, items: [this.piechart] }); this.panelBody = new Ext.Panel({ layout: "border", region: 'center', margin: '0 0', frame: true, items: [this.panelchart, this.panelBodyChFee] }); // this.tabpanel = new Ext.TabPanel // ({ // activeTab: 0, // autoWidth: true, // border: false, // frame: false, // region: 'center', // id: "TabPanelID", // enableTabScroll: true, // items: // [ // // ] // }); Ext.apply(this, { items: [this.panelTop, this.panelSearch, this.panelBody] }); this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); }, //end initUIComponents InitGrid: function (condition, objname, sumfieldtype, startdate, enddate) { _this = this; var zlcolumn = [{ sortable: true, dataIndex: 'MONTHNAME', header: '月份', width: 110 }]; var myfield = [{ name: 'MONTHNAME', type: 'string'}]; var charfield = []; var aseries = []; this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, fields: [ { name: 'MONTHNAME', type: 'string' }, { name: 'MONTHNUM', type: 'number' } ], remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsRptOpProfitCompare/SumYearListData', reader: { id: '', root: 'data', totalProperty: 'totalCount' } } }); var storeMonthData = Ext.create('DsExt.ux.RefTableStore', { fields: [ { name: 'MONTHNAME', type: 'string' }, { name: 'MONTHNO', type: 'number' }, { name: 'MONTHFIELDNAME', type: 'string' } ], proxy: { url: '/MvcShipping/MsRptOpProfitCompare/GetObjYearListData' } }); _this = this; for (i = parseInt(startdate); i <= parseInt(enddate); i += 1) { myfield.push({ name: 'Z' + i.toString(), type: 'number' }); zlcolumn.push({ dataIndex: 'Z' + i.toString(), header: i.toString() + '年', renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; }, summaryType: 'sum', summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 2, '', true); return value; }, align: 'right', width: 80 } ); var cfield = 'Z' + i.toString(); charfield.push(cfield); aseries.push({ type: 'line', highlight: { size: 7, radius: 7 }, axis: 'left', smooth: true, fill: true, xField: 'MONTHNAME', yField: 'Z' + i.toString(), listeners: { itemmouseup: function (item) { // alert(item.value[1]); }, itemclick: function () { //alert(item.value[1]); //Ext.getCmp('chartControl').getValue(); //get("MONTHNAME"); } }, tips: { trackMouse: true, width: 80, height: 40, renderer: function (storeItem, item) { this.setTitle(item.value[1]); // this.update(item.value[1]); } }, markerConfig: { type: 'circle', size: 4, radius: 4, 'stroke-width': 0 } }); Ext.define('summodel', { extend: 'Ext.data.Model', fields: myfield }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'summodel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsRptOpProfitCompare/SumYearListData', reader: { root: 'data', totalProperty: 'totalCount' } } }); this.gridList.reconfigure(this.storeList, zlcolumn); this.storeList.load({ params: { start: 0, limit: this.PageSize, condition: condition, objname: objname, sumfieldtype: sumfieldtype, startyear: startdate, endyear: enddate }, waitMsg: "正在查询数据...", scope: this }); var chart = Ext.create('Ext.chart.Chart', { id: 'chartControl', xtype: 'chart', style: 'background:#fff', animate: true, store: this.storeList, shadow: true, theme: 'Category1', legend: { position: 'right' }, axes: [{ type: 'Numeric', minimum: 0, position: 'left', fields: charfield, title: '数据', minorTickSteps: 1, grid: { odd: { opacity: 1, fill: '#ddd', stroke: '#bbb', 'stroke-width': 0.5 } } }, { type: 'Category', position: 'bottom', fields: ['MONTHNAME'], title: '月份' }], series: aseries }); this.panelchart.removeAll(); this.panelchart.add(chart); this.panelchart.doLayout(); this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); } }, onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; this.isquery = true; var form = this.formSearch.getForm(); var rdOBJNUM = Ext.getCmp('rdOBJNUM'); var OBJNUM = rdOBJNUM.getValue(); var form = this.formSearch.getForm(); var expDate_Min = form.findField('FrmYear').getValue(); var expDate_Max = form.findField('ToYear').getValue(); if (expDate_Min == '' || expDate_Min == null || expDate_Min == undefined) { Ext.Msg.alert('提示', '开始年度不能为空!'); return; } if (expDate_Max == '' || expDate_Max == null || expDate_Max == undefined) { Ext.Msg.alert('提示', '结束年度不能为空!'); return; } var rdOBJNUM = Ext.getCmp('rdOBJNUM'); var OBJNAME = form.findField('COMTYPE').getValue(); var OBJNUM = rdOBJNUM.getValue(); var sql = this.getCondition(); this.sqlcontext = sql; this.InitGrid(sql, OBJNAME, OBJNUM, expDate_Min, expDate_Max); // this.storeList.load({ // params: { start: 0, limit: this.PageSize, condition: sql, sumfieldtype: OBJNUM, startmonth: expDate_Min, endmonth: expDate_Max }, // waitMsg: "正在查询数据...", // scope: this // }); }, getCondition: function () { var form = this.formSearch.getForm(); var sql = ''; var CUSTOMERNAME = form.findField('PS_CUSTOMERNAME').getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "B.CUSTOMERNAME='" + CUSTOMERNAME + "'"); var SALE = form.findField('PS_SALE').getValue(); sql = sql + getAndConSql(sql, SALE, "B.SALE='" + SALE + "'"); var SUBCOMP = form.findField('SUBCOMP').getValue(); sql = sql + getAndConSql(sql, SUBCOMP, "B.CORPID='" + SUBCOMP + "'"); var CARRIER = form.findField('CARRIER').getValue(); sql = sql + getAndConSql(sql, CARRIER, "B.CARRIER='" + CARRIER + "'"); var OPLB = form.findField('PS_OPLB').getValue(); sql = sql + getAndConSql(sql, OPLB, "B.OPLBNAME='" + OPLB + "'"); var BSSOURCE = form.findField('BSSOURCE').getValue(); sql = sql + getAndConSql(sql, BSSOURCE, "B.BSSOURCE='" + BSSOURCE + "'"); var LANE = form.findField('LANE').getValue(); sql = sql + getAndConSql(sql, LANE, "B.LANE='" + LANE + "'"); return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; ret[3] = this.SelectedRecord.data.BSNO; ret[4] = "MsRptOpProfitPerCentIndex"; return ret; } });