From 0ee16e9f5dd31c6c98df1a5fdcf081c8eb7f80df Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期二, 14 十一月 2023 13:15:55 +0800 Subject: [PATCH] 修改了获取风险值的请求接口 --- src/api/exceptionApi.js | 7 src/utils/risk_estimate_common_function/riskValue.js | 59 ++++ src/views/line_graph/SiteComprehensiveRskRanking.vue | 82 +++-- src/api/risk/riskApi.js | 24 + src/utils/risk_estimate_common_function/index.js | 296 ++++++++++---------- src/views/exception/FlightInspection.vue | 2 src/views/line_graph/DataRiskModel.vue | 46 ++- src/views/line_graph/DataRiskRank.vue | 282 +++++++++----------- src/views/data_management/HistoryData.vue | 2 9 files changed, 448 insertions(+), 352 deletions(-) diff --git a/src/api/exceptionApi.js b/src/api/exceptionApi.js index 104fbb3..cfc4c1f 100644 --- a/src/api/exceptionApi.js +++ b/src/api/exceptionApi.js @@ -18,6 +18,7 @@ } }) }, + // 鏍规嵁鏈堜唤鍜岀被鍨嬫煡鎵惧垎鏋愭暟鎹� analysisdataByType(month,type) { return $http.get('/dust/analysisdataByType', { @@ -27,6 +28,7 @@ } }) }, + // 鏍规嵁鏃舵鍜岀被鍨嬫煡鎵惧垎鏋愭暟鎹� analysisdataByTimeAndType(beginTime,endTime,type) { return $http.get('/dust/analysisdataByTimeAndType', { @@ -37,6 +39,8 @@ } }) }, + + /** * @@ -59,9 +63,6 @@ }, - - - getSitesNum() { return $http.get('/dust/sitename') diff --git a/src/api/risk/riskApi.js b/src/api/risk/riskApi.js new file mode 100644 index 0000000..0df350e --- /dev/null +++ b/src/api/risk/riskApi.js @@ -0,0 +1,24 @@ +import {$http} from '@/api/index.js'; + +export default{ + /** + * 鏍规嵁绔欑偣淇℃垨鏈堜唤锛岀被鍨� 鏌ヨ椋庨櫓鍊� + * @param锛� + * @returns锛� + */ + + + queryRiskValue(siteName,month,type){ + const params = { + month:month, + type:type, + } + + if(siteName != '' || siteName != null){ + params.siteName = siteName + } + + return $http.post('/dust/risk/riskValue',params) + }, +} + diff --git a/src/utils/risk_estimate_common_function/index.js b/src/utils/risk_estimate_common_function/index.js index bfcfb96..a6430d5 100644 --- a/src/utils/risk_estimate_common_function/index.js +++ b/src/utils/risk_estimate_common_function/index.js @@ -1,4 +1,4 @@ -import dayjs from 'dayjs'; +import dayjs from 'dayjs' // import exceptionApi from '../../api/exceptionApi'; export default { /** @@ -8,7 +8,7 @@ * @returns锛� */ getDaysDifference(startDate, endDate) { - return dayjs(endDate).diff(startDate, 'day') + 1; + return dayjs(endDate).diff(startDate, 'day') + 1 }, /** @@ -17,55 +17,52 @@ * @returns锛� */ calBillData(arr, beginTime, endTime) { - let min = 65536; - let max = -1; - let avg = 0; - let online = 0; - let valid = 0; - let exceeding = 0; + let min = 65536 + let max = -1 + let avg = 0 + let online = 0 + let valid = 0 + let exceeding = 0 - let sumAvg = 0; - let sumOnline = 0; - let sumValid = 0; - let sumExceeding = 0; + let sumAvg = 0 + let sumOnline = 0 + let sumValid = 0 + let sumExceeding = 0 // 璁$畻閫夋嫨鐨勬椂闂寸殑鐩稿樊鐨勫ぉ鏁� - let begin = dayjs(beginTime).format('YYYY-MM-DD'); - let end = dayjs(endTime).format('YYYY-MM-DD'); - let dayDiff = this.getDaysDifference(begin, end); - let obj = {}; + let begin = dayjs(beginTime).format('YYYY-MM-DD') + let end = dayjs(endTime).format('YYYY-MM-DD') + let dayDiff = this.getDaysDifference(begin, end) + let obj = {} // 璁$畻鏈�灏忓拰澶у�� arr.forEach((item) => { if (item.min < min) { - min = item.min; + min = item.min } if (item.max > max) { - max = item.max; + max = item.max } // 璁$畻骞冲潎鍊硷紝鍦ㄧ嚎鐜囷紝鏈夋晥鐜囷紝瓒呮爣鐜� - sumAvg = sumAvg + item.dayAvg; - sumOnline = sumOnline + Number(item.dayOnline.slice(0, -1)); - sumValid = sumValid + Number(item.dayValid.slice(0, -1)); - sumExceeding = sumExceeding + Number(item.dayExceeding.slice(0, -1)); - }); + sumAvg = sumAvg + item.dayAvg + sumOnline = sumOnline + Number(item.dayOnline.slice(0, -1)) + sumValid = sumValid + Number(item.dayValid.slice(0, -1)) + sumExceeding = sumExceeding + Number(item.dayExceeding.slice(0, -1)) + }) // 璁$畻鍧囧�� - avg = sumAvg / dayDiff; - online = sumOnline / dayDiff; - valid = sumValid / dayDiff; - exceeding = sumExceeding / dayDiff; - obj['min'] = min.toFixed(3); - obj['max'] = max.toFixed(3); + avg = sumAvg / dayDiff + online = sumOnline / dayDiff + valid = sumValid / dayDiff + exceeding = sumExceeding / dayDiff + obj['min'] = min.toFixed(3) + obj['max'] = max.toFixed(3) - obj['avg'] = avg.toFixed(2); - obj['online'] = online.toFixed(2); - obj['valid'] = valid.toFixed(2); - obj['exceeding'] = exceeding.toFixed(2); + obj['avg'] = avg.toFixed(2) + obj['online'] = online.toFixed(2) + obj['valid'] = valid.toFixed(2) + obj['exceeding'] = exceeding.toFixed(2) - return obj; + return obj }, - - - /** * 璁$畻寮傚父绫诲瀷鑱氶泦搴︼細璇ユ椂娈靛嚭鐜扮殑寮傚父绫诲瀷鏁伴噺闄�8 @@ -74,159 +71,165 @@ * @returns锛� */ calRecur(exceptionArr) { - if(exceptionArr.length == 0){ - let obj = {}; - obj['exceptionRecurrence'] = 0; - obj['exceptionTypeAggregation'] = 0; + if (exceptionArr.length == 0) { + let obj = {} + obj['exceptionRecurrence'] = 0 + obj['exceptionTypeAggregation'] = 0 - return obj; + return obj } - // 鍏稿瀷寮傚父澶嶇幇鐜� - let exceptionTyprRecurRate = 0; + // 閲忕骇绐佸彉 - let mutationCount = 0; + let mutationCount = 0 // 瓒呮爣涓磋繎 - let exceedingNearCount = 0; + let exceedingNearCount = 0 // 瓒呮爣娆℃暟涓寸晫 - let exceedingCriticalDegree = 0; + let exceedingCriticalDegree = 0 // 淇濆瓨鍑虹幇鐨勪笉鍚屽紓甯哥被鍨� - let exception = []; + let exception = [] // 寮傚父绫诲瀷鑱氶泦搴� - let exceptionTypeAggregation = 0; - + let exceptionTypeAggregation = 0 + // 鍏稿瀷寮傚父澶嶇幇鐜� + let exceptionTyprRecurRate = 0 + // 璁板綍鎸囧畾3绉嶅紓甯稿嚭鐜扮殑娆℃暟鍜屼笉鍚岀殑寮傚父绉嶇被 exceptionArr.forEach((item) => { - // 寮傚父澶嶇幇鐜� + // 閲忕骇绐佸彉寮傚父 if (item.exceptionType == 4) { - mutationCount++; + mutationCount++ + // 涓磋繎瓒呮爣寮傚父 } else if (item.exceptionType == 5) { - exceedingNearCount++; + exceedingNearCount++ + // 鍗曟棩瓒呮爣娆℃暟涓寸晫寮傚父 } else if (item.exceptionType == 6) { - exceedingCriticalDegree++; + exceedingCriticalDegree++ } // 寮傚父绫诲瀷鑱氶泦搴� if (exception.length == 0) { - exception.push(item.exceptionType); + exception.push(item.exceptionType) } // 淇濆瓨鏂扮殑寮傚父绫诲瀷 else if (exception.indexOf(item.exceptionType) == -1) { - exception.push(item.exceptionType); + exception.push(item.exceptionType) } - }); + }) - let sum = 0; + let sum = 0 // 娆℃暟鍑�1锛岃寮傚父鍑虹幇2娆★紝绠楀鐜�1娆°�傚嚭鐜�3娆★紝绠楀鐜�2娆�... if (mutationCount > 1) { - sum = sum + mutationCount - 1; + sum = sum + mutationCount - 1 } if (exceedingNearCount > 1) { - sum = sum + exceedingNearCount - 1; + sum = sum + exceedingNearCount - 1 } if (exceedingCriticalDegree > 1) { - sum = sum + exceedingCriticalDegree - 1; + sum = sum + exceedingCriticalDegree - 1 } switch (true) { - case (sum == 0 || sum == 1) : - exceptionTyprRecurRate = (sum / 3).toFixed(2); - break; - case (sum == 2|| sum >=3) : - exceptionTyprRecurRate = 1; - break; + case sum == 0 || sum == 1: + exceptionTyprRecurRate = (sum / 3).toFixed(2) + break + case sum == 2 || sum >= 3: + exceptionTyprRecurRate = 1 + break default: - return 'error'; + return 'error' } - exceptionTypeAggregation = (exception.length / 8).toFixed(2); + exceptionTypeAggregation = (exception.length / 8).toFixed(2) - let obj = {}; - obj['exceptionRecurrence'] = exceptionTyprRecurRate; - obj['exceptionTypeAggregation'] = exceptionTypeAggregation; + let obj = {} + obj['exceptionRecurrence'] = exceptionTyprRecurRate + obj['exceptionTypeAggregation'] = exceptionTypeAggregation - return obj; -}, -// 鍙傛暟锛氬璞℃暟缁�(璇ュ璞′腑鐨勫睘鎬т笉鑳芥槸寮曠敤绫诲瀷锛屽惁鍒欐嫹璐濈殑鍊艰繕鏄細鐩镐簰褰卞搷) - // 鍔熻兘锛氭嫹璐濊瀵硅薄鏁扮粍銆� -shallowCopyList(val) { - if(val == 'arr'){ - let tempList = []; - return tempList; - }else if(val == 'obj'){ - let tempList = {}; - return tempList; - } - -}, -getRate(obj){ - let a = {} - a.online = obj['dayOnline'] - a.valid = obj['dayValid'] - a.exceeding = obj['dayExceeding'] - return a -}, - -/** - * 鎵惧埌瀵硅薄鏁扮粍涓睘鎬nCode涓簐alue鐨勫璞� 娣诲姞杩涙暟缁勪腑 - * @param锛� 瀵硅薄鏁扮粍 锛宮nCode绛変簬value - * @returns锛� - */ -findValue(exceptionData,value){ - if(exceptionData.length==0){ - return [] - } - - let temp = [] - exceptionData.forEach((res)=>{ - if(res.mnCode == value){ - temp.push(res) + return obj + }, + // 鍙傛暟锛氬璞℃暟缁�(璇ュ璞′腑鐨勫睘鎬т笉鑳芥槸寮曠敤绫诲瀷锛屽惁鍒欐嫹璐濈殑鍊艰繕鏄細鐩镐簰褰卞搷) + // 鍔熻兘锛氭嫹璐濊瀵硅薄鏁扮粍銆� + shallowCopyList(val) { + if (val == 'arr') { + let tempList = [] + return tempList + } else if (val == 'obj') { + let tempList = {} + return tempList } - }) - return temp -}, + }, + getRate(obj) { + let a = {} + a.online = obj['dayOnline'] + a.valid = obj['dayValid'] + a.exceeding = obj['dayExceeding'] + return a + }, -/** - * 璁$畻椋庨櫓鍊� - * @param锛� 鏁扮粍銆備緷娆℃槸鍦ㄧ嚎鐜囷紝鏈夋晥鐜囷紝瓒呮爣鐜囷紝寮傚父绫诲瀷鑱氶泦搴︼紝寮傚父澶嶇幇鐜� - * @returns锛� - */ -calRiskValue(arr){ - // 鐢�100鍑� 鏄洜涓鸿灞炴�ч渶瑕佽绠楃殑鏄闄╁�硷紝搴斿綋鏄绾跨巼锛屾棤鏁堢巼 - // 涔樹互0.01鏄洜涓哄幓闄ょ櫨鍒嗗彿鍚庨渶瑕佸啀缂╁皬100鍊� - let weight = ( - (100 - parseFloat(arr[0].slice(0, -1)))*0.01 * 0.1 + - (100 - parseFloat(arr[1].slice(0, -1)))*0.01 * 0.2 + - parseFloat(arr[2].slice(0, -1))*0.01 * 0.2 + - arr[3] * 0.2 + - arr[4] * 0.3 - ).toFixed(2) - - return weight -}, + /** + * 鎵惧埌瀵硅薄鏁扮粍涓睘鎬nCode涓簐alue鐨勫璞� 娣诲姞杩涙暟缁勪腑 + * @param锛� 瀵硅薄鏁扮粍 锛宮nCode绛変簬value + * @returns锛� + */ + findValue(exceptionData, value) { + if (exceptionData.length == 0) { + return [] + } -/** - * 瀵瑰垎鏋愬�煎拰寮傚父鍊艰绠楅闄╁�� - * @param锛� 鍒嗘瀽鏁版嵁锛屽紓甯告暟鎹紝寮�濮嬫椂闂达紝缁撴潫鏃堕棿 - * @returns锛氳〃鏍兼暟鎹� - */ -merge(anaData,exceptionData,beginTime,endTime){ + let temp = [] + exceptionData.forEach((res) => { + if (res.mnCode == value) { + temp.push(res) + } + }) + return temp + }, - if (anaData.length == 0){ - return [] - } - const table = [] - let i = 0 - anaData.forEach((res) =>{ - let siteName = res.name + /** + * 璁$畻椋庨櫓鍊� + * @param锛� 鏁扮粍銆備緷娆℃槸鍦ㄧ嚎鐜囷紝鏈夋晥鐜囷紝瓒呮爣鐜囷紝寮傚父绫诲瀷鑱氶泦搴︼紝寮傚父澶嶇幇鐜� + * @returns锛� + */ + calRiskValue(arr) { + // 鐢�100鍑� 鏄洜涓鸿灞炴�ч渶瑕佽绠楃殑鏄闄╁�硷紝搴斿綋鏄绾跨巼锛屾棤鏁堢巼 + // 涔樹互0.01鏄洜涓哄幓闄ょ櫨鍒嗗彿鍚庨渶瑕佸啀缂╁皬100鍊� + /* arr[0]:鍦ㄧ嚎鐜� 90% + arr[1]:鏈夋晥鐜� 100% + arr[2]:瓒呮爣鐜� 2% + arr[3]:鍏稿瀷寮傚父澶嶇幇椋庨櫓 0.2 + arr[4]:寮傚父绫诲瀷鑱氶泦椋庨櫓 0.5 + */ + let weight = ( + (100 - parseFloat(arr[0].slice(0, -1))) * 0.01 * 0.1 + + (100 - parseFloat(arr[1].slice(0, -1))) * 0.01 * 0.2 + + parseFloat(arr[2].slice(0, -1)) * 0.01 * 0.2 + + arr[3] * 0.2 + + arr[4] * 0.3 + ).toFixed(2) + + return weight + }, + + /** + * 瀵瑰垎鏋愬�煎拰寮傚父鍊艰绠楅闄╁�� + * @param锛� 鍒嗘瀽鏁版嵁锛屽紓甯告暟鎹紝寮�濮嬫椂闂达紝缁撴潫鏃堕棿 + * @returns锛氳〃鏍兼暟鎹� + */ + merge(anaData, exceptionData, beginTime, endTime) { + if (anaData.length == 0) { + return [] + } + const table = [] + let i = 0 + anaData.forEach((res) => { // 浠庡垎鏋愭暟鎹腑寰楀埌璁惧缂栧彿 let mnCode = res.mnCode // 鎵惧埌寮傚父鏁版嵁涓璵nCode绛変簬value鐨勫璞� - let d = this.findValue(exceptionData,mnCode) + let d = this.findValue(exceptionData, mnCode) // let temp = [...res,...d] - + // 璁$畻鍦ㄧ嚎锛屾湁鏁堢巼锛岃秴鏍囩巼 let r1 = this.getRate(res, beginTime, endTime) - + // 璁$畻澶嶇幇鐜� let r2 = this.calRecur(d) i = i + 1 @@ -253,7 +256,6 @@ if (weight >= 0.6) { obj.riskGrage = '楂橀闄�' obj.riskAdvice = '寤鸿瀵硅绔欑偣杩涜绾夸笅鎵ф硶妫�鏌ワ紝涓撻」鏁版嵁瀵规瘮' - } else if (weight < 0.6 && weight >= 0.2) { obj.riskGrage = '涓闄�' obj.riskAdvice = '寤鸿寮�灞曞父鎬佽拷韪垎鏋�' @@ -265,5 +267,5 @@ }) return table + } } -} \ No newline at end of file diff --git a/src/utils/risk_estimate_common_function/riskValue.js b/src/utils/risk_estimate_common_function/riskValue.js new file mode 100644 index 0000000..14f2278 --- /dev/null +++ b/src/utils/risk_estimate_common_function/riskValue.js @@ -0,0 +1,59 @@ +// import rank from '@/utils/risk_estimate_common_function/rank.js'; +// import dayjs from 'dayjs.js'; + + + +export default { + + // // 璁$畻鏃ラ闄╁�� + // calDailyRisk(allTypeRiskValue){ + // let dailyRiskValue = allTypeRiskValue.onlineRisk*0.1 + allTypeRiskValue.validRisk*0.2 + allTypeRiskValue.exceedingRisk*0.2 + allTypeRiskValue.exceptionTypeAggregation*0.2 + allTypeRiskValue.typicalExceptionRepetitionRate*0.3 + // return dailyRiskValue + // }, + + // // 璁$畻鏈堥闄╁�� + // calMonthRisk(DailyRiskValues,month){ + // // 鏍规嵁鏈堜唤鑾峰緱璇ユ湀鐨勫ぉ鏁� + // let dayNum = dayjs(month).daysInMonth() + // // 绱姞鏃ラ闄╁�� + // let sum = 0 + // for(let i in DailyRiskValues){ + // sum += i + // } + // // 鏃ュ紓甯哥被鍨嬭仛闆嗙巼鐨勫拰/褰撴湀澶╂暟 + // let monthRiskValue = sum /dayNum + // return monthRiskValue + // }, + + // calRiskValue(allTypeRiskValue,queryMonth){ + // // 瀵硅澶囩紪鍙疯繘琛屽垎缁� + // let groupeObj = rank.groupByMncode(allTypeRiskValue) + // // + // for (let mnCode in groupeObj){ + // // 鑾峰緱璁惧缂栧彿瀵瑰簲鐨勬暟鎹� + // let dayData = groupeObj[mnCode] + + // // 淇濆瓨鏌愯澶囩紪鍙疯娈垫椂闂寸殑鏃ラ闄╁�� + // let dailyRiskValues = [] + // // 璁$畻鏃ラ闄╁�� + // for(let item in dayData){ + // let dailyRiskValue = this.calDailyRisk(item) + // dailyRiskValues.push(dailyRiskValue) + // } + // } + + // } + + // 璁$畻鏈堝害椋庨櫓鍊� + calMonthlyRiskValue(exceptionRiskValue){ + // 淇濆瓨鏈堝害椋庨櫓鍊� + let monthlyRiskValue = [] + // 璁$畻姣忎釜绔欑偣鐨勬湀搴﹂闄╁�� + for(let item in exceptionRiskValue){ + let value = item.onlineRisk*0.1 + item.validRisk*0.2 + item.exceedingRisk*0.2 + item.exceptionTypeAggregation*0.2 + item.typicalExceptionRepetitionRate*0.3 + monthlyRiskValue.push(value) + } + return monthlyRiskValue + } + +} \ No newline at end of file diff --git a/src/views/data_management/HistoryData.vue b/src/views/data_management/HistoryData.vue index be2f154..86454df 100644 --- a/src/views/data_management/HistoryData.vue +++ b/src/views/data_management/HistoryData.vue @@ -234,7 +234,7 @@ <el-col> <el-form-item> - <TimeShortCuts @submit-time="giveTime"></TimeShortCuts> + <TimeShortCuts time-type="week" @submit-time="giveTime"></TimeShortCuts> </el-form-item> <el-form-item> diff --git a/src/views/exception/FlightInspection.vue b/src/views/exception/FlightInspection.vue index fc379ed..139b4ad 100644 --- a/src/views/exception/FlightInspection.vue +++ b/src/views/exception/FlightInspection.vue @@ -18,7 +18,7 @@ DustLineChart, ButtonClick, AreaAndmonitorType, - AnalysisCard + AnalysisCard, }, data() { return { diff --git a/src/views/line_graph/DataRiskModel.vue b/src/views/line_graph/DataRiskModel.vue index c1207bf..2da5caf 100644 --- a/src/views/line_graph/DataRiskModel.vue +++ b/src/views/line_graph/DataRiskModel.vue @@ -24,7 +24,7 @@ isNoData: false, loading: false, screenLoading: false, - parentDataFlag:false, + parentDataFlag: false, chartData: [], chartData1: {}, //淇濆瓨鏌ヨ鐨勭粨鏋� chartData2: {}, @@ -78,7 +78,7 @@ watch: { sName() { // 褰撳埆鐨勯〉闈㈣皟鐢ㄦ椂 - if (this.sName != ''|| this.month_1 != '') { + if (this.sName != '' || this.month_1 != '') { // 鏇存柊绔欑偣鍚嶅瓧鍜屾椂闂� this.form.name = this.sName this.month = this.month_1 @@ -89,7 +89,7 @@ this.getAnalysisData() // 璁$畻椋庨櫓鍊� this.calRiskValue() - } + } } }, @@ -244,7 +244,7 @@ this.bill.exceptionTypeAggregation = obj['exceptionTypeAggregation'] }) }, - + // 閫夋嫨鍏朵粬鍊肩被鍨嬫椂 setChart() { if (this.chartData.length) { @@ -338,8 +338,6 @@ ></InputSearch> </el-form-item> - - <el-form-item> <MonthSelect :month="this.month_1" @submit-value="giveMonth"></MonthSelect> </el-form-item> @@ -376,28 +374,44 @@ label="搴忓彿" :index="indexMethod" fixed - width="25" + width="52" show-overflow-tooltip + align="center" /> - <el-table-column prop="siteName" label="绔欑偣鍚嶇О" show-overflow-tooltip /> <el-table-column - prop="riskValue" - label="椋庨櫓鍊�" - sortable - width="67" + prop="siteName" + label="绔欑偣鍚嶇О" show-overflow-tooltip - /> - <el-table-column label="鎿嶄綔" align="center"> + align="center" + > <template #default="{ row }"> <el-button type="primary" text class="table-button" @click="querySiteStaticsInfo(row)" - >椋庨櫓璇︽儏</el-button + >{{ row.siteName }}</el-button > </template> </el-table-column> + <el-table-column + prop="riskValue" + label="椋庨櫓鍊�" + sortable + show-overflow-tooltip + align="center" + /> + <!-- <el-table-column label="鎿嶄綔" align="center"> + <template #default="{ row }"> + <el-button + type="primary" + text + class="table-button" + @click="querySiteStaticsInfo(row)" + >璇︽儏</el-button + > + </template> + </el-table-column> --> </el-table> </el-card> </el-col> @@ -409,7 +423,7 @@ '鏁版嵁鏈夋晥椋庨櫓', '鍏稿瀷寮傚父澶嶇幇椋庨櫓', '寮傚父绫诲瀷鑱氶泦椋庨櫓', - '鏁版嵁瓒呮爣椋庨櫓', + '瓒呮爣寮傚父椋庨櫓', '鏁版嵁鍦ㄧ嚎椋庨櫓' ]" :yData="[ diff --git a/src/views/line_graph/DataRiskRank.vue b/src/views/line_graph/DataRiskRank.vue index b8c8292..465b2b8 100644 --- a/src/views/line_graph/DataRiskRank.vue +++ b/src/views/line_graph/DataRiskRank.vue @@ -1,9 +1,9 @@ <script> -import TimeShortCuts from '@/sfc/TimeShortCuts.vue'; -import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue'; -import { useCommonFunction } from '../../utils/common.js'; -import requetsApi from '@/api/exportExcel/requetsApi.js'; -import dayjs from 'dayjs'; +import TimeShortCuts from '@/sfc/TimeShortCuts.vue' +import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue' +import { useCommonFunction } from '../../utils/common.js' +import requetsApi from '@/api/exportExcel/requetsApi.js' +import dayjs from 'dayjs' import ButtonExportExcel from '@/sfc/ButtonExportExcel.vue' import ButtonClick from '@/sfc/ButtonClick.vue' @@ -26,26 +26,28 @@ isNoData: true, loading: false, // 缁熻鍒嗘瀽鎸夐挳鍔犺浇涓� - queryButton:false, + queryButton: false, // 瀵煎嚭鎸夐挳鍔犺浇涓� - exportButton:false, + exportButton: false, form: { // 寮�濮嬫椂闂� beginTime: '', // 缁撴潫鏃堕棿 endTime: '' - } - }; + }, + tableHeight: '600' + } }, setup() { // 寮曞叆 鐧惧垎鍙锋瘮杈冨ぇ灏� 瀵煎嚭鍔熻兘 - const { cmpp, exportToExcel } = useCommonFunction(); - return { cmpp, exportToExcel }; + const { cmpp, exportToExcel } = useCommonFunction() + return { cmpp, exportToExcel } }, mounted() { - this.form.name = ''; + this.form.name = '' this.fetchData() + this.calTableHeight() }, methods: { // 鍔熻兘锛氬鍑轰负Excel @@ -53,10 +55,10 @@ let params = { beginTime: this.form.beginTime, endTime: this.form.endTime - }; + } this.exportButton = true requetsApi.fetchAllData(params).then((res) => { - const data = res.data.data; + const data = res.data.data const tableColumns = [ 'name', @@ -68,7 +70,7 @@ 'dayOnline', 'dayValid', 'dayExceeding' - ]; + ] const excelColumns = [ ['A1', '绔欑偣鍚嶇О'], ['B1', '璁惧缂栧彿'], @@ -79,213 +81,183 @@ ['G1', '鍦ㄧ嚎鐜�'], ['H1', '鏈夋晥鐜�'], ['I1', '瓒呮爣鐜�'] - ]; - this.exportToExcel(data, tableColumns, excelColumns, '鍒嗘瀽琛�.xlsx'); + ] + this.exportToExcel(data, tableColumns, excelColumns, '鍒嗘瀽琛�.xlsx') this.exportButton = false - }); + }) }, + // 鍔熻兘锛氭敼鍙樿〃鏍兼煇涓崟鍏冩牸鐨勯鑹� tableCellClassName({ row, columnIndex }) { // 骞冲潎鍊间笉婊¤冻鏍囧噯鏃� if (columnIndex == 4) { if (row.dayAvg >= 0.8) { - return 'warning-row'; + return 'warning-row' } } // 鍦ㄧ嚎鐜囷紝鏈夋晥鐜� 涓嶆弧瓒虫爣鍑嗘椂 鍙橀鑹� if (columnIndex == 7) { if (!this.cmpp(row.dayOnline, '90%')) { - return 'red-color'; + return 'red-color' } } if (columnIndex == 8) { if (!this.cmpp(row.dayValid, '90%')) { - return 'red-color'; + return 'red-color' } } }, + + // 鍔熻兘锛氳〃鏍奸珮搴︽牴鎹唴瀹硅嚜閫傚簲 + calTableHeight() { + const h1 = this.$refs.h1.$el.offsetHeight + const h2 = this.$refs.h2.$el.offsetHeight; + // 鍏朵腑涓�涓�40鏄洅瀛愮殑鎬诲杈硅窛 + this.tableHeight = `calc(100vh - ${h1}px - ${h2}px - 40px - 120px - var(--el-main-padding) * 2`; + }, // 椤靛ぇ灏忔敼鍙樻椂瑙﹀彂 handleSizeChange(val) { - this.pageSize = val; + this.pageSize = val // 鏀瑰彉姣忛〉鏄剧ず鏁扮洰鏃惰烦鍒板綋鍓嶉〉 - this.handleCurrentChange(1); + this.handleCurrentChange(1) }, // 椤靛彿鏀瑰彉鏃惰Е鍙� handleCurrentChange(val) { // 灏嗗綋鍓嶉〉鍙风粰currentPage - this.currentPage = val; + this.currentPage = val // 椤甸潰鍙樺寲鏃惰皟鐢� 鏌ヨ鏁版嵁鍑芥暟 - this.fetchData(); + this.fetchData() }, //搴忓彿閫掑 indexMethod(index) { - return index + 1 + (this.currentPage - 1) * this.pageSize; + return index + 1 + (this.currentPage - 1) * this.pageSize }, giveTime(val) { //灏嗕腑鍥芥爣鍑嗘椂闂磋浆涓烘寚瀹氭牸寮�(璇ョ粍浠惰繑鍥炵殑鏍囧噯鏃堕棿鐨勬牸寮忥紝鎵�浠ュ繀椤荤殑鍔犺繖涓嚱鏁�) - this.form.beginTime = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss'); - this.form.endTime = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss'); + this.form.beginTime = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss') + this.form.endTime = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss') }, - - - // 鐐瑰嚮缁熻鎸夐挳 fetchData() { - let params = {}; - params['page'] = this.currentPage; - params['pageSize'] = this.pageSize; + let params = {} + params['page'] = this.currentPage + params['pageSize'] = this.pageSize if (this.form.name) { - params['siteName'] = this.form.name; + params['siteName'] = this.form.name } if (this.form.beginTime) { - params['beginTime'] = this.form.beginTime; + params['beginTime'] = this.form.beginTime } if (this.form.endTime) { - params['endTime'] = this.form.endTime; + params['endTime'] = this.form.endTime } - this.loading = true; + this.loading = true this.queryButton = true this.isNoData = false - this.$http - .get('/dust/analysistime', { params: params }) - .then((response) => { - this.tableData = response.data.data.rows; - this.loading = false; - this.queryButton = false - if (response.data.data.total == 0) { - this.isNoData = true; - return; - } - // 绉婚櫎绌烘暟鎹姸鎬� - this.isNoData = false; - this.total = response.data.data.total; - }); + this.$http.get('/dust/analysistime', { params: params }).then((response) => { + this.tableData = response.data.data.rows + this.loading = false + this.queryButton = false + if (response.data.data.total == 0) { + this.isNoData = true + return + } + // 绉婚櫎绌烘暟鎹姸鎬� + this.isNoData = false + this.total = response.data.data.total + }) } } -}; +} </script> <template> - <div class="search-container"> - <el-container> - <el-main> - <el-form :inline="true" :model="form"> - <el-form-item> - <AreaAndmonitorType></AreaAndmonitorType> - </el-form-item> + <el-form :inline="true" :model="form" ref="h1"> + <el-form-item> + <AreaAndmonitorType></AreaAndmonitorType> + </el-form-item> - <el-form-item> - <TimeShortCuts - timeType="currentMonth" - @submit-time="giveTime" - ></TimeShortCuts> - </el-form-item> - - <el-form-item> - <ButtonClick style="margin-right: 12px;" content="鏁版嵁鎺掑悕" type="primary" :loading="queryButton" @do-search="fetchData" ></ButtonClick> - <ButtonExportExcel content="瀵煎嚭鏁版嵁" type="success" :loading="exportButton" @do-export="exportData"></ButtonExportExcel> - </el-form-item> - </el-form> + <el-form-item> + <TimeShortCuts timeType="currentMonth" @submit-time="giveTime"></TimeShortCuts> + </el-form-item> - <el-card v-show="!isNoData"> - <el-table - :data="tableData" - height="600px" - style="width: 100%" - v-loading="loading" - :cell-class-name="tableCellClassName" - > - <el-table-column - type="index" - prop="name" - label="搴忓彿" - :index="indexMethod" - fixed - show-overflow-tooltip - /> - <el-table-column - prop="name" - label="绔欑偣鍚嶇О" - show-overflow-tooltip - /> + <el-form-item> + <ButtonClick + style="margin-right: 12px" + content="鏁版嵁鎺掑悕" + type="primary" + :loading="queryButton" + @do-search="fetchData" + ></ButtonClick> + <ButtonExportExcel + content="瀵煎嚭鏁版嵁" + type="success" + :loading="exportButton" + @do-export="exportData" + ></ButtonExportExcel> + </el-form-item> + </el-form> - <el-table-column - prop="mnCode" - label="璁惧缂栧彿" - show-overflow-tooltip - /> + <el-card v-show="!isNoData"> + <el-table + :data="tableData" + :height="tableHeight" + style="width: 100%" + v-loading="loading" + :cell-class-name="tableCellClassName" + > + <el-table-column + type="index" + prop="name" + label="搴忓彿" + :index="indexMethod" + fixed + show-overflow-tooltip + /> + <el-table-column prop="name" label="绔欑偣鍚嶇О" show-overflow-tooltip /> - <el-table-column - prop="lst" - label="鐩戞祴鏃ユ湡" - sortable - show-overflow-tooltip - /> + <el-table-column prop="mnCode" label="璁惧缂栧彿" show-overflow-tooltip /> - <el-table-column - prop="dayAvg" - label="鏃ュ钩鍧囧��" - sortable - show-overflow-tooltip - /> - <el-table-column - prop="min" - label="鏃ユ渶灏忓��" - sortable - show-overflow-tooltip - /> - <el-table-column - prop="max" - label="鏃ユ渶澶у��" - sortable - show-overflow-tooltip - /> + <el-table-column prop="lst" label="鐩戞祴鏃ユ湡" sortable show-overflow-tooltip /> - <el-table-column - prop="dayOnline" - label="鏃ュ湪绾跨巼" - sortable - show-overflow-tooltip - /> + <el-table-column prop="dayAvg" label="鏃ュ钩鍧囧��" sortable show-overflow-tooltip /> + <el-table-column prop="min" label="鏃ユ渶灏忓��" sortable show-overflow-tooltip /> + <el-table-column prop="max" label="鏃ユ渶澶у��" sortable show-overflow-tooltip /> - <el-table-column - prop="dayValid" - label="鏃ユ湁鏁堢巼" - sortable - show-overflow-tooltip - /> + <el-table-column prop="dayOnline" label="鏃ュ湪绾跨巼" sortable show-overflow-tooltip /> - <el-table-column - prop="dayExceeding" - label="鏃ヨ秴鏍囩巼" - sortable - show-overflow-tooltip - /> - </el-table> + <el-table-column prop="dayValid" label="鏃ユ湁鏁堢巼" sortable show-overflow-tooltip /> - <el-pagination - :page-sizes="[10, 20, 50, 100]" - :total="total" - layout="total,sizes, prev, pager, next, jumper" - v-model:current-page="currentPage" - v-model:page-size="pageSize" - @update:current-page="handleCurrentChange" - @update:page-size="handleSizeChange" - /> - </el-card> - <el-empty v-show="isNoData" :image-size="200" /> - </el-main> - </el-container> - </div> + <el-table-column prop="dayExceeding" label="鏃ヨ秴鏍囩巼" sortable show-overflow-tooltip /> + </el-table> + + <el-pagination + ref="h2" + :page-sizes="[10, 20, 50, 100]" + :total="total" + layout="total,sizes, prev, pager, next, jumper" + v-model:current-page="currentPage" + v-model:page-size="pageSize" + @update:current-page="handleCurrentChange" + @update:page-size="handleSizeChange" + /> + </el-card> + <el-empty v-show="isNoData" :image-size="200" /> </template> <style scoped> +.el-form { + margin: 20px; +} +.el-card { + margin: 20px 20px 0px 20px; +} :deep().el-table__row .warning-row { background-color: #f7ba1e; } diff --git a/src/views/line_graph/SiteComprehensiveRskRanking.vue b/src/views/line_graph/SiteComprehensiveRskRanking.vue index 7a7d908..2d361f6 100644 --- a/src/views/line_graph/SiteComprehensiveRskRanking.vue +++ b/src/views/line_graph/SiteComprehensiveRskRanking.vue @@ -11,6 +11,8 @@ import SiteDetail from '@/views/line_graph/components/SiteDetail.vue' import { useLoadingStore } from '@/stores/loadingStore'; import { mapStores } from 'pinia'; +import riskApi from '@/api/risk/riskApi.js'; +import riskValue from '@/utils/risk_estimate_common_function/riskValue.js'; export default { components: { AreaAndmonitorType, @@ -109,47 +111,69 @@ this.tableHeight = `calc(100vh - ${h1}px - 40px - 40px - var(--el-main-padding) * 2` }, // 鐐瑰嚮椋庨櫓鎺掑悕鎸夐挳 - fetchData() { + // fetchData() { + // this.loading = true + // this.queryButton = true + // exceptionApi + // .analysisdataByType(this.form.month, 'month') + // .then((response) => { + // this.chartData = response.data.data + // this.queryButton = false + // this.isNoData = false + + // if (response.data.data.length == 0) { + // this.isNoData = true + // return + // } + + // exceptionApi + // .exceptiondata1({ + // siteName: '', + // beginTime: this.form.beginTime, + // endTime: this.form.endTime + // }) + // .then((res) => { + // this.isNoData = false + + // this.table = index.merge( + // this.chartData, + // res.data.data, + // this.form.beginTime, + // this.form.endTime + // ) + // this.loading = false + + // this.$nextTick(()=>{ + // this.$refs.table.sort('riskValue','descending') + + // }) + + // }) + + // }) + // }, + + // 鐐瑰嚮椋庨櫓鎺掑悕鎸夐挳 + fetchData() { this.loading = true this.queryButton = true - exceptionApi - .analysisdataByType(this.form.month, 'month') + riskApi + .queryRiskValue('',this.form.month, 'month') .then((response) => { - this.chartData = response.data.data - this.queryButton = false - this.isNoData = false - if (response.data.data.length == 0) { this.isNoData = true return } - exceptionApi - .exceptiondata1({ - siteName: '', - beginTime: this.form.beginTime, - endTime: this.form.endTime - }) - .then((res) => { - this.isNoData = false - - this.table = index.merge( - this.chartData, - res.data.data, - this.form.beginTime, - this.form.endTime - ) - this.loading = false - + this.table = riskValue.calMonthlyRiskValue(response.data.data) + this.queryButton = false + this.isNoData = false this.$nextTick(()=>{ this.$refs.table.sort('riskValue','descending') - }) - - }) - }) - }, + }) + }, /** * 鍒濆鍔犺浇鍑芥暟 -- Gitblit v1.9.3