Browse Source

修改bug

chuwu 5 years ago
parent
commit
f9ec5df825

+ 22 - 3
src/components/config_point/cut_string.vue

@@ -6,7 +6,7 @@
             @click="checkItem(item,index)"
             ref="span"
             :class="{
-                'saga-warning': (closedStr.indexOf(index) > -1)
+                'saga-warning': isWarning(item)
             } "
             class="cut-string saga-border pointer border-hover"
           >{{item}}</span>
@@ -35,6 +35,14 @@
         created() {},
         mounted() {},
         methods: {
+            //是否在危险状态
+            isWarning(val){
+                if(this.closedStr.indexOf(val) > -1){
+                    return true
+                }else{
+                    return false
+                }
+            },
             checkItem(item, index) {
                 if(this.obj.hasOwnProperty(index)){
                     delete this.obj[index]
@@ -49,17 +57,28 @@
                     this.$refs.span[index].setAttribute('class',classList)
                 }
             },
-            clear() {
+            clear(str) {
                 this.obj = {}
                 this.stringArr = this.string.split("")
                 for(let i = 0; i < this.stringArr.length; i++){
                     let classList = this.$refs.span[i].getAttribute('class')
-                    console.log(classList,'classList')
                     if(classList.indexOf('bg') > -1){
                         classList = classList.split('bg')
                     }
                     this.$refs.span[i].setAttribute('class',classList)
                 }
+                if(!!str){
+                    let strsArr = str.split("")
+                    strsArr.map((item,index) => {
+                        for(let j = 0; j < stringArr.length;j++){
+                            if(item == stringArr[j]){
+                                this.obj[j] = item
+                                let classList = this.$refs.span[j].getAttribute('class') + ' bg'
+                                this.$refs.span[j].setAttribute('class',classList)
+                            }
+                        }
+                    })
+                }
             },
             getData() {
                 let string = ""

+ 4 - 1
src/components/config_point/find_keyword.vue

@@ -99,6 +99,7 @@
                     cancel: "取消",
                     confirm: "确定"
                 },
+                aiStr: "",//ai推荐
                 Id: "",
                 dataName: "",
                 isSwitch: false,//是否开启开关
@@ -216,13 +217,15 @@
                         //默认已经选择的关键字
                         if(this.type == "type"){
                             this.closedStr = res.Content[0].KeyEquipmentParameter || ''
+                            this.aiStr = res.Content[0].KeyEquipmentType || ''
                         }else{
                             this.closedStr = res.Content[0].KeyEquipmentType || ''
+                            this.aiStr = res.Content[0].KeyEquipmentParameter || ''
                         }
                         this.Id = res.Content[0].PointId
                         //清空已选择的数据
                         this.$nextTick(_ => {
-                            this.$refs.cutString.clear()
+                            this.$refs.cutString.clear(this.aiStr)
                         })
                     } else {
                         this.Description = ""