Browse Source

风机健康趋势模块完成

yangxiao 3 years ago
parent
commit
3eabb94653

+ 7 - 0
src/components/chart/line/simple-line-chart.vue

@@ -132,6 +132,10 @@ export default {
       type: String,
       default: "green",
     },
+    lineTitle:{
+      type: Array,
+      default: () => [],
+    }
   },
   data() {
     return {
@@ -352,11 +356,13 @@ export default {
     },
   },
   created() {
+    this.xData = this.lineTitle;
     this.$nextTick(()=>{
       this.id = "pie-chart-" + util.newGUID();
     });
   },
   mounted() {
+    this.xData = this.lineTitle;
     this.$nextTick(() => {
       this.$el.style.width = this.width;
       this.$el.style.height = this.height;
@@ -364,6 +370,7 @@ export default {
     });
   },
   updated() {
+    this.xData = this.lineTitle;
     this.$nextTick(() => {
       this.initChart();
     });

+ 1 - 1
src/router/index.js

@@ -155,7 +155,7 @@ const routes = [
     path: '/health/health4',
     name: 'health4',
     children: [{
-      path: 'healthLineChart/:wtId', // 健康趋势
+      path: 'healthLineChart/:wtId', // 风机健康趋势
       component: () => import(/* webpackChunkName: "healthLineChart" */ '../views/HealthControl/healthLineChart.vue'),
     },
     {

+ 34 - 7
src/views/HealthControl/healthLineChart.vue

@@ -1,10 +1,6 @@
 <template>
   <div class="pageBox">
-    <simple-line-chart :height="'100px'" />
-    <simple-line-chart :height="'100px'" :color="'yellow'" :title="'发电机'" />
-    <simple-line-chart :height="'100px'" :color="'purple'" :title="'变桨系统'" />
-    <simple-line-chart :height="'100px'" :color="'blue'" :title="'主控系统'" />
-    <simple-line-chart :height="'100px'" :color="'orange'" :title="'齿轮箱'" />
+    <simple-line-chart :height="'100px'" v-for="(item, index) in chartData" :key="index" :title="item.title" :data="item.data" :color="item.color" :lineTitle="item.lineTitle" />
   </div>
 </template>
 
@@ -14,15 +10,46 @@ export default {
   setup() {},
   components: { SimpleLineChart },
   data() {
-    return {};
+    return {
+      chartData:[]
+    };
   },
 
   created() {
     this.wtId = this.$route.params.wtId;
+    this.requestData();
   },
   
   methods:{
-   
+    requestData(){
+      let that=this;
+      that.API.requestData({
+        method: "POST",
+        subUrl: "healthsub/hsFjValueIndex",
+        data:{
+          wtId: that.wtId
+        },
+        success(res) {
+
+          const color=["green","yellow","purple","blue","orange"];
+          let chartData=[];
+          let lineTitle=[];
+
+          res.data.xData.forEach(ele=>{
+            lineTitle.push(new Date(ele).formatDate("hh:mm"));
+          });
+
+          res.data.datasets.forEach((ele,index)=>{
+            chartData.push({
+              title:ele.name,
+              data:ele.data,
+              color:color[index],
+              lineTitle
+            });
+          });
+          that.chartData=chartData;
+        },
+      });}
   }
 };
 </script>