Skip to content

Commit 4393db9

Browse files
fix: Fix the issue with tag management
1 parent 586c353 commit 4393db9

File tree

3 files changed

+52
-50
lines changed

3 files changed

+52
-50
lines changed

ui/src/views/document/tag/MulAddTagDialog.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
:placeholder="$t('views.document.tag.requiredMessage2')"
6363
>
6464
<el-option
65-
v-for="op in tag.valueOptions"
65+
v-for="op in getValueOptions(tag)"
6666
:key="op"
6767
:value="op.id"
6868
:label="op.value"
@@ -143,11 +143,17 @@ const deleteTag = (index: number) => {
143143
}
144144
145145
function tagKeyChange(tag: any) {
146-
const currentKeyOption = keyOptions.value.find((op: any) => op.key === tag.key)
147-
tag.valueOptions = currentKeyOption ? currentKeyOption.values : []
148146
tag.value = null
149147
}
150148
149+
function getValueOptions(tag?: any) {
150+
let currentKeyOption = null
151+
if (tag && tag.key) {
152+
currentKeyOption = keyOptions.value.find((op: any) => op.key === tag.key)
153+
}
154+
return currentKeyOption ? currentKeyOption.values : []
155+
}
156+
151157
const submit = () => {
152158
FormRef.value.validate((valid: boolean) => {
153159
if (!valid) return
@@ -162,12 +168,7 @@ function getTags(Key?: string) {
162168
loadSharedApi({ type: 'knowledge', systemType: props.apiType, isShared: isShared.value })
163169
.getTags(id, {}, optionLoading)
164170
.then((res: any) => {
165-
if (Key) {
166-
const index = res.data.findIndex((op: any) => op.key === Key)
167-
tagList.value[index].valueOptions = res.data[index].values
168-
} else {
169-
keyOptions.value = res.data
170-
}
171+
keyOptions.value = res.data
171172
})
172173
}
173174

ui/src/views/document/tag/TagDrawer.vue

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
</template>
66
<div class="flex-between mb-16">
77
<div>
8-
<el-button type="primary" @click="openCreateTagDialog()"
8+
<el-button
9+
type="primary"
10+
@click="openCreateTagDialog()"
911
v-if="permissionPrecise.tag_create(id)"
10-
>{{ $t('views.document.tag.create') }}
12+
>{{ $t('views.document.tag.create') }}
1113
</el-button>
12-
<el-button :disabled="multipleSelection.length === 0" @click="batchDelete"
14+
<el-button
15+
:disabled="multipleSelection.length === 0"
16+
@click="batchDelete"
1317
v-if="permissionPrecise.tag_delete(id)"
1418
>
1519
{{ $t('common.delete') }}
@@ -32,15 +36,18 @@
3236
@cell-mouse-enter="cellMouseEnter"
3337
@cell-mouse-leave="cellMouseLeave"
3438
>
35-
<el-table-column type="selection" width="55"/>
39+
<el-table-column type="selection" width="55" />
3640
<el-table-column :label="$t('views.document.tag.key')">
3741
<template #default="{ row }">
3842
<div class="flex-between">
3943
{{ row.key }}
4044
<div v-if="currentMouseId === row.id">
4145
<span class="mr-4">
4246
<el-tooltip effect="dark" :content="$t('views.document.tag.addValue')">
43-
<el-button type="primary" text @click.stop="openCreateTagDialog(row)"
47+
<el-button
48+
type="primary"
49+
text
50+
@click.stop="openCreateTagDialog(row)"
4451
v-if="permissionPrecise.tag_create(id)"
4552
>
4653
<AppIcon iconName="app-add-outlined" />
@@ -49,15 +56,21 @@
4956
</span>
5057
<span class="mr-4">
5158
<el-tooltip effect="dark" :content="$t('views.document.tag.edit')">
52-
<el-button type="primary" text @click.stop="editTagKey(row)"
59+
<el-button
60+
type="primary"
61+
text
62+
@click.stop="editTagKey(row)"
5363
v-if="permissionPrecise.tag_edit(id)"
5464
>
5565
<AppIcon iconName="app-edit" />
5666
</el-button>
5767
</el-tooltip>
5868
</span>
5969
<el-tooltip effect="dark" :content="$t('common.delete')">
60-
<el-button type="primary" text @click.stop="delTag(row)"
70+
<el-button
71+
type="primary"
72+
text
73+
@click.stop="delTag(row)"
6174
v-if="permissionPrecise.tag_delete(id)"
6275
>
6376
<AppIcon iconName="app-delete" />
@@ -78,15 +91,21 @@
7891
<template #default="{ row }">
7992
<span class="mr-4">
8093
<el-tooltip effect="dark" :content="$t('views.document.tag.editValue')">
81-
<el-button type="primary" text @click.stop="editTagValue(row)"
94+
<el-button
95+
type="primary"
96+
text
97+
@click.stop="editTagValue(row)"
8298
v-if="permissionPrecise.tag_edit(id)"
8399
>
84100
<AppIcon iconName="app-edit" />
85101
</el-button>
86102
</el-tooltip>
87103
</span>
88104
<el-tooltip effect="dark" :content="$t('common.delete')">
89-
<el-button type="primary" text @click.stop="delTagValue(row)"
105+
<el-button
106+
type="primary"
107+
text
108+
@click.stop="delTagValue(row)"
90109
v-if="permissionPrecise.tag_delete(id)"
91110
>
92111
<AppIcon iconName="app-delete" />
@@ -96,8 +115,8 @@
96115
</el-table-column>
97116
</el-table>
98117
</el-drawer>
99-
<CreateTagDialog ref="createTagDialogRef" @refresh="getList"/>
100-
<EditTagDialog ref="editTagDialogRef" @refresh="getList"/>
118+
<CreateTagDialog ref="createTagDialogRef" @refresh="getList" />
119+
<EditTagDialog ref="editTagDialogRef" @refresh="getList" />
101120
</template>
102121

103122
<script setup lang="ts">
@@ -110,12 +129,11 @@ import { t } from '@/locales'
110129
import EditTagDialog from '@/views/document/tag/EditTagDialog.vue'
111130
import permissionMap from '@/permission'
112131
113-
114132
const emit = defineEmits(['refresh'])
115133
116134
const route = useRoute()
117135
const {
118-
params: {id, folderId}, // id为knowledgeID
136+
params: { id, folderId }, // id为knowledgeID
119137
} = route as any
120138
121139
const isShared = computed(() => {
@@ -169,7 +187,7 @@ const tableData = computed(() => {
169187
})
170188
171189
// 合并单元格方法
172-
const spanMethod = ({row, column, rowIndex, columnIndex}: any) => {
190+
const spanMethod = ({ row, column, rowIndex, columnIndex }: any) => {
173191
if (columnIndex === 0 || columnIndex === 1) {
174192
// key列 (由于添加了选择列,索引变为1)
175193
if (row.keyIndex === 0) {
@@ -200,19 +218,12 @@ function openCreateTagDialog(row?: any) {
200218
}
201219
202220
function batchDelete() {
203-
MsgConfirm(t('views.document.tag.deleteConfirm'), t('views.document.tag.deleteTip'), {
204-
confirmButtonText: t('common.delete'),
205-
confirmButtonClass: 'danger',
206-
})
221+
const tagsToDelete = multipleSelection.value.map((item) => item.id)
222+
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
223+
.delMulTag(id, tagsToDelete)
207224
.then(() => {
208-
const tagsToDelete = multipleSelection.value.map((item) => item.id)
209-
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
210-
.delMulTag(id, tagsToDelete)
211-
.then(() => {
212-
getList()
213-
})
225+
getList()
214226
})
215-
.catch(() => {})
216227
}
217228
218229
const editTagDialogRef = ref()
@@ -241,29 +252,18 @@ function editTagValue(row: any) {
241252
}
242253
243254
function delTagValue(row: any) {
244-
MsgConfirm(
245-
t('views.document.tag.deleteConfirm') + row.key + '-' + row.value,
246-
t('views.document.tag.deleteTip'),
247-
{
248-
confirmButtonText: t('common.delete'),
249-
confirmButtonClass: 'danger',
250-
},
251-
)
255+
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
256+
.delTag(id, row.id, 'one')
252257
.then(() => {
253-
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
254-
.delTag(id, row.id, 'one')
255-
.then(() => {
256-
getList()
257-
})
258+
getList()
258259
})
259-
.catch(() => {})
260260
}
261261
262262
function getList() {
263263
const params = {
264-
...(filterText.value && {name: filterText.value}),
264+
...(filterText.value && { name: filterText.value }),
265265
}
266-
loadSharedApi({type: 'knowledge', systemType: apiType.value, isShared: isShared.value})
266+
loadSharedApi({ type: 'knowledge', systemType: apiType.value, isShared: isShared.value })
267267
.getTags(id, params, loading)
268268
.then((res: any) => {
269269
tags.value = res.data

ui/src/views/document/tag/TagSettingDrawer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function addTags(tags: any) {
199199
}
200200
201201
const open = (doc: any) => {
202+
filterText.value = ''
202203
debugVisible.value = true
203204
document_id.value = doc.id
204205

0 commit comments

Comments
 (0)