fix: Fix the issue with tag management
parent
586c3536ca
commit
4393db9f05
|
|
@ -62,7 +62,7 @@
|
||||||
:placeholder="$t('views.document.tag.requiredMessage2')"
|
:placeholder="$t('views.document.tag.requiredMessage2')"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="op in tag.valueOptions"
|
v-for="op in getValueOptions(tag)"
|
||||||
:key="op"
|
:key="op"
|
||||||
:value="op.id"
|
:value="op.id"
|
||||||
:label="op.value"
|
:label="op.value"
|
||||||
|
|
@ -143,11 +143,17 @@ const deleteTag = (index: number) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tagKeyChange(tag: any) {
|
function tagKeyChange(tag: any) {
|
||||||
const currentKeyOption = keyOptions.value.find((op: any) => op.key === tag.key)
|
|
||||||
tag.valueOptions = currentKeyOption ? currentKeyOption.values : []
|
|
||||||
tag.value = null
|
tag.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getValueOptions(tag?: any) {
|
||||||
|
let currentKeyOption = null
|
||||||
|
if (tag && tag.key) {
|
||||||
|
currentKeyOption = keyOptions.value.find((op: any) => op.key === tag.key)
|
||||||
|
}
|
||||||
|
return currentKeyOption ? currentKeyOption.values : []
|
||||||
|
}
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
FormRef.value.validate((valid: boolean) => {
|
FormRef.value.validate((valid: boolean) => {
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
|
|
@ -162,12 +168,7 @@ function getTags(Key?: string) {
|
||||||
loadSharedApi({ type: 'knowledge', systemType: props.apiType, isShared: isShared.value })
|
loadSharedApi({ type: 'knowledge', systemType: props.apiType, isShared: isShared.value })
|
||||||
.getTags(id, {}, optionLoading)
|
.getTags(id, {}, optionLoading)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
if (Key) {
|
keyOptions.value = res.data
|
||||||
const index = res.data.findIndex((op: any) => op.key === Key)
|
|
||||||
tagList.value[index].valueOptions = res.data[index].values
|
|
||||||
} else {
|
|
||||||
keyOptions.value = res.data
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,15 @@
|
||||||
</template>
|
</template>
|
||||||
<div class="flex-between mb-16">
|
<div class="flex-between mb-16">
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" @click="openCreateTagDialog()"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="openCreateTagDialog()"
|
||||||
v-if="permissionPrecise.tag_create(id)"
|
v-if="permissionPrecise.tag_create(id)"
|
||||||
>{{ $t('views.document.tag.create') }}
|
>{{ $t('views.document.tag.create') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button :disabled="multipleSelection.length === 0" @click="batchDelete"
|
<el-button
|
||||||
|
:disabled="multipleSelection.length === 0"
|
||||||
|
@click="batchDelete"
|
||||||
v-if="permissionPrecise.tag_delete(id)"
|
v-if="permissionPrecise.tag_delete(id)"
|
||||||
>
|
>
|
||||||
{{ $t('common.delete') }}
|
{{ $t('common.delete') }}
|
||||||
|
|
@ -32,7 +36,7 @@
|
||||||
@cell-mouse-enter="cellMouseEnter"
|
@cell-mouse-enter="cellMouseEnter"
|
||||||
@cell-mouse-leave="cellMouseLeave"
|
@cell-mouse-leave="cellMouseLeave"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55"/>
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column :label="$t('views.document.tag.key')">
|
<el-table-column :label="$t('views.document.tag.key')">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
|
|
@ -40,7 +44,10 @@
|
||||||
<div v-if="currentMouseId === row.id">
|
<div v-if="currentMouseId === row.id">
|
||||||
<span class="mr-4">
|
<span class="mr-4">
|
||||||
<el-tooltip effect="dark" :content="$t('views.document.tag.addValue')">
|
<el-tooltip effect="dark" :content="$t('views.document.tag.addValue')">
|
||||||
<el-button type="primary" text @click.stop="openCreateTagDialog(row)"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
@click.stop="openCreateTagDialog(row)"
|
||||||
v-if="permissionPrecise.tag_create(id)"
|
v-if="permissionPrecise.tag_create(id)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-add-outlined" />
|
<AppIcon iconName="app-add-outlined" />
|
||||||
|
|
@ -49,7 +56,10 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="mr-4">
|
<span class="mr-4">
|
||||||
<el-tooltip effect="dark" :content="$t('views.document.tag.edit')">
|
<el-tooltip effect="dark" :content="$t('views.document.tag.edit')">
|
||||||
<el-button type="primary" text @click.stop="editTagKey(row)"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
@click.stop="editTagKey(row)"
|
||||||
v-if="permissionPrecise.tag_edit(id)"
|
v-if="permissionPrecise.tag_edit(id)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-edit" />
|
<AppIcon iconName="app-edit" />
|
||||||
|
|
@ -57,7 +67,10 @@
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
<el-tooltip effect="dark" :content="$t('common.delete')">
|
<el-tooltip effect="dark" :content="$t('common.delete')">
|
||||||
<el-button type="primary" text @click.stop="delTag(row)"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
@click.stop="delTag(row)"
|
||||||
v-if="permissionPrecise.tag_delete(id)"
|
v-if="permissionPrecise.tag_delete(id)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-delete" />
|
<AppIcon iconName="app-delete" />
|
||||||
|
|
@ -78,7 +91,10 @@
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="mr-4">
|
<span class="mr-4">
|
||||||
<el-tooltip effect="dark" :content="$t('views.document.tag.editValue')">
|
<el-tooltip effect="dark" :content="$t('views.document.tag.editValue')">
|
||||||
<el-button type="primary" text @click.stop="editTagValue(row)"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
@click.stop="editTagValue(row)"
|
||||||
v-if="permissionPrecise.tag_edit(id)"
|
v-if="permissionPrecise.tag_edit(id)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-edit" />
|
<AppIcon iconName="app-edit" />
|
||||||
|
|
@ -86,7 +102,10 @@
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
<el-tooltip effect="dark" :content="$t('common.delete')">
|
<el-tooltip effect="dark" :content="$t('common.delete')">
|
||||||
<el-button type="primary" text @click.stop="delTagValue(row)"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
@click.stop="delTagValue(row)"
|
||||||
v-if="permissionPrecise.tag_delete(id)"
|
v-if="permissionPrecise.tag_delete(id)"
|
||||||
>
|
>
|
||||||
<AppIcon iconName="app-delete" />
|
<AppIcon iconName="app-delete" />
|
||||||
|
|
@ -96,8 +115,8 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<CreateTagDialog ref="createTagDialogRef" @refresh="getList"/>
|
<CreateTagDialog ref="createTagDialogRef" @refresh="getList" />
|
||||||
<EditTagDialog ref="editTagDialogRef" @refresh="getList"/>
|
<EditTagDialog ref="editTagDialogRef" @refresh="getList" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -110,12 +129,11 @@ import { t } from '@/locales'
|
||||||
import EditTagDialog from '@/views/document/tag/EditTagDialog.vue'
|
import EditTagDialog from '@/views/document/tag/EditTagDialog.vue'
|
||||||
import permissionMap from '@/permission'
|
import permissionMap from '@/permission'
|
||||||
|
|
||||||
|
|
||||||
const emit = defineEmits(['refresh'])
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const {
|
const {
|
||||||
params: {id, folderId}, // id为knowledgeID
|
params: { id, folderId }, // id为knowledgeID
|
||||||
} = route as any
|
} = route as any
|
||||||
|
|
||||||
const isShared = computed(() => {
|
const isShared = computed(() => {
|
||||||
|
|
@ -169,7 +187,7 @@ const tableData = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// 合并单元格方法
|
// 合并单元格方法
|
||||||
const spanMethod = ({row, column, rowIndex, columnIndex}: any) => {
|
const spanMethod = ({ row, column, rowIndex, columnIndex }: any) => {
|
||||||
if (columnIndex === 0 || columnIndex === 1) {
|
if (columnIndex === 0 || columnIndex === 1) {
|
||||||
// key列 (由于添加了选择列,索引变为1)
|
// key列 (由于添加了选择列,索引变为1)
|
||||||
if (row.keyIndex === 0) {
|
if (row.keyIndex === 0) {
|
||||||
|
|
@ -200,19 +218,12 @@ function openCreateTagDialog(row?: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function batchDelete() {
|
function batchDelete() {
|
||||||
MsgConfirm(t('views.document.tag.deleteConfirm'), t('views.document.tag.deleteTip'), {
|
const tagsToDelete = multipleSelection.value.map((item) => item.id)
|
||||||
confirmButtonText: t('common.delete'),
|
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||||
confirmButtonClass: 'danger',
|
.delMulTag(id, tagsToDelete)
|
||||||
})
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const tagsToDelete = multipleSelection.value.map((item) => item.id)
|
getList()
|
||||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
|
||||||
.delMulTag(id, tagsToDelete)
|
|
||||||
.then(() => {
|
|
||||||
getList()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editTagDialogRef = ref()
|
const editTagDialogRef = ref()
|
||||||
|
|
@ -241,29 +252,18 @@ function editTagValue(row: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function delTagValue(row: any) {
|
function delTagValue(row: any) {
|
||||||
MsgConfirm(
|
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||||
t('views.document.tag.deleteConfirm') + row.key + '-' + row.value,
|
.delTag(id, row.id, 'one')
|
||||||
t('views.document.tag.deleteTip'),
|
|
||||||
{
|
|
||||||
confirmButtonText: t('common.delete'),
|
|
||||||
confirmButtonClass: 'danger',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
getList()
|
||||||
.delTag(id, row.id, 'one')
|
|
||||||
.then(() => {
|
|
||||||
getList()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getList() {
|
function getList() {
|
||||||
const params = {
|
const params = {
|
||||||
...(filterText.value && {name: filterText.value}),
|
...(filterText.value && { name: filterText.value }),
|
||||||
}
|
}
|
||||||
loadSharedApi({type: 'knowledge', systemType: apiType.value, isShared: isShared.value})
|
loadSharedApi({ type: 'knowledge', systemType: apiType.value, isShared: isShared.value })
|
||||||
.getTags(id, params, loading)
|
.getTags(id, params, loading)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
tags.value = res.data
|
tags.value = res.data
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,7 @@ function addTags(tags: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const open = (doc: any) => {
|
const open = (doc: any) => {
|
||||||
|
filterText.value = ''
|
||||||
debugVisible.value = true
|
debugVisible.value = true
|
||||||
document_id.value = doc.id
|
document_id.value = doc.id
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue