Pārlūkot izejas kodu

fix: 修复定制化分析排除词展示问题

zhangyuhan 3 gadi atpakaļ
vecāks
revīzija
211d1d28ff

+ 16 - 6
src/web/staticres/common-module/collection/js/keyword-mobile.js

@@ -49,8 +49,8 @@ var keywordComponentTemplate = `<div class="j-container">
               <span class="j-tag" :class="iitem.matchway == 1 ? 'tag-orange' : 'tag-green'">{{ iitem.matchway == 1 ? '模糊' : '精准' }}</span>
               <span class="custom-title">{{ iitem.text || iitem.name }}</span>
             </template>
-            <template #label v-if="useKeyCard && iitem.notkey">
-              <span class="custom-title">排除词:{{ iitem.notkey }}</span>
+            <template #label v-if="useKeyCard && (iitem.notkey && iitem.notkey.length)">
+              <span class="custom-title">排除词:{{ iitem.notkey|formatKeys }}</span>
             </template>
             <template #right-icon>
               <van-checkbox checked-color="#2ABED1" :bind-group="false" v-model="iitem.type" :name="iitem.name" ref="checkboxes" />
@@ -106,6 +106,14 @@ var keywordComponent = {
       return 1
     }
   },
+  filters: {
+    formatKeys: function (arr) {
+      if (typeof arr === 'object' && typeof arr.join === 'function') {
+        return arr.join(' ')
+      }
+      return arr
+    }
+  },
   created () {
     this.getUserRoot()
     this.getbBtnClick()
@@ -455,10 +463,12 @@ var keywordComponent = {
               data.text = data.name
             }
             if(data.notkey) {
-              if(data.notkey.length != 0) {
-                data.notkey = data.notkey.split(' ')
-              } else {
-                data.notkey = []
+              if (typeof data.notkey === 'string') {
+                if(data.notkey.length) {
+                  data.notkey = data.notkey.split(' ')
+                } else {
+                  data.notkey = []
+                }
               }
             } else {
               data.notkey = []