|
@@ -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)
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|