diff --git a/App.vue b/App.vue index cf13387..e6fdbd1 100644 --- a/App.vue +++ b/App.vue @@ -54,7 +54,8 @@ console.log('App Hide') }, globalData: { - baseUrl: 'http://27.223.104.50:8001',//接口前缀 + // baseUrl: 'http://27.223.104.50:8001',//接口前缀 + baseUrl: 'http://jtxx.qdjtcx.cn:8001',//接口前缀 mobile: '66007587' }, methods: { diff --git a/common/util.js b/common/util.js index fc10555..3e79f7b 100644 --- a/common/util.js +++ b/common/util.js @@ -107,7 +107,7 @@ function calcMom(cur, data) { } // 计算同比 function calcYoy(cur, data) { - console.log(cur,"同比==========",data); + // console.log(cur,"同比==========",data); return !checkNotEmpty(cur) || !checkNotEmpty(data) ? '' : data === 0 && parseInt(cur) === 0 ? 0 : data === 0 && parseInt(cur) > 0 ? 100 : (parseInt(cur) - data) / data * 100; } diff --git a/pages/highWay/runData/form.vue b/pages/highWay/runData/form.vue index c58a9f4..bc594b6 100644 --- a/pages/highWay/runData/form.vue +++ b/pages/highWay/runData/form.vue @@ -21,21 +21,23 @@ 统计日期: - + {{form.statDate?form.statDate:'请选择时段'}} + {{form.statDate?form.statDate:''}} 统计时段: - + {{index>-1?array[index].dictLabel:'请选择时段'}} + {{index>-1?array[index].dictLabel:''}} @@ -46,13 +48,13 @@ + :class="checkNotEmpty(form.entranceVehicleCount) && form.entranceVehicleCount === yoyMomSumary.minusDaySummaryData.entranceVehicleCount ? 'danger' : ''"> + :style="checkNotEmpty(form.entranceVehicleCount) && form.entranceVehicleCount === yoyMomSumary.minusDaySummaryData.entranceVehicleCount ?'color: #EB4747':''"> 驶入车辆数统计环比 + :style="checkNotEmpty(form.entranceVehicleCount) && form.entranceVehicleCount === yoyMomSumary.minusDaySummaryData.entranceVehicleCount ?'color: #EB4747':''"> {{formatDigit(form.entranceVehicleCountMom)}}% @@ -72,13 +74,13 @@ + :class="checkNotEmpty(form.exitVehicleCount) && form.exitVehicleCount === yoyMomSumary.minusDaySummaryData.exitVehicleCount ? 'danger' : ''"> + :style="checkNotEmpty(form.exitVehicleCount) && form.exitVehicleCount === yoyMomSumary.minusDaySummaryData.exitVehicleCount ?'color: #EB4747':''"> 驶出车辆数统计环比 + :style="checkNotEmpty(form.exitVehicleCount) && form.exitVehicleCount === yoyMomSumary.minusDaySummaryData.exitVehicleCount ?'color: #EB4747':''"> {{formatDigit(form.exitVehicleCountMom)}}% @@ -262,6 +264,10 @@ index: 2, //时段选择,默认0-24 userInfo: {}, yoyMom: {}, //同比环比 + yoyMomSumary: { + minusDaySummaryData: {}, + minusYearSummaryData: {} + },//汇总统计同环比 showStaion: false, //展开收起 pageType: '', deptNameList: [], //当前登录人所在单位 @@ -279,10 +285,14 @@ this.pageType = 'add'; let now = new Date(); this.form.statDate = getDateStr(now, -1); //默认前一天 - this.queryStation('add'); + // this.queryStation('add'); this.queryTime(); //统计时段 + }else if(options.item) { + this.btnText = '修改并保存'; + let obj = JSON.parse(options.item); + this.queryDetailInfo2(obj.statDate, obj.statPeriod); } - if (options.id) { + else if (options.id) { this.btnText = '修改并保存'; this.queryDetailInfo(options.id); } @@ -319,20 +329,39 @@ this.queryStation(); }) }, + //日期和时段查询详情 + queryDetailInfo2(statDate, statPeriod) { + this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/getSubData?statDate=' + statDate + '&statPeriod=' + statPeriod, {}, + 'GET').then(res => { + res.data.statDate = statDate; + res.data.statPeriod = statPeriod; + this.form = res.data; + this.queryTime(); + this.queryStation(); + }) + }, //同比环比查询 queryYoYMom() { if (this.form.statDate && this.form.statPeriod) { + //汇总统计 this.$request(getApp().globalData.baseUrl + - '/api/biz/highwayParentDataController/getYoYAndMoM?statDate=' + this.form.statDate + + '/api/biz/highwayParentDataController/getSummaryDataYoYAndMoM?statDate=' + this.form.statDate + '&statPeriod=' + this.form.statPeriod + '&_t=' + Date.parse(new Date()), {}, "GET").then( res => { - this.yoyMom = res.data; - //如果重新更改填报日期,重新计算同比环比 - if (this.highwaySubDataList.length > 0 && this.form.highwaySubDataList.length > 0) { - this.highwaySubDataList.map((item, index) => { - this.checkStationInfo(index); + this.yoyMomSumary = res.data; + //各收费站同环比查询 + this.$request(getApp().globalData.baseUrl + + '/api/biz/highwayParentDataController/getYoYAndMoM?statDate=' + this.form.statDate + + '&statPeriod=' + this.form.statPeriod + '&_t=' + Date.parse(new Date()), {}, "GET").then( + res2 => { + this.yoyMom = res2.data; + //如果重新更改填报日期,重新计算同比环比 + if (this.highwaySubDataList.length > 0 && this.form.highwaySubDataList.length > 0) { + this.highwaySubDataList.map((item, index) => { + this.checkStationInfo(index); + }) + } }) - } }) } }, @@ -377,8 +406,8 @@ }, //计算收费站信息是否填写完整 checkStationInfo(index) { - this.highwaySubDataList[index].isFinish = this.form.highwaySubDataList[index].entranceVehicleCount != '' && - this.form.highwaySubDataList[index].exitVehicleCount != ''; + this.highwaySubDataList[index].isFinish = checkNotEmpty(this.form.highwaySubDataList[index].entranceVehicleCount) && + checkNotEmpty(this.form.highwaySubDataList[index].exitVehicleCount); //统计计算 let entranceVehicleCount = 0, exitVehicleCount = 0; @@ -391,19 +420,17 @@ }) this.form.entranceVehicleCount = entranceVehicleCount; this.form.exitVehicleCount = exitVehicleCount; - //环比计算规则 if今天没有值不计算,elseif昨天没有值不计算,elseif昨天===0并且今天===0百分比0,esleif昨天0今天大于0百分比100,else(今天-昨天)/昨天*100 //收费站驶入车辆数统计 - this.form.entranceVehicleCountMom = this.$calcMom(this.form.entranceVehicleCount,this.yoyMom.minusDaysEntranceVehicleSum); - this.form.entranceVehicleCountYoy = this.$calcYoy(this.form.entranceVehicleCount, this.yoyMom.minusYearsEntranceVehicleSum); + this.form.entranceVehicleCountMom = this.$calcMom(this.form.entranceVehicleCount,this.yoyMomSumary.minusDaySummaryData.entranceVehicleCount); + this.form.entranceVehicleCountYoy = this.$calcYoy(this.form.entranceVehicleCount, this.yoyMomSumary.minusYearSummaryData.entranceVehicleCount); //收费站驶出车辆数统计 - this.form.exitVehicleCountMom = this.$calcMom(this.form.exitVehicleCount, this.yoyMom.minusDaysExitVehicleSum); + this.form.exitVehicleCountMom = this.$calcMom(this.form.exitVehicleCount, this.yoyMomSumary.minusDaySummaryData.exitVehicleCount); - this.form.exitVehicleCountYoy = this.$calcYoy(this.form.exitVehicleCount, this.yoyMom.minusYearsExitVehicleSum); + this.form.exitVehicleCountYoy = this.$calcYoy(this.form.exitVehicleCount, this.yoyMomSumary.minusYearSummaryData.exitVehicleCount); //收费站子表计算同比环比 - // if(this.form.highwaySubDataList[index].entranceVehicleCount != '' || this.form.highwaySubDataList[index].exitVehicleCount != ''){ let idx = this.yoyMom.minusDaysList.findIndex(item => { return item.tollStationName == this.form.highwaySubDataList[index].tollStationName; }); @@ -478,8 +505,7 @@ .stationName; }); if (idx > -1) { - item.isFinish = arr[idx].entranceVehicleCount != '' && arr[idx] - .exitVehicleCount != '' ? true : false; + item.isFinish = checkNotEmpty(arr[idx].entranceVehicleCount) && checkNotEmpty(arr[idx].exitVehicleCount) ? true : false; this.form.highwaySubDataList.push(arr[idx]); } else { item.isFinish = false; @@ -515,18 +541,42 @@ //选择统计日期 bindDateChange(e) { this.form.statDate = e.detail.value; - this.queryYoYMom(); + if(this.pageType == 'add') { + this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/getSubData?statDate=' + this.form.statDate + '&statPeriod=' + this.form.statPeriod, {}, + 'GET').then(res => { + res.data.statDate = this.form.statDate; + res.data.statPeriod = this.form.statPeriod; + this.form = res.data; + this.queryStation(); + this.queryYoYMom(); + }) + } + else { + this.queryYoYMom(); + } }, //统计时段切换 changeStatPeriod(e) { this.index = e.detail.value; this.form.statPeriod = this.array[e.detail.value].dictValue; - console.log('change 时段') - this.queryYoYMom(); + console.log('change 时段') + if(this.pageType == 'add') { + this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/getSubData?statDate=' + this.form.statDate + '&statPeriod=' + this.form.statPeriod, {}, + 'GET').then(res => { + res.data.statDate = this.form.statDate; + res.data.statPeriod = this.form.statPeriod; + this.form = res.data; + this.queryStation(); + this.queryYoYMom(); + }) + } + else { + this.queryYoYMom(); + } }, //时段 queryTime() { - this.$request(getApp().globalData.baseUrl + '/api/dict/dictList?dictType=airport_time' + '&_t=' + Date + this.$request(getApp().globalData.baseUrl + '/api/dict/dictList?dictType=highway_time' + '&_t=' + Date .parse( new Date()), {}, 'GET').then(res => { this.array = res.data; @@ -539,11 +589,28 @@ this.form.statPeriod = '0012'; let idx = this.array.findIndex(item => item.dictValue == '0012'); this.index = idx > -1 ? idx : ''; + if(idx > -1) { + this.index = idx; + }else { + //字典值没有0-12 默认0-24 + this.form.statPeriod = '03'; //默认0-24 + let _idx = this.array.findIndex(item => item.dictValue == '03'); + this.index = _idx > -1 ? _idx : ''; + } } else { this.form.statPeriod = '03'; //默认0-24 let idx = this.array.findIndex(item => item.dictValue == '03'); this.index = idx > -1 ? idx : ''; } + //报送阶段 - 初始化汇总数据 + this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/getSubData?statDate=' + this.form.statDate + '&statPeriod=' + this.form.statPeriod, {}, + 'GET').then(res => { + res.data.statDate = this.form.statDate; + res.data.statPeriod = this.form.statPeriod; + this.form = res.data; + console.log('add == queryTime', this.form) + this.queryStation(); + }) } else { let idx = this.array.findIndex(item => item.dictValue == this.form.statPeriod); this.index = idx > -1 ? idx : ''; @@ -575,7 +642,7 @@ } uni.showModal({ title: '提示', - content: this.form.id == undefined ? '您确认提交该条报送数据?' : '您确认将该条数据进行修改?', + content: this.pageType == 'add' ? '您确认提交该条报送数据?' : '您确认将该条数据进行修改?', success: (res) => { if (res.confirm) { this.submitForm(); @@ -588,7 +655,7 @@ title: '提交中...', mask: true }) - this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/saveOrUpdate', this + this.$request(getApp().globalData.baseUrl + '/api/biz/highwayParentDataController/saveOrUpdateV2', this .form, 'POST').then(res => { uni.hideLoading(); diff --git a/pages/highWay/runData/list.vue b/pages/highWay/runData/list.vue index d6dc7c4..ce96f42 100644 --- a/pages/highWay/runData/list.vue +++ b/pages/highWay/runData/list.vue @@ -1,10 +1,10 @@