mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: The document supports setting tags
This commit is contained in:
parent
aa42c6f76f
commit
75eab6749e
|
|
@ -75,5 +75,25 @@ export default {
|
|||
])
|
||||
},
|
||||
},
|
||||
|
||||
'app-tag': {
|
||||
iconReader: () => {
|
||||
return h('i', [
|
||||
h(
|
||||
'svg',
|
||||
{
|
||||
style: { height: '100%', width: '100%' },
|
||||
viewBox: '0 0 1024 1024',
|
||||
version: '1.1',
|
||||
xmlns: 'http://www.w3.org/2000/svg',
|
||||
},
|
||||
[
|
||||
h('path', {
|
||||
d: 'M512 85.333333a42.666667 42.666667 0 0 1 30.165333 12.501334l345.045334 345.045333a119.466667 119.466667 0 0 1 0 168.448l-275.413334 275.370667a119.466667 119.466667 0 0 1-169.002666 0.042666l-344.96-344.533333A42.666667 42.666667 0 0 1 85.333333 512V128a42.666667 42.666667 0 0 1 42.666667-42.666667h384z m-17.706667 85.333334H170.666667v323.669333l332.458666 332.074667a34.133333 34.133333 0 0 0 18.773334 9.557333l5.376 0.426667a34.133333 34.133333 0 0 0 24.149333-10.026667l275.242667-275.2a34.133333 34.133333 0 0 0 0.085333-48.042667L494.293333 170.666667zM352 298.666667a53.333333 53.333333 0 1 1 0 106.666666 53.333333 53.333333 0 0 1 0-106.666666z',
|
||||
fill: 'currentColor',
|
||||
}),
|
||||
],
|
||||
),
|
||||
])
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,10 +106,12 @@ export default {
|
|||
addTag: 'Add Tag',
|
||||
setting: 'Tag Settings',
|
||||
create: 'Create Tag',
|
||||
createValue: 'Create Tag Value',
|
||||
edit: 'Edit Tag',
|
||||
editValue: 'Edit Tag Value',
|
||||
deleteConfirm: 'Confirm delete tag: ',
|
||||
deleteTip: 'After deletion, resources using this tag will have the tag removed. Please proceed with caution!',
|
||||
deleteTip:
|
||||
'After deletion, resources using this tag will have the tag removed. Please proceed with caution!',
|
||||
requiredMessage1: 'Please enter a tag',
|
||||
requiredMessage2: 'Please enter a value',
|
||||
},
|
||||
|
|
@ -174,8 +176,8 @@ export default {
|
|||
requiredMessage: 'Please enter similarity value',
|
||||
},
|
||||
allow_download: {
|
||||
label: 'Allow download in knowledge base source',
|
||||
}
|
||||
label: 'Allow download in knowledge base source',
|
||||
},
|
||||
},
|
||||
hitHandlingMethod: {
|
||||
optimization: 'Model optimization',
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ export default {
|
|||
addValue: '添加标签值',
|
||||
setting: '标签设置',
|
||||
create: '创建标签',
|
||||
createValue: '创建标签值',
|
||||
edit: '编辑标签',
|
||||
editValue: '编辑标签值',
|
||||
deleteConfirm: '是否删除标签: ',
|
||||
|
|
@ -169,7 +170,7 @@ export default {
|
|||
},
|
||||
allow_download: {
|
||||
label: '允许在知识库来源中下载',
|
||||
}
|
||||
},
|
||||
},
|
||||
hitHandlingMethod: {
|
||||
optimization: '模型优化',
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ export default {
|
|||
addTag: '添加標籤',
|
||||
setting: '標籤設置',
|
||||
create: '創建標籤',
|
||||
createValue: '創建標籤值',
|
||||
edit: '編輯標籤',
|
||||
editValue: '編輯標籤值',
|
||||
deleteConfirm: '是否刪除標籤: ',
|
||||
|
|
@ -170,8 +171,8 @@ export default {
|
|||
requiredMessage: '请输入相似度',
|
||||
},
|
||||
allow_download: {
|
||||
label: '允許在知識庫來源下載',
|
||||
}
|
||||
label: '允許在知識庫來源下載',
|
||||
},
|
||||
},
|
||||
hitHandlingMethod: {
|
||||
optimization: '模型優化',
|
||||
|
|
|
|||
|
|
@ -57,13 +57,7 @@
|
|||
>
|
||||
{{ $t('common.setting') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
@click="openAddTagDialog()"
|
||||
:disabled="multipleSelection.length === 0"
|
||||
v-if="permissionPrecise.doc_edit(id)"
|
||||
>
|
||||
{{ $t('views.document.tag.addTag') }}
|
||||
</el-button>
|
||||
|
||||
<el-dropdown v-if="MoreFilledPermission0(id)">
|
||||
<el-button class="ml-12 mr-12">
|
||||
<AppIcon iconName="app-more"></AppIcon>
|
||||
|
|
@ -77,6 +71,12 @@
|
|||
>
|
||||
{{ $t('views.document.setting.migration') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="openAddTagDialog()"
|
||||
:disabled="multipleSelection.length === 0"
|
||||
v-if="permissionPrecise.doc_edit(id)"
|
||||
>{{ $t('views.document.tag.addTag') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
divided
|
||||
@click="syncMulDocument"
|
||||
|
|
@ -91,6 +91,7 @@
|
|||
v-if="knowledgeDetail?.type === 2 && permissionPrecise.doc_sync(id)"
|
||||
>{{ $t('views.document.syncDocument') }}
|
||||
</el-dropdown-item>
|
||||
|
||||
<el-dropdown-item
|
||||
divided
|
||||
@click="deleteMulDocument"
|
||||
|
|
@ -459,9 +460,9 @@
|
|||
></AppIcon>
|
||||
{{ $t('views.document.generateQuestion.title') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="openTagSettingDrawer(row)"
|
||||
>
|
||||
<el-dropdown-item @click="openTagSettingDrawer(row)">
|
||||
<AppIcon iconName="app-tag" class="color-secondary"></AppIcon>
|
||||
|
||||
{{ $t('views.document.tag.setting') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
|
|
@ -676,15 +677,15 @@
|
|||
:workspaceId="knowledgeDetail?.workspace_id"
|
||||
/>
|
||||
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="getList" :apiType="apiType" />
|
||||
<TagDrawer ref="tagDrawerRef"/>
|
||||
<TagSettingDrawer ref="tagSettingDrawerRef" :knowledge-tags="knowledgeTags"/>
|
||||
<AddTagDialog ref="addTagDialogRef" @addTags="addTags" :knowledge-tags="knowledgeTags"/>
|
||||
<TagDrawer ref="tagDrawerRef" />
|
||||
<TagSettingDrawer ref="tagSettingDrawerRef" />
|
||||
<AddTagDialog ref="addTagDialogRef" @addTags="addTags" :apiType="apiType" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
|
||||
import { useRouter, useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
|
||||
import { ElTable } from 'element-plus'
|
||||
import type { ElTable } from 'element-plus'
|
||||
import ImportDocumentDialog from './component/ImportDocumentDialog.vue'
|
||||
import SyncWebDialog from '@/views/knowledge/component/SyncWebDialog.vue'
|
||||
import SelectKnowledgeDialog from './component/SelectKnowledgeDialog.vue'
|
||||
|
|
@ -700,9 +701,9 @@ import { TaskType, State } from '@/utils/status'
|
|||
import { t } from '@/locales'
|
||||
import permissionMap from '@/permission'
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import TagDrawer from "./tag/TagDrawer.vue";
|
||||
import TagSettingDrawer from "./tag/TagSettingDrawer.vue";
|
||||
import AddTagDialog from "@/views/document/tag/MulAddTagDialog.vue";
|
||||
import TagDrawer from './tag/TagDrawer.vue'
|
||||
import TagSettingDrawer from './tag/TagSettingDrawer.vue'
|
||||
import AddTagDialog from '@/views/document/tag/MulAddTagDialog.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
|
@ -1020,15 +1021,14 @@ function syncMulDocument() {
|
|||
confirmButtonClass: 'danger',
|
||||
})
|
||||
.then(() => {
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.putMulSyncDocument(id, arr, loading)
|
||||
.then(() => {
|
||||
MsgSuccess(t('views.document.sync.successMessage'))
|
||||
getList()
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function syncLarkMulDocument() {
|
||||
|
|
@ -1239,7 +1239,7 @@ function openTagDrawer() {
|
|||
|
||||
const tagSettingDrawerRef = ref()
|
||||
function openTagSettingDrawer(doc: any) {
|
||||
tagSettingDrawerRef.value.open(doc)
|
||||
tagSettingDrawerRef.value.open(doc)
|
||||
}
|
||||
|
||||
const addTagDialogRef = ref()
|
||||
|
|
@ -1251,8 +1251,8 @@ function openAddTagDialog() {
|
|||
function addTags(tags: any) {
|
||||
const arr: string[] = multipleSelection.value.map((v) => v.id)
|
||||
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
.postMulDocumentTags(id, {tag_ids: tags, document_ids: arr}, loading)
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.postMulDocumentTags(id, { tag_ids: tags, document_ids: arr }, loading)
|
||||
.then(() => {
|
||||
addTagDialogRef.value?.close()
|
||||
getList()
|
||||
|
|
@ -1260,15 +1260,6 @@ function addTags(tags: any) {
|
|||
})
|
||||
}
|
||||
|
||||
const knowledgeTags = ref<any[]>([])
|
||||
function getTags() {
|
||||
loadSharedApi({type: 'knowledge', systemType: apiType.value, isShared: isShared.value})
|
||||
.getTags(id, {}, loading)
|
||||
.then((res: any) => {
|
||||
knowledgeTags.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
if (beforePagination.value) {
|
||||
|
|
@ -1279,7 +1270,6 @@ onMounted(() => {
|
|||
filterMethod.value = beforeSearch.value['filterMethod']
|
||||
}
|
||||
getList()
|
||||
getTags()
|
||||
// 初始化定时任务
|
||||
initInterval()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
v-model="dialogVisible"
|
||||
:title="currentTagKey ? $t('views.document.tag.addValue') : $t('views.document.tag.create')"
|
||||
:before-close="close"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="FormRef"
|
||||
|
|
@ -12,7 +13,7 @@
|
|||
@submit.prevent
|
||||
>
|
||||
<el-scrollbar>
|
||||
<el-row :gutter="8" align="bottom" style="margin-right: 10px" class="tag-list-max-list">
|
||||
<el-row :gutter="8" style="margin-right: 10px" class="tag-list-max-list">
|
||||
<template v-for="(tag, index) in tags" :key="tag">
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
>
|
||||
<el-input
|
||||
v-model="tag.key"
|
||||
:disabled="currentTagKey"
|
||||
:disabled="currentTagKey? true : false"
|
||||
class="w-full"
|
||||
:placeholder="$t('views.document.tag.requiredMessage1')"
|
||||
></el-input>
|
||||
|
|
@ -55,7 +56,7 @@
|
|||
link
|
||||
type="info"
|
||||
@click="deleteTag(index)"
|
||||
class="mb-24"
|
||||
:style="{ marginTop: index === 0 ? '35px' : '5px' }"
|
||||
>
|
||||
<AppIcon iconName="app-delete"></AppIcon>
|
||||
</el-button>
|
||||
|
|
@ -124,7 +125,7 @@ const submit = () => {
|
|||
.postTags(id, tags.value, loading)
|
||||
.then((res: any) => {
|
||||
close()
|
||||
emit('refresh')
|
||||
emit('refresh', currentTagKey.value)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +1,98 @@
|
|||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="$t('views.document.tag.add')" :before-close="close">
|
||||
<el-dialog v-model="dialogVisible" :title="$t('views.document.tag.addTag')" :before-close="close">
|
||||
<el-form
|
||||
ref="FormRef"
|
||||
:model="{ tags }"
|
||||
:model="{ tagList }"
|
||||
label-position="top"
|
||||
require-asterisk-position="right"
|
||||
@submit.prevent
|
||||
>
|
||||
<div class="flex-between flex" v-for="(tag, index) in tags" :key="tag">
|
||||
<el-form-item
|
||||
:label="index === 0 ? $t('views.document.tag.key') : ''"
|
||||
:prop="`tags.${index}.key`"
|
||||
style="width: 50%"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: $t('views.document.tag.requiredMessage1'),
|
||||
trigger: 'blur',
|
||||
}"
|
||||
>
|
||||
<el-select v-model="tag.key" @change="tagKeyChange(tag)" filterable>
|
||||
<el-option
|
||||
v-for="op in keyOptions"
|
||||
:key="op"
|
||||
:value="op.key"
|
||||
:label="op.key"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="index === 0 ? $t('views.document.tag.value') : ''"
|
||||
:prop="`tags.${index}.value`"
|
||||
style="width: 50%"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: $t('views.document.tag.requiredMessage2'),
|
||||
trigger: 'blur',
|
||||
}"
|
||||
>
|
||||
<el-select v-model="tag.value" filterable>
|
||||
<el-option
|
||||
v-for="op in tag.valueOptions"
|
||||
:key="op"
|
||||
:value="op.id"
|
||||
:label="op.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-scrollbar>
|
||||
<el-row :gutter="8" style="margin-right: 10px" class="tag-list-max-list">
|
||||
<template v-for="(tag, index) in tagList" :key="tag">
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
:label="index === 0 ? $t('views.document.tag.key') : ''"
|
||||
:prop="`tagList.${index}.key`"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: $t('views.document.tag.requiredMessage1'),
|
||||
trigger: 'blur',
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
v-model="tag.key"
|
||||
@change="tagKeyChange(tag)"
|
||||
filterable
|
||||
:placeholder="$t('views.document.tag.requiredMessage1')"
|
||||
:loading="optionLoading"
|
||||
>
|
||||
<el-option
|
||||
v-for="op in keyOptions"
|
||||
:key="op"
|
||||
:value="op.key"
|
||||
:label="op.key"
|
||||
></el-option>
|
||||
<template #footer>
|
||||
<slot name="footer">
|
||||
<div class="w-full text-left cursor">
|
||||
<el-button type="primary" link @click="openCreateTagDialog()">
|
||||
<AppIcon iconName="app-add-outlined" class="mr-4"></AppIcon>
|
||||
{{ $t('views.document.tag.create') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="11">
|
||||
<el-form-item
|
||||
:label="index === 0 ? $t('views.document.tag.value') : ''"
|
||||
:prop="`tagList.${index}.value`"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: $t('views.document.tag.requiredMessage2'),
|
||||
trigger: 'blur',
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
v-model="tag.value"
|
||||
filterable
|
||||
:placeholder="$t('views.document.tag.requiredMessage2')"
|
||||
>
|
||||
<el-option
|
||||
v-for="op in tag.valueOptions"
|
||||
:key="op"
|
||||
:value="op.id"
|
||||
:label="op.value"
|
||||
></el-option>
|
||||
<template #footer>
|
||||
<slot name="footer">
|
||||
<div class="w-full text-left cursor">
|
||||
<el-button type="primary" link @click="openCreateTagDialog(tag)">
|
||||
<AppIcon iconName="app-add-outlined" class="mr-4"></AppIcon>
|
||||
{{ $t('views.document.tag.createValue') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="1">
|
||||
<el-button
|
||||
:disabled="index === 0"
|
||||
text
|
||||
@click="deleteTag(index)"
|
||||
:style="{ marginTop: index === 0 ? '35px' : '5px' }"
|
||||
>
|
||||
<AppIcon iconName="app-delete"></AppIcon>
|
||||
</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
</el-row>
|
||||
</el-scrollbar>
|
||||
</el-form>
|
||||
|
||||
<el-button link type="primary" @click="add">
|
||||
|
|
@ -60,26 +106,40 @@
|
|||
<el-button type="primary" @click="submit">{{ $t('common.confirm') }}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<CreateTagDialog ref="createTagDialogRef" @refresh="getTags" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
import CreateTagDialog from './CreateTagDialog.vue'
|
||||
|
||||
const emit = defineEmits(['addTags'])
|
||||
const props = defineProps({
|
||||
knowledgeTags: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
const props = defineProps<{
|
||||
apiType: 'systemShare' | 'workspace' | 'systemManage' | 'workspaceShare'
|
||||
}>()
|
||||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id, folderId }, // id为knowledgeID
|
||||
} = route as any
|
||||
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'share'
|
||||
})
|
||||
|
||||
const optionLoading = ref<boolean>(false)
|
||||
const FormRef = ref()
|
||||
const dialogVisible = ref<boolean>(false)
|
||||
const tags = ref<Array<any>>([])
|
||||
const tagList = ref<Array<any>>([])
|
||||
const keyOptions = ref()
|
||||
|
||||
const add = () => {
|
||||
tags.value.push({})
|
||||
tagList.value.push({})
|
||||
}
|
||||
const deleteTag = (index: number) => {
|
||||
tagList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
function tagKeyChange(tag: any) {
|
||||
|
|
@ -93,15 +153,34 @@ const submit = () => {
|
|||
if (!valid) return
|
||||
emit(
|
||||
'addTags',
|
||||
tags.value.map((tag) => tag.value),
|
||||
tagList.value.map((tag) => tag.value),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function getTags(Key?: string) {
|
||||
loadSharedApi({ type: 'knowledge', systemType: props.apiType, isShared: isShared.value })
|
||||
.getTags(id, {}, optionLoading)
|
||||
.then((res: any) => {
|
||||
if (Key) {
|
||||
const index = res.data.findIndex((op: any) => op.key === Key)
|
||||
tagList.value[index].valueOptions = res.data[index].values
|
||||
} else {
|
||||
keyOptions.value = res.data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const createTagDialogRef = ref()
|
||||
|
||||
function openCreateTagDialog(row?: any) {
|
||||
createTagDialogRef.value?.open(row)
|
||||
}
|
||||
|
||||
const open = () => {
|
||||
getTags()
|
||||
dialogVisible.value = true
|
||||
tags.value = [{}]
|
||||
keyOptions.value = props.knowledgeTags
|
||||
tagList.value = [{}]
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<template #header>
|
||||
<h4>{{ $t('views.document.tag.setting') }}</h4>
|
||||
</template>
|
||||
<div class="flex-between">
|
||||
<div class="flex-between mb-16">
|
||||
<div>
|
||||
<el-button type="primary" @click="openAddTagDialog()">
|
||||
{{ $t('views.document.tag.addTag') }}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
class="w-240"
|
||||
@change="getList"
|
||||
clearable
|
||||
:placeholder="$t('common.search')"
|
||||
/>
|
||||
</div>
|
||||
<el-table
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
v-loading="loading"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column :label="$t('views.document.tag.key')">
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
|
|
@ -34,42 +35,37 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('views.document.tag.value')">
|
||||
<el-table-column :label="$t('views.document.tag.value')" class-name="border-l">
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
{{ row.value }}
|
||||
<div>
|
||||
<el-button link>
|
||||
<AppIcon iconName="app-delete" class="mr-4" @click="delTagValue(row)"/>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
{{ row.value }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.operation')" align="left" width="100" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip effect="dark" :content="$t('common.delete')">
|
||||
<el-button type="primary" text @click.stop="delTagValue(row)">
|
||||
<AppIcon iconName="app-delete" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
<AddTagDialog ref="addTagDialogRef" @addTags="addTags" :knowledge-tags="knowledgeTags"/>
|
||||
<AddTagDialog ref="addTagDialogRef" @addTags="addTags" :apiType="apiType" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { loadSharedApi } from "@/utils/dynamics-api/shared-api.ts"
|
||||
import { MsgConfirm } from "@/utils/message.ts";
|
||||
import { t } from "@/locales";
|
||||
import AddTagDialog from "@/views/document/tag/MulAddTagDialog.vue";
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api.ts'
|
||||
import { MsgConfirm } from '@/utils/message.ts'
|
||||
import { t } from '@/locales'
|
||||
import AddTagDialog from '@/views/document/tag/MulAddTagDialog.vue'
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
const props = defineProps({
|
||||
knowledgeTags: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: {id}, // id为knowledgeID
|
||||
params: { id, folderId }, // id为knowledgeID
|
||||
} = route as any
|
||||
|
||||
const apiType = computed(() => {
|
||||
|
|
@ -82,6 +78,10 @@ const apiType = computed(() => {
|
|||
}
|
||||
})
|
||||
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'share'
|
||||
})
|
||||
|
||||
const document_id = ref('')
|
||||
const loading = ref(false)
|
||||
const debugVisible = ref(false)
|
||||
|
|
@ -98,7 +98,7 @@ const tableData = computed(() => {
|
|||
id: value.id,
|
||||
key: tag.key,
|
||||
value: value.value,
|
||||
keyIndex: index // 用于判断是否为第一行
|
||||
keyIndex: index, // 用于判断是否为第一行
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -106,33 +106,31 @@ const tableData = computed(() => {
|
|||
return result
|
||||
})
|
||||
|
||||
|
||||
// 合并单元格方法
|
||||
const spanMethod = ({row, column, rowIndex, columnIndex}: any) => {
|
||||
if (columnIndex === 0 || columnIndex === 1) { // key列 (由于添加了选择列,索引变为1)
|
||||
const spanMethod = ({ row, column, rowIndex, columnIndex }: any) => {
|
||||
if (columnIndex === 0 || columnIndex === 1) {
|
||||
// key列 (由于添加了选择列,索引变为1)
|
||||
if (row.keyIndex === 0) {
|
||||
// 计算当前key有多少个值
|
||||
const sameKeyCount = tableData.value.filter(item => item.key === row.key).length
|
||||
const sameKeyCount = tableData.value.filter((item) => item.key === row.key).length
|
||||
return {
|
||||
rowspan: sameKeyCount,
|
||||
colspan: 1
|
||||
colspan: 1,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const multipleSelection = ref<any[]>([])
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
|
||||
function batchDelete() {
|
||||
MsgConfirm(t('views.document.tag.deleteConfirm'), t('views.document.tag.deleteTip'), {
|
||||
confirmButtonText: t('common.delete'),
|
||||
|
|
@ -141,42 +139,44 @@ function batchDelete() {
|
|||
.then(() => {
|
||||
const tagsToDelete = multipleSelection.value.reduce((acc, item) => {
|
||||
// 找出当前选中项的key对应的所有value id
|
||||
const sameKeyItems = tableData.value.filter(data => data.key === item.key)
|
||||
const sameKeyIds = sameKeyItems.map(data => data.id)
|
||||
const sameKeyItems = tableData.value.filter((data) => data.key === item.key)
|
||||
const sameKeyIds = sameKeyItems.map((data) => data.id)
|
||||
return [...acc, ...sameKeyIds]
|
||||
}, [] as string[])
|
||||
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.delMulDocumentTag(id, document_id.value, tagsToDelete, loading)
|
||||
.then(() => {
|
||||
getList()
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function delTagValue(row: any) {
|
||||
MsgConfirm(t('views.document.tag.deleteConfirm') + row.key + '-' + row.value, t('views.document.tag.deleteTip'), {
|
||||
confirmButtonText: t('common.delete'),
|
||||
confirmButtonClass: 'danger',
|
||||
})
|
||||
MsgConfirm(
|
||||
t('views.document.tag.deleteConfirm') + row.key + '-' + row.value,
|
||||
t('views.document.tag.deleteTip'),
|
||||
{
|
||||
confirmButtonText: t('common.delete'),
|
||||
confirmButtonClass: 'danger',
|
||||
},
|
||||
)
|
||||
.then(() => {
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.delMulDocumentTag(id, document_id.value, [row.id], loading)
|
||||
.then(() => {
|
||||
getList()
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function getList() {
|
||||
const params = {
|
||||
...(filterText.value && {name: filterText.value}),
|
||||
...(filterText.value && { name: filterText.value }),
|
||||
}
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.getDocumentTags(id, document_id.value, params, loading)
|
||||
.then((res: any) => {
|
||||
tags.value = res.data
|
||||
|
|
@ -190,7 +190,7 @@ function openAddTagDialog() {
|
|||
}
|
||||
|
||||
function addTags(tags: any) {
|
||||
loadSharedApi({type: 'document', systemType: apiType.value})
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
.postDocumentTags(id, document_id.value, tags, loading)
|
||||
.then(() => {
|
||||
addTagDialogRef.value?.close()
|
||||
|
|
@ -198,8 +198,6 @@ function addTags(tags: any) {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
const open = (doc: any) => {
|
||||
debugVisible.value = true
|
||||
document_id.value = doc.id
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
@click.stop="openAuthorization(row)"
|
||||
@click.stop="openParamSetting(row)"
|
||||
v-if="
|
||||
(row.model_type === 'TTS' ||
|
||||
row.model_type === 'LLM' ||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
>
|
||||
<template #prefix>
|
||||
<el-icon>
|
||||
<Search></Search>
|
||||
<Search />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
|
|
|
|||
|
|
@ -617,13 +617,13 @@ export const menuNodes = [
|
|||
list: [
|
||||
aiChatNode,
|
||||
intentNode,
|
||||
imageGenerateNode,
|
||||
imageUnderstandNode,
|
||||
videoUnderstandNode,
|
||||
textToSpeechNode,
|
||||
speechToTextNode,
|
||||
imageGenerateNode,
|
||||
imageUnderstandNode,
|
||||
textToVideoNode,
|
||||
imageToVideoNode,
|
||||
videoUnderstandNode,
|
||||
questionNode,
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@
|
|||
:step-strictly="true"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="flex-between">
|
||||
<div>
|
||||
|
|
@ -100,48 +99,44 @@
|
|||
>
|
||||
</div>
|
||||
<el-button @click="addClassfiyBranch" type="primary" size="large" link>
|
||||
<el-icon><Plus /></el-icon>
|
||||
<AppIcon iconName="app-add-outlined" />
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<div>
|
||||
<div
|
||||
v-for="(item, index) in form_data.branch"
|
||||
:key="item.id"
|
||||
class="mb-8"
|
||||
>
|
||||
<el-form-item
|
||||
:prop="`branch.${index}.content`"
|
||||
:rules="{
|
||||
message: $t('views.applicationWorkflow.nodes.intentNode.classify.placeholder'),
|
||||
trigger: 'change',
|
||||
required: true,
|
||||
}"
|
||||
>
|
||||
<el-row :gutter="12" align="middle">
|
||||
<el-col :span="21">
|
||||
<el-input
|
||||
v-model="item.content"
|
||||
style="width: 210px"
|
||||
:disabled="item.isOther"
|
||||
:placeholder="
|
||||
$t('views.applicationWorkflow.nodes.intentNode.classify.placeholder')
|
||||
"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-button
|
||||
link
|
||||
size="large"
|
||||
v-if="!item.isOther"
|
||||
:disabled="form_data.branch.filter((b: any) => !b.isOther).length <= 1"
|
||||
@click="deleteClassifyBranch(item.id)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<div v-for="(item, index) in form_data.branch" :key="item.id" class="mb-8">
|
||||
<el-form-item
|
||||
:prop="`branch.${index}.content`"
|
||||
:rules="{
|
||||
message: $t('views.applicationWorkflow.nodes.intentNode.classify.placeholder'),
|
||||
trigger: 'change',
|
||||
required: true,
|
||||
}"
|
||||
>
|
||||
<el-row :gutter="12" align="middle">
|
||||
<el-col :span="21">
|
||||
<el-input
|
||||
v-model="item.content"
|
||||
style="width: 210px"
|
||||
:disabled="item.isOther"
|
||||
:placeholder="
|
||||
$t('views.applicationWorkflow.nodes.intentNode.classify.placeholder')
|
||||
"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-button
|
||||
link
|
||||
size="large"
|
||||
v-if="!item.isOther"
|
||||
:disabled="form_data.branch.filter((b: any) => !b.isOther).length <= 1"
|
||||
@click="deleteClassifyBranch(item.id)"
|
||||
>
|
||||
<AppIcon iconName="app-delete"></AppIcon>
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
|
@ -331,17 +326,21 @@ const IntentClassifyNodeFormRef = ref<FormInstance>()
|
|||
const modelOptions = ref<any>(null)
|
||||
|
||||
const validate = () => {
|
||||
|
||||
return Promise.all([
|
||||
nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(''),
|
||||
IntentClassifyNodeFormRef.value?.validate(),
|
||||
]).then(() => {
|
||||
if (form_data.value.branch.length != new Set(form_data.value.branch.map((item: any) => item.content)).size) {
|
||||
throw t('views.applicationWorkflow.nodes.intentNode.error2')
|
||||
}
|
||||
}).catch((err: any) => {
|
||||
return Promise.reject({ node: props.nodeModel, errMessage: err })
|
||||
})
|
||||
])
|
||||
.then(() => {
|
||||
if (
|
||||
form_data.value.branch.length !=
|
||||
new Set(form_data.value.branch.map((item: any) => item.content)).size
|
||||
) {
|
||||
throw t('views.applicationWorkflow.nodes.intentNode.error2')
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
return Promise.reject({ node: props.nodeModel, errMessage: err })
|
||||
})
|
||||
}
|
||||
|
||||
const application = getApplicationDetail()
|
||||
|
|
|
|||
Loading…
Reference in New Issue