From d1ccf7e1835b3c583da16d90a286e749d5e27c84 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期四, 07 十二月 2023 14:15:20 +0800 Subject: [PATCH] 修改无数据时段的算法 --- src/views/risk_assessment/components/CompDataRiskModel.vue | 243 +++++++++++++++++------------------------------- 1 files changed, 86 insertions(+), 157 deletions(-) diff --git a/src/views/risk_assessment/components/CompDataRiskModel.vue b/src/views/risk_assessment/components/CompDataRiskModel.vue index d994558..d30dcb1 100644 --- a/src/views/risk_assessment/components/CompDataRiskModel.vue +++ b/src/views/risk_assessment/components/CompDataRiskModel.vue @@ -1,21 +1,17 @@ <!-- 鏃ュ潎鍊� --> - <script> import InputSearch from '@/sfc/InputSearch.vue' import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue' import exceptionApi from '@/api/exceptionApi.js' - import DustRadarChart from '@/views/risk_assessment/components/DustRadarChart.vue' -import LineChart from '@/views/risk_assessment/components/LineChart.vue' - import index from '@/utils/risk_estimate_common_function/index.js' import ButtonClick from '@/sfc/ButtonClick.vue' import dayjs from 'dayjs' import MonthSelect from '@/sfc/MonthSelect.vue' import riskApi from '@/api/risk/riskApi.js' import riskValue from '@/utils/risk_estimate_common_function/riskValue.js' -import lineChart from '@/utils/chartFunction/lineChart.js' import siteInfo from '@/api/site/siteInfo.js' +import CompDailyStatistic from '@/views/risk_assessment/riskModel/components/CompDailyStatistic.vue' export default { props: { // 鐐逛綅鍚嶅瓧 @@ -35,12 +31,12 @@ } }, components: { - LineChart, InputSearch, AreaAndmonitorType, DustRadarChart, ButtonClick, - MonthSelect + MonthSelect, + CompDailyStatistic }, data() { return { @@ -58,9 +54,9 @@ form: { // 绔欑偣鍚嶇О - name: '', + siteName: '', // 璁惧缂栧彿 - number: '3234', + mnCode: '3234', // 寮�濮嬫椂闂� beginTime: '', // 缁撴潫鏃堕棿 @@ -118,37 +114,27 @@ } }, watch: { - // showAll() { - // console.log('1111') - // // 椤甸潰鍔犺浇鏃秙howAll鎵嶄細鍙樺寲涓�娆� - // // 涓簍rue琛ㄧず鐨勯闄╂ā鍨嬮〉闈� - // if (this.showAll) { - // // 鍔犺浇椋庨櫓鍊兼渶楂樼殑绔欑偣鏁版嵁 - // this.ShowDefaultData() - // } - // }, siteName() { - if(this.siteName!= ''){ - // 鏇存柊绔欑偣鍚嶅瓧鍜屾椂闂� - this.form.name = this.siteName - this.screenLoading = true - siteInfo.queryMnCode(this.siteName).then((response) => { - this.form.number = response.data.data[0].mnCode - this.month = this.time - // 鍚屾椂鏇存柊鏈堣捣濮嬫椂闂� - this.form.beginTime = dayjs(this.month).startOf().format('YYYY-MM-DD HH:mm:ss') - this.form.endTime = dayjs(this.month).endOf('month').format('YYYY-MM-DD HH:mm:ss') + if (this.siteName != '') { + // 鏇存柊绔欑偣鍚嶅瓧鍜屾椂闂� + this.form.siteName = this.siteName + this.screenLoading = true + siteInfo.queryMnCode(this.siteName).then((response) => { + this.form.mnCode = response.data.data[0].mnCode + this.month = this.time + // 鍚屾椂鏇存柊鏈堣捣濮嬫椂闂� + this.form.beginTime = dayjs(this.month).startOf().format('YYYY-MM-DD HH:mm:ss') + this.form.endTime = dayjs(this.month).endOf('month').format('YYYY-MM-DD HH:mm:ss') - // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟� - this.getSiteInfo(this.form.number) - // 鏇存柊缁熻鏁版嵁 - this.getAnalysisData() - // 璁$畻椋庨櫓鍊� - this.calRiskValue() - this.screenLoading = false - }) + // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟� + this.getSiteInfo(this.form.mnCode) + // 鏇存柊缁熻鏁版嵁 + this.getAnalysisData() + // 璁$畻椋庨櫓鍊� + this.calRiskValue() + this.screenLoading = false + }) } - } }, @@ -158,16 +144,16 @@ return riskApi.getRiskAdvice(this.weight) } }, -mounted(){ - if(this.showAll){ - // 鍔犺浇椋庨櫓鍊兼渶楂樼殑绔欑偣鏁版嵁 - this.ShowDefaultData() + mounted() { + if (this.showAll) { + // 鍔犺浇椋庨櫓鍊兼渶楂樼殑绔欑偣鏁版嵁 + this.ShowDefaultData() } -}, + }, methods: { // 鏌ヨ绔欑偣缁熻淇℃伅 async querySiteStaticsInfo(row) { - this.form.name = row.siteName + this.form.siteName = row.siteName // 鏇存柊缁熻鏁版嵁 await this.getAnalysisData() // 璁$畻椋庨櫓鍊� @@ -192,7 +178,7 @@ // 鏇存柊鎺掑悕娓呭崟 this.getRiskRank() // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟� - this.getSiteInfo(this.form.number) + this.getSiteInfo(this.form.mnCode) // 鏇存柊鍒嗘瀽鏁版嵁 this.getAnalysisData() // 璁$畻椋庨櫓鍊� @@ -222,12 +208,12 @@ this.screenLoading = true // 鏇存柊鎺掑悕娓呭崟锛屽苟寰楀埌椋庨櫓鍊兼渶楂樼珯鐐� let arr = await this.getRiskRank() - this.form.name = arr[0] - this.form.number = arr[1] + this.form.siteName = arr[0] + this.form.mnCode = arr[1] this.screenLoading = false // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟� - this.getSiteInfo(this.form.number) + this.getSiteInfo(this.form.mnCode) // 鏇存柊鏃ョ粺璁℃暟鎹� this.getAnalysisData() // 璁$畻椋庨櫓鍊� @@ -240,7 +226,7 @@ * @returns锛� */ calRiskValue() { - riskApi.queryRiskValue(this.form.number, this.month, 'month').then((response) => { + riskApi.queryRiskValue(this.form.mnCode, this.month, 'month').then((response) => { const rValue = response.data.data[0] this.exceptionRisk.onlineRisk = rValue.onlineRisk this.exceptionRisk.validRisk = rValue.validRisk @@ -254,25 +240,15 @@ // 鏍规嵁鐩墠绔欑偣锛屾湀浠斤紝鏌ユ姌绾垮浘鏃ョ粺璁℃暟鎹� fetchDayAnalysisData() { - let params = {} - if (this.form.name) { - params['siteName'] = this.form.name - } - if (this.form.beginTime) { - params['beginTime'] = this.form.beginTime - } - if (this.form.endTime) { - params['endTime'] = this.form.endTime - } this.loading = true this.queryButton = true exceptionApi - .analysisdata(this.form.name, this.form.beginTime, this.form.endTime, 'day') + .analysisdata(this.form.siteName, this.form.beginTime, this.form.endTime, 'day') .then((response) => { - this.chartData = response.data.data + this.chartData = response this.loading = false this.queryButton = false - if (response.data.data.length == 0) { + if (response.length == 0) { this.isNoData = true return } @@ -283,12 +259,6 @@ // 绉婚櫎绌烘暟鎹姸鎬� this.isNoData = false - - // 鏃犳暟鎹殑鏃堕棿娈� - let noDataTimeInteval = lineChart.backNoDataInteval(begin, end) - // 鏃犳暟鎹厤缃椂闂存 - this.areaColor = lineChart.getMarkArea(noDataTimeInteval) - this.setChart() // 鎶樼嚎鍥炬暟鎹� let temp = index.calBillData(this.chartData, begin, end) @@ -305,7 +275,7 @@ fetchExceptionAnalysisData() { exceptionApi .exceptiondata1({ - siteName: this.form.name, + siteName: this.form.siteName, beginTime: this.form.beginTime, endTime: this.form.endTime }) @@ -318,35 +288,6 @@ this.bill.exceedingNearCount = obj['exceedingNearCount'] this.bill.exceedingCriticalDegree = obj['exceedingCriticalDegree'] }) - }, - - // 閫夋嫨鍏朵粬鍊肩被鍨嬫椂 - setChart() { - if (this.chartData.length) { - // 鏋勫缓鎶樼嚎鍥緓,y鏁版嵁 - let obj = lineChart.getLineChartXYData( - this.chartData, - this.form.beginTime, - this.form.endTime - ) - - this.chartData1 = { - x: obj.xData, - y: obj.yAvg - } - this.chartData2 = { - x: obj.xData, - y: obj.yOnline - } - this.chartData3 = { - x: obj.xData, - y: obj.yValid - } - this.chartData4 = { - x: obj.xData, - y: obj.yExceed - } - } }, // 寰楀埌鍓�10椋庨櫓鎺掑悕娓呭崟 @@ -391,7 +332,7 @@ }, openDetail() { - const encodedSiteName = encodeURIComponent(this.form.name) + const encodedSiteName = encodeURIComponent(this.form.siteName) const timeType = '1' const jumpPage = '2' this.$router.push(`/exceptionDetail/${encodedSiteName}/${this.month}/${timeType}/${jumpPage}`) @@ -408,17 +349,16 @@ <el-form-item class="form-item"> <InputSearch - :site-name="form.name" + :site-name="form.siteName" isNeedDefaultSite="0" - @submit-value="(n) => (form.name = n)" - @submit-mncode="(n) => (form.number = n)" + @submit-value="(n) => (form.siteName = n)" + @submit-mncode="(n) => (form.mnCode = n)" ></InputSearch> </el-form-item> <el-form-item v-show="showAll"> <MonthSelect @submit-value="giveMonth"></MonthSelect> </el-form-item> - <el-form-item v-show="showAll"> <ButtonClick @@ -433,7 +373,7 @@ <div v-loading="screenLoading" class="wait-name"> <div class="chart-container" v-show="!isNoData && !screenLoading"> <el-card class="time-text"> - <h4>{{ form.name }}</h4> + <h4>{{ form.siteName }}</h4> <br /> <br /> @@ -441,12 +381,18 @@ <el-tag class="mx-1">鍦烘櫙</el-tag>{{ siteInfo.typename }} <el-tag class="mx-1">杩愮淮鍟�</el-tag>{{ siteInfo.dutyCompany }} - <el-button type="primary" size="default" class="exception-button" v-show="showAll" @click="openDetail"> + <el-button + type="primary" + size="default" + class="exception-button" + v-show="showAll" + @click="openDetail" + > 鏁版嵁寮傚父璇︽儏 </el-button> </el-card> - <el-row :gutter="10" > + <el-row :gutter="10"> <el-col :span="5" v-show="showAll"> <el-card shadow="never" class="table-class"> <el-table @@ -495,7 +441,7 @@ </el-card> </el-col> - <el-col :span="showAll ?11:14" > + <el-col :span="showAll ? 11 : 14"> <el-card shadow="never" class="table-class"> <DustRadarChart :name="[ @@ -510,28 +456,31 @@ </el-card> </el-col> - <el-col :span="showAll ?4: 5" > + <el-col :span="showAll ? 4 : 5"> <el-card shadow="never" class="card-height risk-card"> <template #header> + <span class="title-16"> 椋庨櫓鍊�(0~1)锛� </span> <span - class="title-16" + :class="{ + 'weightColor-low': weight < 0.15, + 'weightColor-medium': weight >= 0.15 && weight <= 0.6, + 'weightColor-heigh': weight > 0.6 + }" > - 椋庨櫓鍊�(0~1)锛� - </span> - <span :class="{ - 'weightColor-low': weight < 0.15, - 'weightColor-medium': weight >= 0.15 && weight <= 0.6, - 'weightColor-heigh': weight > 0.6 - }"> {{ weight }}</span> + {{ weight }}</span + > </template> <div class="risk-text-container"> <div class="risk-grade"> <h1 class="sub-title">椋庨櫓绛夌骇锛�</h1> - <span :class="{ - 'weightColor-low': weight < 0.15, - 'weightColor-medium': weight >= 0.15 && weight <= 0.6, - 'weightColor-heigh': weight > 0.6 - }" >{{ riskGradeAndAdvice.riskGrade }} </span> + <span + :class="{ + 'weightColor-low': weight < 0.15, + 'weightColor-medium': weight >= 0.15 && weight <= 0.6, + 'weightColor-heigh': weight > 0.6 + }" + >{{ riskGradeAndAdvice.riskGrade }} + </span> </div> <div class="risk-advice"> @@ -563,7 +512,7 @@ </el-card> </el-col> - <el-col :span="showAll ?4: 5" > + <el-col :span="showAll ? 4 : 5"> <el-card shadow="never" class="card-height"> <template #header> <span class="title-16">椋庨櫓璇︽儏</span> @@ -572,29 +521,35 @@ <el-form> <el-form-item label="鏈�澶у�硷細"> {{ bill.max }} mg/m鲁 </el-form-item> <el-form-item label="鏈�灏忓�硷細"> {{ bill.min }} mg/m鲁 </el-form-item> - <el-form-item label="鏁版嵁鏈夋晥鐜囷細"> {{ bill.online*100 }}% </el-form-item> - <el-form-item label="鏁版嵁鍦ㄧ嚎鐜囷細"> {{ bill.valid*100 }}% </el-form-item> - <el-form-item label="鏁版嵁瓒呮爣鐜囷細"> {{ bill.exceeding*100 }}% </el-form-item> + <el-form-item label="鏁版嵁鏈夋晥鐜囷細"> {{ bill.online * 100 }}% </el-form-item> + <el-form-item label="鏁版嵁鍦ㄧ嚎鐜囷細"> {{ bill.valid * 100 }}% </el-form-item> + <el-form-item label="鏁版嵁瓒呮爣鐜囷細"> {{ bill.exceeding * 100 }}% </el-form-item> <el-form-item label="寮傚父绫诲瀷鑱氶泦搴︼細"> {{ exceptionRisk.exceptionTypeAggregation * 100 }}% </el-form-item> - <el-tag :size="small" v-show="bill.exception.length">鍏卞嚭鐜颁簡{{ bill.exception.length }}绫诲紓甯�</el-tag> + <el-tag size="small" v-show="bill.exception" + >鍏卞嚭鐜颁簡{{ bill.exception }}绫诲紓甯�</el-tag + > + <el-form-item label="鍏稿瀷寮傚父澶嶇幇鐜囷細"> {{ exceptionRisk.typicalExceptionRepetitionRate * 100 }}% </el-form-item> - + <div> - <el-tag :size="small" v-show="bill.mutationCount">閲忕骇绐佸彉寮傚父:{{ bill.mutationCount }}鏉�</el-tag> + <el-tag size="small" v-show="bill.mutationCount" + >閲忕骇绐佸彉寮傚父:{{ bill.mutationCount }}鏉�</el-tag + > </div> <div> - <el-tag :size="small" v-show="bill.exceedingNearCount">涓磋繎瓒呮爣寮傚父:{{ bill.exceedingNearCount }}鏉�</el-tag> + <el-tag size="small" v-show="bill.exceedingNearCount" + >涓磋繎瓒呮爣寮傚父:{{ bill.exceedingNearCount }}鏉�</el-tag + > </div> <div> - <el-tag :size="small" - v-show="bill.exceedingCriticalDegree" + <el-tag size="small" v-show="bill.exceedingCriticalDegree" >鍗曟棩瓒呮爣娆℃暟涓寸晫寮傚父:{{ bill.exceedingCriticalDegree }}鏉�</el-tag > </div> @@ -603,33 +558,7 @@ </el-col> </el-row> - <el-row :gutter="20"> - <el-col :span="12"> - <el-card shadow="never" class="card-value"> - <LineChart - title="鏃ュ潎鍊�" - :chartData="chartData1" - yName="mg/m鲁" - seriesName="鏃ュ潎鍊�" - :areaColor="areaColor" - > - </LineChart> - </el-card> - </el-col> - - <el-col :span="12"> - <el-card shadow="never" class="card-value"> - <LineChart - title="鏃ユ湁鏁堢巼" - :chartData="chartData3" - yName="%" - seriesName="鏃ユ湁鏁堢巼" - :areaColor="areaColor" - > - </LineChart> - </el-card> - </el-col> - </el-row> + <CompDailyStatistic :fetch-params="form" /> </div> </div> <el-empty description="鏆傛棤鏁版嵁" v-show="isNoData" :image-size="200" /> -- Gitblit v1.9.3