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