Bladeren bron

适配多电流情况

liu xiaoping 1 jaar geleden
bovenliggende
commit
6391c2d882

+ 15 - 21
src/components/DataModal/common/RealtimeLine.vue

@@ -23,13 +23,6 @@ import {findYMax} from '@/api/DashboardLayout'
 import moment from 'moment'
 import {mapState} from 'vuex'
 
-const codeMap = {
-  ELECTRIC: '电流',
-  VIBRATION: '振动',
-  NOISE: '噪声',
-  FEEDBACK: '反馈'
-}
-
 export default {
   name: 'RealtimeLine',
   data() {
@@ -84,9 +77,13 @@ export default {
             this.chartList[key] = this.$echarts.init(document.getElementById(key))
 
             const tagList = this.workshopList[key].tagList
-
-            const legendData = tagList.map(e => this.getLegendName(e.name))
-            const startType = codeMap[this.workshopList[key].collectEntityList[0].startType]
+            const legendData = tagList.map(e => this.getLegendName(this.workshopList[key].workshopName, e.name))
+            let startType = 'UNKNOWN'
+            tagList.forEach(e => {
+              if (e.tableColumn === this.workshopList[key].collectEntityList[0].startType) {
+                startType = e.desc
+              }
+            })
             const collectEntityId = this.workshopList[key].collectEntityList[0].id
             const legendSelected = {}
             legendData.forEach(e => {
@@ -95,6 +92,7 @@ export default {
             const options = {
               legend: {
                 right: '4%',
+                left: '20%',
                 icon: 'roundRect',
                 textStyle: {
                   fontSize: 12,
@@ -181,7 +179,7 @@ export default {
               series: []
             }
             for (const e of tagList) {
-              const name = this.getLegendName(e.name)
+              const name = this.getLegendName(this.workshopList[key].workshopName, e.name)
               options.series.push(
                 {
                   name,
@@ -234,6 +232,8 @@ export default {
           const arrNotTags = []
           res.data.forEach((val, index) => {
             if (val.tagList && val.tagList.length > 0) {
+              // 过滤运行反馈
+              val.tagList = val.tagList.filter(e => !e.code.endsWith('FEEDBACK'))
               obj[val.workshopCode] = val
             } else {
               arrNotTags.push(val)
@@ -290,17 +290,11 @@ export default {
           return colors[4]
       }
     },
-    getLegendName(name) {
-      if (name.endsWith('电流')) {
-        return '电流'
-      } else if (name.endsWith('振动')) {
-        return '振动'
-      } else if (name.endsWith('噪声')) {
-        return '噪声'
-      } else if (name.endsWith('反馈')) {
-        return '反馈'
+    getLegendName(prefix, name) {
+      if (name.lastIndexOf(prefix) !== -1) {
+        return name.split(prefix)[1]
       } else {
-        return '未知'
+        return name
       }
     },
     updateChart() {

+ 15 - 5
src/components/DataModal/common/RealtimeTable.vue

@@ -13,18 +13,19 @@
       :cell-style="getCellStyle"
       row-key="id"
       :border="false"
-      style="width: 100%;background-color: inherit">
+      style="background-color: inherit">
       <el-table-column
         column-key="second"
         prop="second"
         label="设备名称"
         align="center"
+        width="110px"
       >
         <template slot-scope="scope">
           <div :style="{ color: scope.row.status ? '#5daf34' : '#f19409' }">{{ scope.row.second }}</div>
         </template>
       </el-table-column>
-      <!--<el-table-column
+      <el-table-column
         v-if="item.prop !== 'second'"
         v-for="item in tableColumns"
         :key="item.id"
@@ -34,9 +35,10 @@
         :align="item.align ? item.align : 'center'"
       >
         <template slot-scope="scope">
-          <span>{{ scope.row[item.prop] && scope.row.status ? Number(scope.row[item.prop]).toFixed(2) : 0 }}</span>
+          <span>{{ Number(scope.row[item.prop]).toFixed(2) === 'NaN' ? '' : Number(scope.row[item.prop]).toFixed(2) }}</span>
         </template>
-      </el-table-column>-->
+      </el-table-column>
+      <!--
       <el-table-column
         column-key="ELECTRIC"
         prop="ELECTRIC"
@@ -66,7 +68,7 @@
         <template slot-scope="scope">
           <span>{{ scope.row.NOISE && scope.row.status ? Number(scope.row.NOISE).toFixed(2) : 0 }}</span>
         </template>
-      </el-table-column>
+      </el-table-column>-->
     </el-table>
   </div>
 </template>
@@ -197,5 +199,13 @@ export default {
     /deep/ .el-table td.el-table__cell, .el-table th.el-table__cell.is-leaf {
       border-bottom: none;
     }
+
+    /deep/ .el-table .el-table__cell {
+      padding: 0;
+    }
+
+    /deep/ .el-table .cell {
+      padding: 8px 0;
+    }
   }
 </style>

+ 18 - 8
src/views/WarnSet/WarnSetModal.vue

@@ -27,6 +27,7 @@
         prop="entityName"
         class-name="first-column"
         align="center"
+        width="200px"
       />
       <el-table-column
         v-for="(item, index) in tableColumns"
@@ -91,6 +92,7 @@
 <script>
 import { findEntityByAcqId } from '@/api/CollectEntity'
 import { updateThreshold } from '@/api/CollectEntityTag'
+import { findTableColumnsNotStatus } from '@/api/TableConfig'
 
 import { mapState } from 'vuex'
 
@@ -113,14 +115,26 @@ export default {
   },
   methods: {
     //更新数据表格数据
-    fetchData() {
+    async fetchData() {
+      await findTableColumnsNotStatus().then(res => {
+        if (res && res.code === '200') {
+          const columns = res.data.filter(e => e.prop !== 'second')
+          const tableColumns = []
+          for (const item of columns) {
+            tableColumns.push({
+              label: item.label,
+              prop: item.prop
+            })
+          }
+          this.tableColumns = tableColumns
+        }
+      })
       const params = {
         acquisitionStationId: this.acquisitionStationId
       }
-      findEntityByAcqId(params).then(res => {
+      await findEntityByAcqId(params).then(res => {
         console.log('根据采集站Id查询所有采集实体 =>', res.data)
         this.tableData.length = 0
-        const columnsMap = new Map()
         for (const entity of res.data) {
           const obj = {
             id: entity.id,
@@ -128,7 +142,7 @@ export default {
           }
           for (const e of entity.collectEntityTagVoList) {
             if (e.tableColumn !== 'FEEDBACK') {
-              columnsMap.set(e.tableColumn, { label: e.desc + '(' + e.unit + ')', prop: e.tableColumn })
+              // columnsMap.set(e.tableColumn, { label: e.desc + '(' + e.unit + ')', prop: e.tableColumn })
               obj[e.tableColumn + 'warnMinValue'] = e.warnMinValue
               obj[e.tableColumn + 'warnMaxValue'] = e.warnMaxValue
               obj.tagId = e.id
@@ -137,10 +151,6 @@ export default {
           }
           this.tableData.push(obj)
         }
-        this.tableColumns.length = 0
-        for (const col of columnsMap.values()) {
-          this.tableColumns.push(col)
-        }
       })
     },
     onTabChange (record) {

+ 33 - 37
src/views/modules/DataReportModal.vue

@@ -67,19 +67,17 @@
         align="center"
         width="200"
       />
+
       <el-table-column
-        prop="electric"
-        :label="`电流\nA`"
-        align="center"
-      />
-      <el-table-column
-        prop="vibration"
-        align="center"
-        :label="`振动\nmm/s`"/>
-      <el-table-column
-        prop="noise"
-        align="center"
-        :label="`噪声\ndB`"/>
+        v-for="(item, index) in tableColumns"
+        :key="index"
+        :column-key="item.prop"
+        :prop="item.prop"
+        :label="item.label"
+        :width="item.width"
+        :class-name="item.className"
+        :align="item.align ? item.align : 'center'"
+      ></el-table-column>
     </el-table>
 
     <div style="display: flex;justify-content: flex-end;margin-top: 8px">
@@ -98,6 +96,7 @@
 
 <script>
 import { findSaveData } from '@/api/HistoryData'
+import { findTableColumnsNotStatus } from '@/api/TableConfig'
 import moment from 'moment'
 
 export default {
@@ -142,29 +141,6 @@ export default {
           }
         }]
       },
-      tableData1: [
-        {
-          id: 1,
-          datetime: '2023-01-06 13:49:51',
-          electric: '0.0',
-          vibration: '0.0000',
-          noise: '0',
-        },
-        {
-          id: 2,
-          datetime: '2023-01-06 13:49:51',
-          electric: '0.0',
-          vibration: '0.0000',
-          noise: '0',
-        },
-        {
-          id: 3,
-          datetime: '2023-01-06 13:49:51',
-          electric: '7.4',
-          vibration: '0.4332',
-          noise: '8773',
-        }
-      ],
       tableData: [],
       tableList: [],
       paginationOption: {
@@ -172,12 +148,32 @@ export default {
         pageSize: 10,
         total: 0,
       },
+      tableColumns: [],
     }
   },
   methods: {
-    fetchData() {
+    async fetchData() {
       // this.tableList.length = 0
       this.tableLoading = true
+
+      await findTableColumnsNotStatus().then(res => {
+        if (res && res.code === '200') {
+          const columns = res.data.filter(e => e.prop !== 'second')
+          const tableColumns = []
+          for (const item of columns) {
+            tableColumns.push({
+              label: item.label,
+              prop: item.prop && item.prop.toLowerCase(),
+              width: item.width,
+              className: item.className,
+              align: item.align,
+            })
+          }
+          this.tableColumns = tableColumns
+          console.log('aaaaaaaaaaaa', tableColumns)
+        }
+      })
+
       const collectEntityId = this.collectEntity.id
       const params = {
         collectEntityId,
@@ -189,7 +185,7 @@ export default {
         pageSize: this.paginationOption.pageSize
       }
       // console.log('==>', this.collectEntity)
-      findSaveData(params).then(res => {
+      await findSaveData(params).then(res => {
         if (res && res.code === '200') {
           this.tableData = res.data.records
           this.paginationOption.total = res.data.total