Browse Source

关键信息点

shaun-sheep 5 years ago
parent
commit
f43e6d8c7e

+ 54 - 50
src/components/ledger/details/detail/cruxDialog.vue

@@ -1,25 +1,13 @@
 <template>
   <el-dialog title="关键信息点" :visible.sync="dialogFormVisible" class="crux-dialog">
-    <section v-for="(val,key,i) in crux" :key="i">
+    <section v-for="(val,key,i) in checkList" :key="i">
       <h4 class="base">{{key}}</h4>
-
-      <el-checkbox-group
-        v-model="checkList[key]"
-        @change="changCheckbox"
-
-      >
-        <el-checkbox
-          v-for="option of val.paths"
-          :key="option.Path"
-          :label="option.InfoPointName"
-          :value="option.KeyWord"
-          :true-label="true"
-          :false-label="false"
-        >
-        </el-checkbox>
-      </el-checkbox-group
-      >
-
+      <el-checkbox
+        v-for="(option,index) in val"
+        :key="option+index"
+        :label="option.InfoPointName"
+        v-model="option.KeyWord"
+      />
     </section>
     <div slot="footer" class="dialog-footer">
       <el-button @click="dialogFormVisible = false">取 消</el-button>
@@ -29,34 +17,31 @@
 </template>
 
 <script>
+  import {setDataDictionary} from "@/api/scan/request";
+
   export default {
     name: "cruxDialog",
-    props: ['crux'],
+    props: ['crux', 'type'],
     data() {
       return {
         dialogFormVisible: false,
-        type: '',//设备类型
         checkList: {},
         checkboxGroup: []
       }
     },
-    computed: {
-      allChecks() {
-        const tmp = [];
-        for (const key in this.checkList) {
-          if (this.checkList.hasOwnProperty(key)) {
-            const element = this.checkList[key];
-            tmp.push(...element)
+    computed: {
+      allChecks() {
+        const tmp = [];
+        for (const key in this.checkList) {
+          if (this.checkList.hasOwnProperty(key)) {
+            const element = this.checkList[key];
+            tmp.push(...element);
           }
         }
-        return tmp;
+        return tmp;
       }
     },
-    created() {
-      //   for (let key in this.crux) {
-      //     this.$set(this.checkList, key, [])
-      //   }
-    },
+
     watch: {
       crux() {
         this.changeList()
@@ -64,29 +49,48 @@
     },
     methods: {
       changeList() {
+        const tmp = {};
         for (let key in this.crux) {
-          this.$set(this.checkList, key, [])
+          if (this.crux.hasOwnProperty(key)) {
+            const element = this.crux[key];
+            tmp[key] = [
+              ...element.paths.map(i => ({
+                InfoPointCode: i.InfoPointCode,
+                KeyWord: i.KeyWord,
+                Type: this.type,
+                InfoPointName: i.InfoPointName
+              }))
+            ]
+          }
         }
+        this.checkList = tmp;
       },
-      dialogOpen(type) {
-        this.type = type
+      dialogOpen() {
         this.dialogFormVisible = true
       },
-      changCheckbox(val) {
-        // let arr = []
-        //   arr = arr.concat(value)
-        // })  val.map((value,index,array)=> {
-        this.checkboxGroup.push(val)
-        let param = {
-          Type: this.type,
-          oPointCode: val.InfoPointCode,
-          KeyWord: val.KeyWord
+      save() {
+        let arrLenght = this.allChecks.filter(i => i.KeyWord)
+        if (arrLenght.length > 6) {
+          this.$message.info('不可超过6个')
+          return false
+        } else {
+          let param = this.allChecks.map(i => {
+            if (i.InfoPointName) {
+              delete i.InfoPointName
+            }
+            return {...i}
+          })
+
+          setDataDictionary(param, res => {
+            this.dialogFormVisible = false
+            this.$emit('cruxSuccess')
+            this.$message('保存成功')
+
+          });
+
         }
 
-        console.log(val, 'val')
-      },
-      save() {
-        console.log(this.checkboxGroup)
+
       }
     }
   }

+ 27 - 5
src/components/ledger/details/detail/exhibitionCrux.vue

@@ -2,8 +2,19 @@
   <section class="exhibition-crux">
     <p class="title">{{exhibitionCrux.title}}
       <span class="icon-shezhi iconfont setting" @click="setting"></span></p>
-    <div style="text-align: center" v-if="!exhibitionCrux.cruxArray.length">暂无数据</div>
-  <cruxDialog ref="setting" :crux="exhibitionCrux.allMessage"/>
+    <div>
+      <div v-if="exhibitionCrux.cruxArray.length">
+        <p class="crux-list" v-for="(item,index) in exhibitionCrux.cruxArray" :key="index">{{item.InfoPointName}}</p>
+      </div>
+      <div style="text-align: center" v-else>暂无数据</div>
+    </div>
+    <cruxDialog
+      ref="setting"
+      :crux="exhibitionCrux.allMessage"
+      :type="type"
+      @cruxSuccess="cruxSuccess"
+
+    />
   </section>
 </template>
 
@@ -15,11 +26,16 @@
     props: ['exhibitionCrux','type'],
     components: {cruxDialog},
     data() {
-      return {}
+      return {
+        list: []
+      }
     },
     methods: {
       setting() {
-        this.$refs.setting.dialogOpen(this.type)
+        this.$refs.setting.dialogOpen()
+      },
+      cruxSuccess() {
+        this.$emit('cruxSuccess')
       }
     }
   }
@@ -29,7 +45,7 @@
   .exhibition-crux {
     .title {
       border-left: 8px solid black;
-      margin: 10px 40px 10px 10px;
+      margin: 10px 40px 0 10px;
       font-weight: 600;
       text-indent: 10px;
       display: block;
@@ -38,6 +54,12 @@
       .setting {
         float: right;
       }
+
     }
+      .crux-list {
+        display: inline-block;
+        width: 25%;
+        margin-left: 28px;
+      }
   }
 </style>

+ 1 - 1
src/components/ledger/details/detail/exhibitionEnergy.vue

@@ -8,7 +8,7 @@
             <div class="table-title">{{item.InfoPointName}}:</div>
             <div>
               <p>表号功能号 {{item.value}}</p>
-              <p>{{item.data}}  {{item.Unit}}</p>
+              <p>{{item.data ? item.data :item.error}} {{item.Unit}}</p>
               <p>{{formatDate(item.receivetime)}}</p>
             </div>
           </div>

+ 5 - 2
src/views/ledger/facility/details/index.vue

@@ -7,7 +7,7 @@
     <div class="content">
       <div class="content-left">
         <div class="content-keyPoint">
-          <exhibitionCrux :exhibitionCrux="exhibitionCrux" :type="type"/>
+          <exhibitionCrux :exhibitionCrux="exhibitionCrux" :type="type" @cruxSuccess="cruxSuccess"/>
         </div>
         <div class="content-showType">
           <selectRadio
@@ -171,6 +171,9 @@
       deepCopy(obj) {
         return JSON.parse(JSON.stringify(obj))
       },
+      cruxSuccess(){
+        this.getData()
+      },
       // 获取表头和实例数据(动态数据在组件中获取,在此格式化请求参数)
       getData() {
         let params1 = {
@@ -249,7 +252,7 @@
         if (val == 1) { //需采集信息
           arr = this.pointData.filter(i => i.Visible)
           //关键信息点
-          this.exhibitionCrux.cruxArray = arr.filter(i => i.KeyWord) //todo 融合
+          this.exhibitionCrux.cruxArray = arr.filter(i => i.KeyWord)
           //  图片和的处理
           this.handlePicList(arr)
           //  文件处理

+ 5 - 2
src/views/ledger/property/details/index.vue

@@ -7,7 +7,7 @@
     <div class="content">
       <div class="content-left">
         <div class="content-keyPoint">
-          <exhibitionCrux :exhibitionCrux="exhibitionCrux" :type="type"/>
+          <exhibitionCrux :exhibitionCrux="exhibitionCrux" :type="type" @cruxSuccess="cruxSuccess"/>
 
         </div>
         <div class="content-showType">
@@ -148,6 +148,9 @@
       deepCopy(obj) {
         return JSON.parse(JSON.stringify(obj))
       },
+      cruxSuccess(){
+        this.getData()
+      },
       // 获取表头和实例数据
       getData () {
         let params1 = {
@@ -184,7 +187,7 @@
         if (val == 1) { //需采集信息
           arr = this.pointData.filter(i => i.Visible)
           //关键信息点
-          this.exhibitionCrux.cruxArray = arr.filter(i => i.KeyWord) //todo 融合
+          this.exhibitionCrux.cruxArray = arr.filter(i => i.KeyWord)
           //  图片和的处理
           this.handlePicList(arr)
           //  文件处理