Browse Source

修改密码和添加标签

cynthia-qin 1 month ago
parent
commit
a37c99b217

+ 3 - 1
src/components/EditPasswordDialog.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog v-model="visible" width="400" title="修改密码" class="password-dialog"
-    @closed="emit('update:modelValue', false)">
+    @closed="onCancel">
     <el-form :model="formData" status-icon :rules="rules" ref="ruleFormRef" class="demo-ruleForm">
       <!-- <el-form-item label="" prop="username"> -->
       <!-- 添加 autocomplete="off" 尝试阻止填充账号 -->
@@ -78,6 +78,7 @@ watch(() => props.show, (newVal) => {
   visible.value = newVal
 })
 function onCancel() {
+  ruleFormRef.value.resetFields()
   emit('update:modelValue', false)
 }
 function onSubmit() {
@@ -106,6 +107,7 @@ function onSubmit() {
         }
         await proxy.$http.post('/open-platform/user/session',data )
         // 修改密码成功后,关闭对话框
+        ruleFormRef.value.resetFields()
         emit('update:modelValue', false);
       } catch (error) {
         console.error("修改密码失败:", error);

+ 25 - 5
src/views/KMPlatform/KnowledgeBase/KBM/KnowledgeBaseManagement.vue

@@ -38,7 +38,14 @@
             <span class="text">
               <div class="title" @click="toKMById(item.id)">{{ item.name }}</div>
               <div class="remark">
-                <el-tag type="info" effect="plain" hit>{{ item.tags }}</el-tag>
+                <template v-if=" typeof item.tags === 'string'">
+                 <el-tag type="info" effect="plain" hit>{{ item.tags }}</el-tag>
+
+                </template>
+                <template v-else-if="Array.isArray(item.tags)">
+                  <el-tag style="margin-right: 5px;padding: 4px;" v-for="(tag, tagIndex) in item.tags" :key="tagIndex">{{ tag }}</el-tag>
+                </template>
+               
               </div>
             </span>
           </div>
@@ -248,23 +255,36 @@ function handleAddKBTags(index) {
   ElMessageBox.prompt('请输入标签', '添加知识库标签', {
     confirmButtonText: '提交',
     cancelButtonText: '取消',
-    inputValue: item.tags,
+    inputValue: '',
     inputPattern:
       /^\S.*$/u,
     inputErrorMessage: '无效输入',
   })
     .then(async ({ value }) => {
+       let tags = []
+      if(item.tags) {
+        if (typeof item.tags === 'string') {
+          tags = item.tags.split()
+          tags.push(value)
+        } else if (Array.isArray(item.tags)) {
+          tags = [...item.tags]
+          tags.push(value)
+        }
+      }else {
+        tags = value.split()
+      }
+       
       const data = await proxy.$http.put(api.knowledgeBase + `/${item.id}`, {
         "name": item.name,
         "description": item.description,
-        "tags": value
+        "tags": tags
       })
       ElMessage({
         type: 'success',
         message: `添加知识库标签成功!`,
       })
-      KBData.value.splice(index, 1, data)
-      // getKnowledgeBase()
+      // KBData.value.splice(index, 1, data)
+      getKnowledgeBase()
     })
     .catch((e) => {
       console.log(e)