Bladeren bron

路由监听报错BUG修复

yangxiao 3 jaren geleden
bovenliggende
commit
ee4d58c847
1 gewijzigde bestanden met toevoegingen van 45 en 41 verwijderingen
  1. 45 41
      src/views/WindSite/pages/Home/Home.vue

+ 45 - 41
src/views/WindSite/pages/Home/Home.vue

@@ -111,7 +111,7 @@
                     <svg-icon svgid="svg-intranet-involvement" />
                   </span>
                   <span class="text white">
-                      受累
+                    受累
                   </span>
                 </div>
               </row>
@@ -185,7 +185,8 @@
         </div>
         <div class="mg-l-16" style="flex:1 1 auto;" ref="lineChart">
           <panel title="4小时功率曲线图">
-            <multiple-line-chart height="18.519vh" v-if="Powertrend" :list="Powertrend.value" :units="Powertrend.units" :showLegend="true" />
+            <multiple-line-chart height="18.519vh" v-if="Powertrend" :list="Powertrend.value" :units="Powertrend.units"
+              :showLegend="true" />
           </panel>
         </div>
         <div class="mg-l-16" style="flex:0 0 400px;">
@@ -196,36 +197,37 @@
       </div>
       <row>
         <Col :span="8">
-          <panel title="日度损失电量分析">
-            <dual-pie-chart :innerData="pieChartData.dayData" :outerData="pieChartData.dayData" height="21.296vh" />
-          </panel>
+        <panel title="日度损失电量分析">
+          <dual-pie-chart :innerData="pieChartData.dayData" :outerData="pieChartData.dayData" height="21.296vh" />
+        </panel>
         </Col>
         <Col :span="8">
-          <panel title="月度损失电量分析">
-            <dual-pie-chart :innerData="pieChartData.monthData" :outerData="pieChartData.monthData" height="21.296vh" />
-          </panel>
+        <panel title="月度损失电量分析">
+          <dual-pie-chart :innerData="pieChartData.monthData" :outerData="pieChartData.monthData" height="21.296vh" />
+        </panel>
         </Col>
         <Col :span="8">
-          <panel title="年度损失电量分析">
-            <dual-pie-chart :innerData="pieChartData.yearData" :outerData="pieChartData.yearData" height="21.296vh" />
-          </panel>
+        <panel title="年度损失电量分析">
+          <dual-pie-chart :innerData="pieChartData.yearData" :outerData="pieChartData.yearData" height="21.296vh" />
+        </panel>
         </Col>
       </row>
       <row>
         <Col :span="8">
-          <panel title="日度损失电量分析">
-            <hover-bar-chart :list="dayLost" height="21.296vh" />
-          </panel>
+        <panel title="日度损失电量分析">
+          <hover-bar-chart :list="dayLost" height="21.296vh" />
+        </panel>
         </Col>
         <Col :span="8">
-          <panel title="日发电量对比">
-            <multiple-bar-chart height="21.296vh" :list="CompleteElectricity.data" :units="CompleteElectricity.units" :showLegend="true" />
-          </panel>
+        <panel title="日发电量对比">
+          <multiple-bar-chart height="21.296vh" :list="CompleteElectricity.data" :units="CompleteElectricity.units"
+            :showLegend="true" />
+        </panel>
         </Col>
         <Col :span="8">
-          <panel title="月发电量对比">
-            <normal-line-chart height="21.296vh" :list="MonthCompare.value" :units="MonthCompare.units" />
-          </panel>
+        <panel title="月发电量对比">
+          <normal-line-chart height="21.296vh" :list="MonthCompare.value" :units="MonthCompare.units" />
+        </panel>
         </Col>
       </row>
     </div>
@@ -256,7 +258,7 @@ export default {
   // 使用组件
   components: { BtnGroup2, WindSiteWeather, Row, Col, Panel, DualPieChart, MultipleLineChart, Panel3, SvgIcon, HoverBarChart, MultipleBarChart, NormalLineChart, LightMatrix, BtnGroupDouble, Station },
   // 数据
-  data() {
+  data () {
     return {
       timmer: null, // 计时器
       timmer2: null,
@@ -351,12 +353,12 @@ export default {
   },
   // 函数
   methods: {
-    getWp() {
+    getWp () {
       let that = this;
       that.API.requestData({
         method: "GET",
         subUrl: "powercompare/windfarmAllAjax",
-        success(res) {
+        success (res) {
           let btnGroups = [
             {
               icon: "svg-wind-site",
@@ -388,7 +390,7 @@ export default {
       });
     },
 
-    renderBtnActiveIndex() {
+    renderBtnActiveIndex () {
       this.btnGroupsss.forEach((pEle, pIndex) => {
         pEle.btns.forEach((cEle, cIndex) => {
           if (cEle.code === this.wpId) {
@@ -399,13 +401,13 @@ export default {
       });
     },
 
-    select(res) {
+    select (res) {
       this.$router.replace({
         path: `/monitor/windsite/home/${res.code}`,
       });
     },
     // 根据风机状态码返回对应 class
-    getColor(fjzt) {
+    getColor (fjzt) {
       switch (fjzt) {
         case 0:
           return "green";
@@ -424,7 +426,7 @@ export default {
       }
     },
     // 请求服务
-    requestData(showLoading) {
+    requestData (showLoading) {
       this.requestWpInfo(showLoading);
       this.requestLoss(showLoading);
       this.requestPower(showLoading);
@@ -432,7 +434,7 @@ export default {
     },
 
     // 获取场站监视数据
-    requestWpInfo(showLoading) {
+    requestWpInfo (showLoading) {
       let that = this;
       that.API.requestData({
         showLoading,
@@ -441,7 +443,7 @@ export default {
         data: {
           wpId: that.wpId,
         },
-        success(res) {
+        success (res) {
           if (res.data) {
             that.tqmap = res.data.tqmap;
             let fjmap = [];
@@ -586,7 +588,7 @@ export default {
     },
 
     // 获取日度损失电量分析
-    requestLoss(showLoading) {
+    requestLoss (showLoading) {
       let that = this;
       that.API.requestData({
         showLoading,
@@ -595,7 +597,7 @@ export default {
         data: {
           wpId: that.wpId,
         },
-        success(res) {
+        success (res) {
           let dayLost = [];
           res.data.forEach((ele) => {
             dayLost.push({
@@ -609,7 +611,7 @@ export default {
     },
 
     // 获取完成电量
-    requestPower(showLoading) {
+    requestPower (showLoading) {
       let that = this;
       that.API.requestData({
         showLoading,
@@ -618,7 +620,7 @@ export default {
         data: {
           wpId: that.wpId,
         },
-        success(res) {
+        success (res) {
           let data = [
             {
               title: "发电量",
@@ -649,7 +651,7 @@ export default {
     },
 
     // 获取月发电量对比
-    requestMonthPower(showLoading) {
+    requestMonthPower (showLoading) {
       let that = this;
       that.API.requestData({
         showLoading,
@@ -658,7 +660,7 @@ export default {
         data: {
           wpId: that.wpId,
         },
-        success(res) {
+        success (res) {
           let data = [
             {
               title: "月发电量",
@@ -689,7 +691,7 @@ export default {
     },
   },
 
-  created() {
+  created () {
     let that = this;
     that.wpId = that.$route.params.wpId;
     that.$nextTick(() => {
@@ -704,19 +706,21 @@ export default {
     });
   },
 
-  mounted() {},
+  mounted () { },
 
-  unmounted() {
+  unmounted () {
     clearInterval(this.timmer);
     clearInterval(this.timmer2);
     this.timmer = null;
     this.timmer2 = null;
   },
   watch: {
-    $route(res) {
+    $route (res) {
       this.wpId = res.params.wpId;
-      this.requestData(false);
-      this.renderBtnActiveIndex();
+      if (res.params.wpId) {
+        this.requestData(false);
+        this.renderBtnActiveIndex();
+      }
     },
   },
 };