feat: shared

This commit is contained in:
wangdan-fit2cloud 2025-06-24 22:12:17 +08:00
parent bba7a60789
commit 1c96897d01
37 changed files with 422 additions and 377 deletions

View File

@ -57,7 +57,7 @@ const emit = defineEmits(['update:modelValue', 'submitDialog'])
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -88,7 +88,7 @@ function getRangeFromLineAndColumn(state: any, line: number, column: number, end
const regexpLinter = linter(async (view) => { const regexpLinter = linter(async (view) => {
const diagnostics: Diagnostic[] = [] const diagnostics: Diagnostic[] = []
await loadSharedApi({ type: 'tool', systemType: type.value }) await loadSharedApi({ type: 'tool', systemType: apiType.value })
.postPylint(view.state.doc.toString()) .postPylint(view.state.doc.toString())
.then((ok: any) => { .then((ok: any) => {
ok.data.forEach((element: any) => { ok.data.forEach((element: any) => {

View File

@ -46,7 +46,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="['document', 'knowledge'].includes(apiType)" v-if="['document', 'knowledge'].includes(apiSubmitType)"
:label="$t('components.selectParagraph.title')" :label="$t('components.selectParagraph.title')"
prop="state" prop="state"
> >
@ -72,8 +72,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, watch, computed } from 'vue' import { reactive, ref, watch, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import documentApi from '@/api/knowledge/document'
import paragraphApi from '@/api/knowledge/paragraph'
import useStore from '@/stores' import useStore from '@/stores'
import { groupBy } from 'lodash' import { groupBy } from 'lodash'
import { MsgSuccess } from '@/utils/message' import { MsgSuccess } from '@/utils/message'
@ -81,19 +79,15 @@ import { t } from '@/locales'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const props = defineProps<{
apiType: 'systemShare' | 'workspace' | 'systemManage'
}>()
const route = useRoute() const route = useRoute()
const { const {
params: { id, documentId }, // idknowledgeID params: { id, documentId }, // idknowledgeID
} = route as any } = route as any
const type = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const { model, prompt, user } = useStore() const { model, prompt, user } = useStore()
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
@ -103,7 +97,7 @@ const loading = ref<boolean>(false)
const dialogVisible = ref<boolean>(false) const dialogVisible = ref<boolean>(false)
const modelOptions = ref<any>(null) const modelOptions = ref<any>(null)
const idList = ref<string[]>([]) const idList = ref<string[]>([])
const apiType = ref('') // documentparagraph const apiSubmitType = ref('') // documentparagraph
const state = ref<'all' | 'error'>('error') const state = ref<'all' | 'error'>('error')
const stateMap = { const stateMap = {
all: ['0', '1', '2', '3', '4', '5', 'n'], all: ['0', '1', '2', '3', '4', '5', 'n'],
@ -141,7 +135,7 @@ const open = (ids: string[], type: string, _knowledgeId?: string) => {
knowledgeId.value = _knowledgeId knowledgeId.value = _knowledgeId
getModel() getModel()
idList.value = ids idList.value = ids
apiType.value = type apiSubmitType.value = type
dialogVisible.value = true dialogVisible.value = true
} }
@ -153,33 +147,37 @@ const submitHandle = async (formEl: FormInstance) => {
if (valid) { if (valid) {
// //
prompt.save(user.userInfo?.id as string, form.value) prompt.save(user.userInfo?.id as string, form.value)
if (apiType.value === 'paragraph') { if (apiSubmitType.value === 'paragraph') {
const data = { const data = {
...form.value, ...form.value,
paragraph_id_list: idList.value, paragraph_id_list: idList.value,
} }
paragraphApi.putBatchGenerateRelated(id, documentId, data, loading).then(() => { loadSharedApi({ type: 'paragraph', systemType: props.apiType })
MsgSuccess(t('views.document.generateQuestion.successMessage')) .putBatchGenerateRelated(id, documentId, data, loading)
emit('refresh') .then(() => {
dialogVisible.value = false MsgSuccess(t('views.document.generateQuestion.successMessage'))
}) emit('refresh')
} else if (apiType.value === 'document') { dialogVisible.value = false
})
} else if (apiSubmitType.value === 'document') {
const data = { const data = {
...form.value, ...form.value,
document_id_list: idList.value, document_id_list: idList.value,
state_list: stateMap[state.value], state_list: stateMap[state.value],
} }
documentApi.putBatchGenerateRelated(id, data, loading).then(() => { loadSharedApi({ type: 'knowledge', systemType: props.apiType })
MsgSuccess(t('views.document.generateQuestion.successMessage')) .putBatchGenerateRelated(id, data, loading)
emit('refresh') .then(() => {
dialogVisible.value = false MsgSuccess(t('views.document.generateQuestion.successMessage'))
}) emit('refresh')
} else if (apiType.value === 'knowledge') { dialogVisible.value = false
})
} else if (apiSubmitType.value === 'knowledge') {
const data = { const data = {
...form.value, ...form.value,
state_list: stateMap[state.value], state_list: stateMap[state.value],
} }
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: props.apiType })
.putGenerateRelated(id ? id : knowledgeId.value, data, loading) .putGenerateRelated(id ? id : knowledgeId.value, data, loading)
.then(() => { .then(() => {
MsgSuccess(t('views.document.generateQuestion.successMessage')) MsgSuccess(t('views.document.generateQuestion.successMessage'))
@ -192,7 +190,7 @@ const submitHandle = async (formEl: FormInstance) => {
function getModel() { function getModel() {
loading.value = true loading.value = true
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: props.apiType })
.getKnowledgeModel() .getKnowledgeModel()
.then((res: any) => { .then((res: any) => {
modelOptions.value = groupBy(res?.data, 'provider') modelOptions.value = groupBy(res?.data, 'provider')

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="breadcrumb ml-4 mt-4 mb-12 flex"> <div class="breadcrumb ml-4 mt-4 mb-12 flex">
<back-button :to="activeMenu" class="mt-4"></back-button> <back-button to="-1" class="mt-4"></back-button>
<div class="flex align-center"> <div class="flex align-center">
<el-avatar <el-avatar
v-if="isApplication && isAppIcon(current?.icon)" v-if="isApplication && isAppIcon(current?.icon)"
@ -21,94 +21,6 @@
<div class="ellipsis" :title="current?.name">{{ current?.name }}</div> <div class="ellipsis" :title="current?.name">{{ current?.name }}</div>
</div> </div>
<!-- <el-dropdown
placement="bottom"
trigger="click"
@command="changeMenu"
class="w-full"
style="display: block"
>
<div class="breadcrumb-hover flex-between cursor">
<div class="flex align-center">
<el-avatar
v-if="isApplication && isAppIcon(current?.icon)"
shape="square"
:size="24"
style="background: none"
class="mr-8"
>
<img :src="current?.icon" alt="" />
</el-avatar>
<LogoIcon
v-else-if="isApplication"
height="28px"
style="width: 28px; height: 28px; display: block"
/>
<KnowledgeIcon v-else-if="isKnowledge" :type="current?.type" />
<div class="ellipsis" :title="current?.name">{{ current?.name }}</div>
</div>
<el-button text>
<el-icon><CaretBottom /></el-icon>
</el-button>
</div>
<template #dropdown>
<el-scrollbar>
<div style="max-height: 400px">
<el-dropdown-menu>
<template v-for="(item, index) in list" :key="index">
<div :class="item.id === id ? 'dropdown-active' : ''">
<el-dropdown-item :command="item.id">
<div class="flex align-center">
<el-avatar
v-if="isApplication && isAppIcon(item?.icon)"
shape="square"
:size="24"
style="background: none"
class="mr-8"
>
<img :src="item?.icon" alt="" />
</el-avatar>
<el-avatar
v-else-if="isApplication"
:name="item.name"
pinyinColor
class="mr-12"
shape="square"
:size="24"
/>
<KnowledgeIcon v-if="isKnowledge" :type="item.type" />
<span class="ellipsis" :title="item?.name"> {{ item?.name }}</span>
</div>
</el-dropdown-item>
</div>
</template>
</el-dropdown-menu>
</div>
</el-scrollbar>
<div class="breadcrumb__footer border-t" style="padding: 8px 11px; min-width: 200px">
<template v-if="isApplication">
<div class="w-full text-left cursor" @click="openCreateDialog">
<el-button link>
<el-icon class="mr-4"><Plus /></el-icon>
{{ $t('views.application.createApplication') }}
</el-button>
</div>
</template>
<template v-else-if="isKnowledge">
<div class="w-full text-left cursor" @click="openCreateDialog">
<el-button link>
<el-icon class="mr-4"><Plus /></el-icon> {{ $t('views.knowledge.createKnowledge') }}
</el-button>
</div>
</template>
</div>
</template>
</el-dropdown> -->
</div> </div>
</template> </template>
@ -127,7 +39,7 @@ const {
params: { id }, params: { id },
} = route as any } = route as any
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -154,7 +66,7 @@ const isKnowledge = computed(() => {
function getKnowledgeDetail() { function getKnowledgeDetail() {
loading.value = true loading.value = true
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getKnowledgeDetail(id) .getKnowledgeDetail(id)
.then((res: any) => { .then((res: any) => {
current.value = res.data current.value = res.data

View File

@ -23,9 +23,12 @@ import AppMain from '@/layout/app-main/index.vue'
import useStore from '@/stores' import useStore from '@/stores'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
const {
params: { folderId }, // idknowledgeID
} = route as any
const isShared = computed(() => { const isShared = computed(() => {
return route.path.endsWith('hared') || route.name.includes('ResourceManagement') return folderId === 'shared' || route.name.includes('ResourceManagement')
}) })
const { theme } = useStore() const { theme } = useStore()
const isDefaultTheme = computed(() => { const isDefaultTheme = computed(() => {

View File

@ -150,9 +150,9 @@ const systemRouter = {
[RoleConst.ADMIN], [RoleConst.ADMIN],
[PermissionConst.SHARED_TOOL_READ], [PermissionConst.SHARED_TOOL_READ],
[EditionConst.IS_EE], [EditionConst.IS_EE],
'OR' 'OR',
) ),
] ],
}, },
component: () => import('@/views/system-shared/ToolSharedIndex.vue'), component: () => import('@/views/system-shared/ToolSharedIndex.vue'),
}, },
@ -169,9 +169,9 @@ const systemRouter = {
[RoleConst.ADMIN], [RoleConst.ADMIN],
[PermissionConst.SHARED_MODEL_READ], [PermissionConst.SHARED_MODEL_READ],
[EditionConst.IS_EE], [EditionConst.IS_EE],
'OR' 'OR',
) ),
] ],
}, },
component: () => import('@/views/system-shared/ModelSharedIndex.vue'), component: () => import('@/views/system-shared/ModelSharedIndex.vue'),
}, },

View File

@ -1,16 +1,22 @@
import knowledgeWorkspaceApi from '@/api/knowledge/knowledge' import knowledgeWorkspaceApi from '@/api/knowledge/knowledge'
import documentWorkspaceApi from '@/api/knowledge/document'
import paragraphWorkspaceApi from '@/api/knowledge/paragraph'
import modelWorkspaceApi from '@/api/model/model' import modelWorkspaceApi from '@/api/model/model'
import toolWorkspaceApi from '@/api/tool/tool' import toolWorkspaceApi from '@/api/tool/tool'
import sharedWorkspaceApi from '@/api/shared-workspace' import sharedWorkspaceApi from '@/api/shared-workspace'
import toolSystemShareApi from '@/api/system-shared/tool' import toolSystemShareApi from '@/api/system-shared/tool'
import modelSystemShareApi from '@/api/system-shared/model' import modelSystemShareApi from '@/api/system-shared/model'
import knowledgeSystemShareApi from '@/api/system-shared/knowledge' import knowledgeSystemShareApi from '@/api/system-shared/knowledge'
import documentSystemShareApi from '@/api/system-shared/document'
import paragraphSystemShareApi from '@/api/system-shared/paragraph'
// 普通 API // 普通 API
const workspaceApiMap = { const workspaceApiMap = {
knowledge: knowledgeWorkspaceApi, knowledge: knowledgeWorkspaceApi,
model: modelWorkspaceApi, model: modelWorkspaceApi,
tool: toolWorkspaceApi, tool: toolWorkspaceApi,
document: documentWorkspaceApi,
paragraph: paragraphWorkspaceApi,
} as any } as any
// 系统分享 API // 系统分享 API
@ -18,6 +24,8 @@ const systemShareApiMap = {
knowledge: knowledgeSystemShareApi, knowledge: knowledgeSystemShareApi,
model: modelSystemShareApi, model: modelSystemShareApi,
tool: toolSystemShareApi, tool: toolSystemShareApi,
document: documentSystemShareApi,
paragraph: paragraphSystemShareApi,
} as any } as any
// 资源管理 API // 资源管理 API

View File

@ -144,6 +144,7 @@ import { getImgUrl } from '@/utils/utils'
import { t } from '@/locales' import { t } from '@/locales'
import type Node from 'element-plus/es/components/tree/src/model/node' import type Node from 'element-plus/es/components/tree/src/model/node'
import documentApi from '@/api/knowledge/document' import documentApi from '@/api/knowledge/document'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()

View File

@ -60,7 +60,7 @@ import { useRouter, useRoute } from 'vue-router'
import SetRules from './upload/SetRules.vue' import SetRules from './upload/SetRules.vue'
import ResultSuccess from './upload/ResultSuccess.vue' import ResultSuccess from './upload/ResultSuccess.vue'
import UploadComponent from './upload/UploadComponent.vue' import UploadComponent from './upload/UploadComponent.vue'
import documentApi from '@/api/knowledge/document' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import { MsgConfirm, MsgSuccess } from '@/utils/message' import { MsgConfirm, MsgSuccess } from '@/utils/message'
import { t } from '@/locales' import { t } from '@/locales'
import useStore from '@/stores' import useStore from '@/stores'
@ -75,6 +75,16 @@ const {
query: { id }, // idknowledgeIDid query: { id }, // idknowledgeIDid
} = route } = route
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const SetRulesRef = ref() const SetRulesRef = ref()
const UploadComponentRef = ref() const UploadComponentRef = ref()
@ -94,11 +104,15 @@ async function next() {
}) })
if (id) { if (id) {
// QA // QA
documentApi.postQADocument(id as string, fd, loading).then((res) => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('common.submitSuccess')) .postQADocument(id as string, fd, loading)
clearStore() .then(() => {
router.push({ path: `/knowledge/${id}/${folderId}/document` }) MsgSuccess(t('common.submitSuccess'))
}) clearStore()
router.push({
path: `/knowledge/${id}/${folderId}/document`,
})
})
} }
} else if (documentsType.value === 'table') { } else if (documentsType.value === 'table') {
const fd = new FormData() const fd = new FormData()
@ -109,11 +123,15 @@ async function next() {
}) })
if (id) { if (id) {
// table // table
documentApi.postTableDocument(id as string, fd, loading).then((res) => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('common.submitSuccess')) .postTableDocument(id as string, fd, loading)
clearStore() .then(() => {
router.push({ path: `/knowledge/${id}/${folderId}/document` }) MsgSuccess(t('common.submitSuccess'))
}) clearStore()
router.push({
path: `/knowledge/${id}/${folderId}/document`,
})
})
} }
} else { } else {
if (active.value++ > 2) active.value = 0 if (active.value++ > 2) active.value = 0
@ -152,7 +170,9 @@ function submit() {
.then(() => { .then(() => {
MsgSuccess(t('common.submitSuccess')) MsgSuccess(t('common.submitSuccess'))
clearStore() clearStore()
router.push({ path: `/knowledge/${id}/${folderId}/document` }) router.push({
path: `/knowledge/${id}/${folderId}/document`,
})
}) })
.catch(() => { .catch(() => {
loading.value = false loading.value = false

View File

@ -66,7 +66,8 @@ const route = useRoute()
const { const {
params: { id }, // idknowledgeID params: { id }, // idknowledgeID
} = route as any } = route as any
const type = computed(() => {
const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -99,7 +100,7 @@ const loadTree = (node: any, resolve: any) => {
console.log(node) console.log(node)
if (node.isLeaf) return resolve([]) if (node.isLeaf) return resolve([])
const folder_id = node.level === 0 ? '' : node.data.id const folder_id = node.level === 0 ? '' : node.data.id
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getKnowledgeList(folder_id, loading) .getKnowledgeList(folder_id, loading)
.then((res: any) => { .then((res: any) => {
resolve(res.data) resolve(res.data)

View File

@ -7,26 +7,32 @@
<div class="flex-between"> <div class="flex-between">
<div> <div>
<el-button <el-button
v-if="knowledgeDetail.type === 0 && permissionPrecise.doc_create(id)" v-if="knowledgeDetail?.type === 0 && permissionPrecise.doc_create(id)"
type="danger" type="primary"
@click=" @click="
router.push({ path: `/knowledge/document/upload/${folderId}`, query: { id: id } }) router.push({
path: `/knowledge/document/upload/${folderId}`,
query: { id: id },
})
" "
>{{ $t('views.document.uploadDocument') }} >{{ $t('views.document.uploadDocument') }}
</el-button> </el-button>
<el-button <el-button
v-if="knowledgeDetail.type === 1 && permissionPrecise.doc_create(id)" v-if="knowledgeDetail?.type === 1 && permissionPrecise.doc_create(id)"
type="primary" type="primary"
@click="importDoc" @click="importDoc"
>{{ $t('views.document.importDocument') }} >{{ $t('views.document.importDocument') }}
</el-button> </el-button>
<el-button <el-button
v-if="knowledgeDetail.type === 2 && permissionPrecise.doc_create(id)" v-if="knowledgeDetail?.type === 2 && permissionPrecise.doc_create(id)"
type="primary" type="primary"
@click=" @click="
router.push({ router.push({
path: `/knowledge/import`, path: `/knowledge/import`,
query: { id: id, folder_token: knowledgeDetail.meta.folder_token }, query: {
id: id,
folder_token: knowledgeDetail?.meta.folder_token,
},
}) })
" "
>{{ $t('views.document.importDocument') }} >{{ $t('views.document.importDocument') }}
@ -73,7 +79,7 @@
divided divided
@click="syncLarkMulDocument" @click="syncLarkMulDocument"
:disabled="multipleSelection.length === 0" :disabled="multipleSelection.length === 0"
v-if="knowledgeDetail.type === 2 && permissionPrecise.doc_sync(id)" v-if="knowledgeDetail?.type === 2 && permissionPrecise.doc_sync(id)"
>{{ $t('views.document.syncDocument') }} >{{ $t('views.document.syncDocument') }}
</el-dropdown-item> </el-dropdown-item>
@ -103,7 +109,7 @@
class="mt-16" class="mt-16"
:data="documentData" :data="documentData"
:pagination-config="paginationConfig" :pagination-config="paginationConfig"
:quick-create="knowledgeDetail.type === 0 && permissionPrecise.doc_create(id)" :quick-create="knowledgeDetail?.type === 0 && permissionPrecise.doc_create(id)"
@sizeChange="handleSizeChange" @sizeChange="handleSizeChange"
@changePage="getList" @changePage="getList"
@cell-mouse-enter="cellMouseEnter" @cell-mouse-enter="cellMouseEnter"
@ -351,7 +357,7 @@
/> />
</span> </span>
<el-divider direction="vertical" /> <el-divider direction="vertical" />
<template v-if="knowledgeDetail.type === 0"> <template v-if="knowledgeDetail?.type === 0">
<span <span
class="mr-4" class="mr-4"
v-if=" v-if="
@ -451,7 +457,7 @@
</el-dropdown> </el-dropdown>
</span> </span>
</template> </template>
<template v-if="knowledgeDetail.type === 1 || knowledgeDetail.type === 2"> <template v-if="knowledgeDetail?.type === 1 || knowledgeDetail?.type === 2">
<span class="mr-4"> <span class="mr-4">
<el-button <el-button
type="primary" type="primary"
@ -571,14 +577,13 @@
<SyncWebDialog ref="SyncWebDialogRef" @refresh="refresh" /> <SyncWebDialog ref="SyncWebDialogRef" @refresh="refresh" />
<!-- 选择知识库 --> <!-- 选择知识库 -->
<SelectKnowledgeDialog ref="selectKnowledgeDialogRef" @refresh="refreshMigrate" /> <SelectKnowledgeDialog ref="selectKnowledgeDialogRef" @refresh="refreshMigrate" />
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="getList" /> <GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="getList" :apiType="apiType" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, onBeforeUnmount, computed } from 'vue' import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
import { useRouter, useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router' import { useRouter, useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import documentApi from '@/api/knowledge/document'
import ImportDocumentDialog from './component/ImportDocumentDialog.vue' import ImportDocumentDialog from './component/ImportDocumentDialog.vue'
import SyncWebDialog from '@/views/knowledge/component/SyncWebDialog.vue' import SyncWebDialog from '@/views/knowledge/component/SyncWebDialog.vue'
import SelectKnowledgeDialog from './component/SelectKnowledgeDialog.vue' import SelectKnowledgeDialog from './component/SelectKnowledgeDialog.vue'
@ -598,32 +603,12 @@ import permissionMap from '@/permission'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const { folder, user } = useStore()
const type = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const permissionPrecise = computed(() => {
return permissionMap['knowledge'][type.value]
})
const router = useRouter() const router = useRouter()
const { const {
params: { id, folderId }, // idknowledgeID params: { id, folderId }, // idknowledgeID
} = route as any } = route as any
const { common, document } = useStore()
const { common, knowledge, document } = useStore()
const storeKey = 'documents' const storeKey = 'documents'
const getTaskState = (status: string, taskType: number) => {
const statusList = status.split('').reverse()
return taskType - 1 > statusList.length + 1 ? 'n' : statusList[taskType - 1]
}
onBeforeRouteUpdate(() => { onBeforeRouteUpdate(() => {
common.savePage(storeKey, null) common.savePage(storeKey, null)
common.saveCondition(storeKey, null) common.saveCondition(storeKey, null)
@ -639,6 +624,25 @@ onBeforeRouteLeave((to: any) => {
}) })
} }
}) })
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const permissionPrecise = computed(() => {
return permissionMap['knowledge'][apiType.value]
})
const getTaskState = (status: string, taskType: number) => {
const statusList = status.split('').reverse()
return taskType - 1 > statusList.length + 1 ? 'n' : statusList[taskType - 1]
}
const beforePagination = computed(() => common.paginationConfig[storeKey]) const beforePagination = computed(() => common.paginationConfig[storeKey])
const beforeSearch = computed(() => common.search[storeKey]) const beforeSearch = computed(() => common.search[storeKey])
const embeddingContentDialogRef = ref<InstanceType<typeof EmbeddingContentDialog>>() const embeddingContentDialogRef = ref<InstanceType<typeof EmbeddingContentDialog>>()
@ -666,14 +670,14 @@ const title = ref('')
const selectKnowledgeDialogRef = ref() const selectKnowledgeDialogRef = ref()
const exportDocument = (document: any) => { const exportDocument = (document: any) => {
documentApi loadSharedApi({ type: 'document', systemType: apiType.value })
.exportDocument(document.name, document.knowledge_id, document.id, loading) .exportDocument(document.name, document.knowledge_id, document.id, loading)
.then(() => { .then(() => {
MsgSuccess(t('common.exportSuccess')) MsgSuccess(t('common.exportSuccess'))
}) })
} }
const exportDocumentZip = (document: any) => { const exportDocumentZip = (document: any) => {
documentApi loadSharedApi({ type: 'document', systemType: apiType.value })
.exportDocumentZip(document.name, document.knowledge_id, document.id, loading) .exportDocumentZip(document.name, document.knowledge_id, document.id, loading)
.then(() => { .then(() => {
MsgSuccess(t('common.exportSuccess')) MsgSuccess(t('common.exportSuccess'))
@ -691,10 +695,12 @@ function cancelTaskHandle(val: any) {
id_list: arr, id_list: arr,
type: val, type: val,
} }
documentApi.putBatchCancelTask(id, obj, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.tip.cancelSuccess')) .putBatchCancelTask(id, obj, loading)
multipleTableRef.value?.clearSelection() .then(() => {
}) MsgSuccess(t('views.document.tip.cancelSuccess'))
multipleTableRef.value?.clearSelection()
})
} }
function clearSelection() { function clearSelection() {
@ -734,9 +740,11 @@ function beforeCommand(attr: string, val: any, task_type?: number) {
} }
const cancelTask = (row: any, task_type: number) => { const cancelTask = (row: any, task_type: number) => {
documentApi.putCancelTask(id, row.id, { type: task_type }).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.tip.sendMessage')) .putCancelTask(id, row.id, { type: task_type })
}) .then(() => {
MsgSuccess(t('views.document.tip.sendMessage'))
})
} }
function importDoc() { function importDoc() {
@ -791,9 +799,11 @@ function syncLarkDocument(row: any) {
confirmButtonClass: 'color-danger', confirmButtonClass: 'color-danger',
}) })
.then(() => { .then(() => {
documentApi.putLarkDocumentSync(id, row.id).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
getList() .putLarkDocumentSync(id, row.id)
}) .then(() => {
getList()
})
}) })
.catch(() => {}) .catch(() => {})
} }
@ -805,9 +815,11 @@ function syncWebDocument(row: any) {
confirmButtonClass: 'color-danger', confirmButtonClass: 'color-danger',
}) })
.then(() => { .then(() => {
documentApi.putDocumentSync(row.knowledge_id, row.id).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
getList() .putDocumentSync(row.knowledge_id, row.id)
}) .then(() => {
getList()
})
}) })
.catch(() => {}) .catch(() => {})
} else { } else {
@ -822,9 +834,11 @@ function syncWebDocument(row: any) {
function refreshDocument(row: any) { function refreshDocument(row: any) {
const embeddingDocument = (stateList: Array<string>) => { const embeddingDocument = (stateList: Array<string>) => {
return documentApi.putDocumentRefresh(row.knowledge_id, row.id, stateList).then(() => { return loadSharedApi({ type: 'document', systemType: apiType.value })
getList() .putDocumentRefresh(row.knowledge_id, row.id, stateList)
}) .then(() => {
getList()
})
} }
embeddingContentDialogRef.value?.open(embeddingDocument) embeddingContentDialogRef.value?.open(embeddingDocument)
} }
@ -834,7 +848,7 @@ function rowClickHandle(row: any, column: any) {
return return
} }
router.push({ path: `/paragraph/${id}/${row.id}` }) router.push({ path: `/paragraph/${id}/${row.id}`, query: { type: apiType.value } })
} }
/* /*
@ -861,10 +875,12 @@ function syncMulDocument() {
arr.push(v.id) arr.push(v.id)
} }
}) })
documentApi.putMulSyncDocument(id, arr, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.sync.successMessage')) .putMulSyncDocument(id, arr, loading)
getList() .then(() => {
}) MsgSuccess(t('views.document.sync.successMessage'))
getList()
})
} }
function syncLarkMulDocument() { function syncLarkMulDocument() {
@ -874,10 +890,12 @@ function syncLarkMulDocument() {
arr.push(v.id) arr.push(v.id)
} }
}) })
documentApi.delMulLarkSyncDocument(id, arr, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.sync.successMessage')) .delMulLarkSyncDocument(id, arr, loading)
getList() .then(() => {
}) MsgSuccess(t('views.document.sync.successMessage'))
getList()
})
} }
function deleteMulDocument() { function deleteMulDocument() {
@ -896,11 +914,13 @@ function deleteMulDocument() {
arr.push(v.id) arr.push(v.id)
} }
}) })
documentApi.delMulDocument(id, arr, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.delete.successMessage')) .delMulDocument(id, arr, loading)
multipleTableRef.value?.clearSelection() .then(() => {
getList() MsgSuccess(t('views.document.delete.successMessage'))
}) multipleTableRef.value?.clearSelection()
getList()
})
}) })
.catch(() => {}) .catch(() => {})
} }
@ -908,10 +928,12 @@ function deleteMulDocument() {
function batchRefresh() { function batchRefresh() {
const arr: string[] = multipleSelection.value.map((v) => v.id) const arr: string[] = multipleSelection.value.map((v) => v.id)
const embeddingBatchDocument = (stateList: Array<string>) => { const embeddingBatchDocument = (stateList: Array<string>) => {
documentApi.putBatchRefresh(id, arr, stateList, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('views.document.tip.vectorizationSuccess')) .putBatchRefresh(id, arr, stateList, loading)
multipleTableRef.value?.clearSelection() .then(() => {
}) MsgSuccess(t('views.document.tip.vectorizationSuccess'))
multipleTableRef.value?.clearSelection()
})
} }
embeddingContentDialogRef.value?.open(embeddingBatchDocument) embeddingContentDialogRef.value?.open(embeddingBatchDocument)
} }
@ -926,10 +948,12 @@ function deleteDocument(row: any) {
}, },
) )
.then(() => { .then(() => {
documentApi.delDocument(id, row.id, loading).then(() => { loadSharedApi({ type: 'document', systemType: apiType.value })
MsgSuccess(t('common.deleteSuccess')) .delDocument(id, row.id, loading)
getList() .then(() => {
}) MsgSuccess(t('common.deleteSuccess'))
getList()
})
}) })
.catch(() => {}) .catch(() => {})
} }
@ -938,9 +962,9 @@ function deleteDocument(row: any) {
更新名称或状态 更新名称或状态
*/ */
function updateData(documentId: string, data: any, msg: string) { function updateData(documentId: string, data: any, msg: string) {
documentApi loadSharedApi({ type: 'document', systemType: apiType.value })
.putDocument(id, documentId, data, loading) .putDocument(id, documentId, data, loading)
.then((res) => { .then((res: any) => {
const index = documentData.value.findIndex((v) => v.id === documentId) const index = documentData.value.findIndex((v) => v.id === documentId)
documentData.value.splice(index, 1, res.data) documentData.value.splice(index, 1, res.data)
MsgSuccess(msg) MsgSuccess(msg)
@ -995,16 +1019,16 @@ function getList(bool?: boolean) {
order_by: orderBy.value, order_by: orderBy.value,
folder_id: folderId, folder_id: folderId,
} }
documentApi loadSharedApi({ type: 'document', systemType: apiType.value })
.getDocumentPage(id as string, paginationConfig.value, param, bool ? undefined : loading) .getDocumentPage(id as string, paginationConfig.value, param, bool ? undefined : loading)
.then((res) => { .then((res: any) => {
documentData.value = res.data.records documentData.value = res.data.records
paginationConfig.value.total = res.data.total paginationConfig.value.total = res.data.total
}) })
} }
function getDetail() { function getDetail() {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getKnowledgeDetail(id, loading) .getKnowledgeDetail(id, loading)
.then((res: any) => { .then((res: any) => {
knowledgeDetail.value = res.data knowledgeDetail.value = res.data

View File

@ -16,12 +16,24 @@
</div> </div>
</template> </template>
<template #extra> <template #extra>
<el-button @click="router.push({ path: `/knowledge` })">{{ <el-button
$t('views.knowledge.ResultSuccess.buttons.toknowledge') @click="
}}</el-button> router.push({
path: `/knowledge`,
query: {
type: apiType,
},
})
"
>{{ $t('views.knowledge.ResultSuccess.buttons.toknowledge') }}</el-button
>
<el-button <el-button
type="primary" type="primary"
@click="router.push({ path: `/knowledge/${data?.id}/${folderId}/document` })" @click="
router.push({
path: `/knowledge/${data?.id}/${folderId}/document`,
})
"
>{{ $t('views.knowledge.ResultSuccess.buttons.toDocument') }}</el-button >{{ $t('views.knowledge.ResultSuccess.buttons.toDocument') }}</el-button
> >
</template> </template>
@ -68,18 +80,29 @@ import { computed } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { numberFormat } from '@/utils/utils' import { numberFormat } from '@/utils/utils'
import { filesize, getImgUrl } from '@/utils/utils' import { filesize, getImgUrl } from '@/utils/utils'
const route = useRoute()
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
}) })
const router = useRouter()
const route = useRoute()
const { const {
params: { id, folderId }, // idknowledgeID params: { id, folderId }, // idknowledgeID
} = route as any } = route as any
const router = useRouter()
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const paragraph_count = computed(() => const paragraph_count = computed(() =>
props.data?.document_list.reduce((sum: number, obj: any) => (sum += obj.paragraph_count), 0), props.data?.document_list.reduce((sum: number, obj: any) => (sum += obj.paragraph_count), 0),
) )

View File

@ -123,9 +123,9 @@ import { ref, computed, onMounted, reactive, watch } from 'vue'
import ParagraphPreview from '@/views/knowledge/component/ParagraphPreview.vue' import ParagraphPreview from '@/views/knowledge/component/ParagraphPreview.vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { cutFilename } from '@/utils/utils' import { cutFilename } from '@/utils/utils'
import documentApi from '@/api/knowledge/document'
import useStore from '@/stores' import useStore from '@/stores'
import type { KeyValue } from '@/api/type/common' import type { KeyValue } from '@/api/type/common'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const { knowledge } = useStore() const { knowledge } = useStore()
const documentsFiles = computed(() => knowledge.documentsFiles) const documentsFiles = computed(() => knowledge.documentsFiles)
const splitPatternList = ref<Array<KeyValue<string, string>>>([]) const splitPatternList = ref<Array<KeyValue<string, string>>>([])
@ -133,6 +133,17 @@ const route = useRoute()
const { const {
query: { id }, // idknowledgeID query: { id }, // idknowledgeID
} = route as any } = route as any
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const radio = ref('1') const radio = ref('1')
const loading = ref(false) const loading = ref(false)
const paragraphList = ref<any[]>([]) const paragraphList = ref<any[]>([])
@ -187,7 +198,7 @@ function splitDocument() {
} }
}) })
} }
documentApi loadSharedApi({ type: 'document', systemType: apiType.value })
.postSplitDocument(id, fd) .postSplitDocument(id, fd)
.then((res: any) => { .then((res: any) => {
const list = res.data const list = res.data
@ -218,9 +229,11 @@ function splitDocument() {
} }
const initSplitPatternList = () => { const initSplitPatternList = () => {
documentApi.listSplitPattern(id, patternLoading).then((ok) => { loadSharedApi({ type: 'document', systemType: apiType.value })
splitPatternList.value = ok.data .listSplitPattern(id, patternLoading)
}) .then((ok) => {
splitPatternList.value = ok.data
})
} }
watch(radio, () => { watch(radio, () => {

View File

@ -196,24 +196,37 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onUnmounted, onMounted, computed, watch, nextTick } from 'vue' import { ref, reactive, onUnmounted, onMounted, computed, watch, nextTick } from 'vue'
import { useRoute } from 'vue-router'
import type { UploadFiles } from 'element-plus' import type { UploadFiles } from 'element-plus'
import { filesize, getImgUrl, isRightType } from '@/utils/utils' import { filesize, getImgUrl, isRightType } from '@/utils/utils'
import { MsgError } from '@/utils/message' import { MsgError } from '@/utils/message'
import documentApi from '@/api/knowledge/document' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import useStore from '@/stores' import useStore from '@/stores'
import { t } from '@/locales' import { t } from '@/locales'
const route = useRoute()
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const { knowledge } = useStore() const { knowledge } = useStore()
const documentsFiles = computed(() => knowledge.documentsFiles) const documentsFiles = computed(() => knowledge.documentsFiles)
const documentsType = computed(() => knowledge.documentsType) const documentsType = computed(() => knowledge.documentsType)
const form = ref({ const form = ref({
fileType: 'txt', fileType: 'txt',
fileList: [] as any fileList: [] as any,
}) })
const rules = reactive({ const rules = reactive({
fileList: [ fileList: [
{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' } { required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' },
] ],
}) })
const FormRef = ref() const FormRef = ref()
@ -223,16 +236,16 @@ watch(form.value, (value) => {
}) })
function downloadTemplate(type: string) { function downloadTemplate(type: string) {
documentApi.exportQATemplate( loadSharedApi({ type: 'document', systemType: apiType.value }).exportQATemplate(
`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`, `${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`,
type type,
) )
} }
function downloadTableTemplate(type: string) { function downloadTableTemplate(type: string) {
documentApi.exportTableTemplate( loadSharedApi({ type: 'document', systemType: apiType.value }).exportTableTemplate(
`${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`, `${type}${t('views.document.upload.template')}.${type == 'csv' ? type : 'xlsx'}`,
type type,
) )
} }
@ -303,13 +316,13 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
form.value = { form.value = {
fileType: 'txt', fileType: 'txt',
fileList: [] fileList: [],
} }
}) })
defineExpose({ defineExpose({
validate, validate,
form form,
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -323,5 +336,4 @@ defineExpose({
color: var(--el-color-primary-light-5); color: var(--el-color-primary-light-5);
} }
} }
</style> </style>

View File

@ -230,7 +230,7 @@ const {
meta: { activeMenu }, meta: { activeMenu },
params: { id }, params: { id },
} = route as any } = route as any
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -324,7 +324,7 @@ function getHitTestList() {
...formInline.value, ...formInline.value,
} }
if (isDataset.value) { if (isDataset.value) {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putKnowledgeHitTest(id, obj, loading) .putKnowledgeHitTest(id, obj, loading)
.then((res: any) => { .then((res: any) => {
paragraphDetail.value = res.data && arraySort(res.data, 'comprehensive_score', true) paragraphDetail.value = res.data && arraySort(res.data, 'comprehensive_score', true)

View File

@ -22,7 +22,7 @@
shadow="never" shadow="never"
class="mb-8 w-full" class="mb-8 w-full"
style="line-height: 22px" style="line-height: 22px"
v-if="detail.type === 0" v-if="detail?.type === 0"
> >
<div class="flex align-center"> <div class="flex align-center">
<el-avatar class="mr-8 avatar-blue" shape="square" :size="32"> <el-avatar class="mr-8 avatar-blue" shape="square" :size="32">
@ -78,7 +78,7 @@
<el-form-item <el-form-item
:label="$t('views.knowledge.form.source_url.label')" :label="$t('views.knowledge.form.source_url.label')"
prop="source_url" prop="source_url"
v-if="detail.type === 1" v-if="detail?.type === 1"
> >
<el-input <el-input
v-model="form.source_url" v-model="form.source_url"
@ -88,7 +88,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('views.knowledge.form.selector.label')" :label="$t('views.knowledge.form.selector.label')"
v-if="detail.type === 1" v-if="detail?.type === 1"
> >
<el-input <el-input
v-model="form.selector" v-model="form.selector"
@ -96,7 +96,7 @@
@blur="form.selector = form.selector.trim()" @blur="form.selector = form.selector.trim()"
/> />
</el-form-item> </el-form-item>
<el-form-item label="App ID" prop="app_id" v-if="detail.type === 2"> <el-form-item label="App ID" prop="app_id" v-if="detail?.type === 2">
<el-input <el-input
v-model="form.app_id" v-model="form.app_id"
:placeholder=" :placeholder="
@ -104,7 +104,7 @@
" "
/> />
</el-form-item> </el-form-item>
<el-form-item label="App Secret" prop="app_id" v-if="detail.type === 2"> <el-form-item label="App Secret" prop="app_id" v-if="detail?.type === 2">
<el-input <el-input
v-model="form.app_secret" v-model="form.app_secret"
type="password" type="password"
@ -114,7 +114,7 @@
" "
/> />
</el-form-item> </el-form-item>
<el-form-item label="Folder Token" prop="folder_token" v-if="detail.type === 2"> <el-form-item label="Folder Token" prop="folder_token" v-if="detail?.type === 2">
<el-input <el-input
v-model="form.folder_token" v-model="form.folder_token"
:placeholder=" :placeholder="
@ -123,7 +123,7 @@
/> />
</el-form-item> </el-form-item>
<div v-if="detail.type === 0"> <div v-if="detail?.type === 0">
<h4 class="title-decoration-1 mb-16"> <h4 class="title-decoration-1 mb-16">
{{ $t('common.otherSetting') }} {{ $t('common.otherSetting') }}
</h4> </h4>
@ -173,7 +173,7 @@ const {
params: { id }, params: { id },
} = route as any } = route as any
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -248,20 +248,20 @@ async function submit() {
}) })
.then(() => { .then(() => {
if (detail.value.type === 2) { if (detail.value.type === 2) {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putLarkKnowledge(id, obj, loading) .putLarkKnowledge(id, obj, loading)
.then(() => { .then(() => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putReEmbeddingKnowledge(id) .putReEmbeddingKnowledge(id)
.then(() => { .then(() => {
MsgSuccess(t('common.saveSuccess')) MsgSuccess(t('common.saveSuccess'))
}) })
}) })
} else { } else {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putKnowledge(id, obj, loading) .putKnowledge(id, obj, loading)
.then(() => { .then(() => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putReEmbeddingKnowledge(id) .putReEmbeddingKnowledge(id)
.then(() => { .then(() => {
MsgSuccess(t('common.saveSuccess')) MsgSuccess(t('common.saveSuccess'))
@ -272,17 +272,17 @@ async function submit() {
.catch(() => {}) .catch(() => {})
} else { } else {
if (detail.value.type === 2) { if (detail.value.type === 2) {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putLarkKnowledge(id, obj, loading) .putLarkKnowledge(id, obj, loading)
.then(() => { .then(() => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putReEmbeddingKnowledge(id) .putReEmbeddingKnowledge(id)
.then(() => { .then(() => {
MsgSuccess(t('common.saveSuccess')) MsgSuccess(t('common.saveSuccess'))
}) })
}) })
} else { } else {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putKnowledge(id, obj, loading) .putKnowledge(id, obj, loading)
.then(() => { .then(() => {
MsgSuccess(t('common.saveSuccess')) MsgSuccess(t('common.saveSuccess'))
@ -295,12 +295,12 @@ async function submit() {
} }
function getDetail() { function getDetail() {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getKnowledgeDetail(id, loading) .getKnowledgeDetail(id, loading)
.then((res: any) => { .then((res: any) => {
detail.value = res.data detail.value = res.data
cloneModelId.value = res.data?.embedding_model_id cloneModelId.value = res.data?.embedding_model_id
if (detail.value.type === '1' || detail.value.type === '2') { if (detail.value?.type === 1 || detail.value?.type === 2) {
form.value = res.data.meta form.value = res.data.meta
} }
}) })

View File

@ -176,7 +176,9 @@
:description="item.desc" :description="item.desc"
class="cursor" class="cursor"
@click=" @click="
router.push({ path: `/knowledge/${item.id}/${folder.currentFolder.id}/document` }) router.push({
path: `/knowledge/${item.id}/${folder.currentFolder.id || 'shared'}/document`,
})
" "
> >
<template #icon> <template #icon>
@ -188,7 +190,7 @@
</el-text> </el-text>
</template> </template>
<template #tag> <template #tag>
<el-tag v-if="isShared" type="info" class="info-tag"> <el-tag v-if="isShared || isSystemShare" type="info" class="info-tag">
{{ t('views.system.shared.label') }} {{ t('views.system.shared.label') }}
</el-tag> </el-tag>
</template> </template>
@ -250,7 +252,7 @@
icon="Setting" icon="Setting"
@click.stop=" @click.stop="
router.push({ router.push({
path: `/knowledge/${item.id}/${folder.currentFolder.id}/setting`, path: `/knowledge/${item.id}/${folder.currentFolder.id || 'shared'}/setting`,
}) })
" "
v-if="permissionPrecise.setting(item.id)" v-if="permissionPrecise.setting(item.id)"
@ -295,7 +297,7 @@
<component :is="currentCreateDialog" ref="CreateKnowledgeDialogRef" v-if="!isShared" /> <component :is="currentCreateDialog" ref="CreateKnowledgeDialogRef" v-if="!isShared" />
<CreateFolderDialog ref="CreateFolderDialogRef" v-if="!isShared" /> <CreateFolderDialog ref="CreateFolderDialogRef" v-if="!isShared" />
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" /> <GenerateRelatedDialog ref="GenerateRelatedDialogRef" :apiType="apiType" />
<SyncWebDialog ref="SyncWebDialogRef" v-if="!isShared" /> <SyncWebDialog ref="SyncWebDialogRef" v-if="!isShared" />
<AuthorizedWorkspace <AuthorizedWorkspace
ref="AuthorizedWorkspaceDialogRef" ref="AuthorizedWorkspaceDialogRef"
@ -328,7 +330,7 @@ const router = useRouter()
const route = useRoute() const route = useRoute()
const { folder, user, knowledge } = useStore() const { folder, user, knowledge } = useStore()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -338,14 +340,14 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['knowledge'][type.value] return permissionMap['knowledge'][apiType.value]
}) })
const isShared = computed(() => { const isShared = computed(() => {
return folder.currentFolder.id === 'share' return folder.currentFolder.id === 'share'
}) })
const isSystemShare = computed(() => { const isSystemShare = computed(() => {
return type.value === 'systemShare' return apiType.value === 'systemShare'
}) })
const loading = ref(false) const loading = ref(false)
@ -365,7 +367,6 @@ const paginationConfig = reactive({
}) })
const knowledgeList = ref<any[]>([]) const knowledgeList = ref<any[]>([])
const currentFolder = ref<any>({})
const CreateKnowledgeDialogRef = ref() const CreateKnowledgeDialogRef = ref()
const currentCreateDialog = shallowRef<any>(null) const currentCreateDialog = shallowRef<any>(null)
@ -393,7 +394,7 @@ function openCreateDialog(data: any) {
} }
function reEmbeddingKnowledge(row: any) { function reEmbeddingKnowledge(row: any) {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putReEmbeddingKnowledge(row.id) .putReEmbeddingKnowledge(row.id)
.then(() => { .then(() => {
MsgSuccess(t('common.submitSuccess')) MsgSuccess(t('common.submitSuccess'))
@ -418,14 +419,14 @@ function openGenerateDialog(row: any) {
} }
const exportKnowledge = (item: any) => { const exportKnowledge = (item: any) => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.exportKnowledge(item.name, item.id, loading) .exportKnowledge(item.name, item.id, loading)
.then(() => { .then(() => {
MsgSuccess(t('common.exportSuccess')) MsgSuccess(t('common.exportSuccess'))
}) })
} }
const exportZipKnowledge = (item: any) => { const exportZipKnowledge = (item: any) => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.exportZipKnowledge(item.name, item.id, loading) .exportZipKnowledge(item.name, item.id, loading)
.then(() => { .then(() => {
MsgSuccess(t('common.exportSuccess')) MsgSuccess(t('common.exportSuccess'))
@ -442,7 +443,7 @@ function deleteKnowledge(row: any) {
}, },
) )
.then(() => { .then(() => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.delKnowledge(row.id, loading) .delKnowledge(row.id, loading)
.then(() => { .then(() => {
const list = cloneDeep(knowledge.knowledgeList) const list = cloneDeep(knowledge.knowledgeList)
@ -483,7 +484,7 @@ function getList() {
[search_type.value]: search_form.value[search_type.value], [search_type.value]: search_form.value[search_type.value],
} }
knowledge knowledge
.asyncGetKnowledgeListPage(paginationConfig, isShared.value, type.value, params, loading) .asyncGetKnowledgeListPage(paginationConfig, isShared.value, apiType.value, params, loading)
.then((res: any) => { .then((res: any) => {
paginationConfig.total = res.data?.total paginationConfig.total = res.data?.total
knowledge.setKnowledgeList([...knowledgeList.value, ...res.data.records]) knowledge.setKnowledgeList([...knowledgeList.value, ...res.data.records])
@ -495,7 +496,10 @@ function clickFolder(item: any) {
} }
onMounted(() => { onMounted(() => {
if (type.value !== 'workspace') { if (apiType.value !== 'workspace') {
folder.setCurrentFolder({
id: '',
})
getList() getList()
} }
}) })

View File

@ -42,7 +42,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import { t } from '@/locales' import { t } from '@/locales'
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -70,7 +70,7 @@ const open = (id: string) => {
} }
const submit = () => { const submit = () => {
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.putSyncWebKnowledge(knowledgeId.value, method.value, loading) .putSyncWebKnowledge(knowledgeId.value, method.value, loading)
.then((res: any) => { .then((res: any) => {
emit('refresh', res.data) emit('refresh', res.data)

View File

@ -33,7 +33,7 @@ const emit = defineEmits(['refresh'])
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -65,11 +65,16 @@ const submitHandle = async () => {
folder_id: currentFolder.value?.id, folder_id: currentFolder.value?.id,
...BaseFormRef.value.form, ...BaseFormRef.value.form,
} }
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.postKnowledge(obj, loading) .postKnowledge(obj, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.createSuccess')) MsgSuccess(t('common.createSuccess'))
router.push({ path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document` }) router.push({
path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document`,
query: {
type: apiType.value,
},
})
emit('refresh') emit('refresh')
}) })
} else { } else {

View File

@ -62,7 +62,7 @@ const emit = defineEmits(['refresh'])
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -157,11 +157,16 @@ const submitHandle = async () => {
...BaseFormRef.value.form, ...BaseFormRef.value.form,
...knowledgeForm.value, ...knowledgeForm.value,
} }
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.postLarkKnowledge(obj, loading) .postLarkKnowledge(obj, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.createSuccess')) MsgSuccess(t('common.createSuccess'))
router.push({ path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document` }) router.push({
path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document`,
query: {
type: apiType.value,
},
})
emit('refresh') emit('refresh')
}) })
} else { } else {

View File

@ -54,7 +54,7 @@ const emit = defineEmits(['refresh'])
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -111,11 +111,16 @@ const submitHandle = async () => {
...BaseFormRef.value.form, ...BaseFormRef.value.form,
...knowledgeForm.value, ...knowledgeForm.value,
} }
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.postWebKnowledge(obj, loading) .postWebKnowledge(obj, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.createSuccess')) MsgSuccess(t('common.createSuccess'))
router.push({ path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document` }) router.push({
path: `/knowledge/${res.data.id}/${currentFolder.value.id}/document`,
query: {
type: apiType.value,
},
})
emit('refresh') emit('refresh')
}) })
} else { } else {

View File

@ -30,8 +30,7 @@ import { useRoute } from 'vue-router'
import useStore from '@/stores' import useStore from '@/stores'
const route = useRoute() const route = useRoute()
const { folder, knowledge } = useStore() const { folder, knowledge } = useStore()
const apiType = computed(() => {
const type = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -41,7 +40,7 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['knowledge'][type.value] return permissionMap['knowledge'][apiType.value]
}) })
const loading = ref(false) const loading = ref(false)

View File

@ -252,7 +252,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -390,7 +390,7 @@ const submit = () => {
?.validate() ?.validate()
.then(() => { .then(() => {
if (providerValue.value) { if (providerValue.value) {
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.createModel( .createModel(
{ {
...base_form_data.value, ...base_form_data.value,

View File

@ -134,7 +134,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -222,7 +222,7 @@ const list_base_model = (model_type: any, change?: boolean) => {
} }
const open = (provider: Provider, model: Model) => { const open = (provider: Provider, model: Model) => {
modelValue.value = model modelValue.value = model
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getModelById(model.id, formLoading) .getModelById(model.id, formLoading)
.then((ok: any) => { .then((ok: any) => {
modelValue.value = ok.data modelValue.value = ok.data
@ -255,7 +255,7 @@ const close = () => {
const submit = () => { const submit = () => {
dynamicsFormRef.value?.validate().then(() => { dynamicsFormRef.value?.validate().then(() => {
if (modelValue.value) { if (modelValue.value) {
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.updateModel( .updateModel(
modelValue.value.id, modelValue.value.id,
{ {

View File

@ -204,7 +204,7 @@ const deleteModel = () => {
} }
const cancelDownload = () => { const cancelDownload = () => {
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.pauseDownload(props.model.id) .pauseDownload(props.model.id)
.then(() => { .then(() => {
downModel.value = undefined downModel.value = undefined
@ -227,7 +227,7 @@ const icon = computed(() => {
const initInterval = () => { const initInterval = () => {
interval = setInterval(() => { interval = setInterval(() => {
if (currentModel.value.status === 'DOWNLOAD') { if (currentModel.value.status === 'DOWNLOAD') {
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getModelMetaById(props.model.id) .getModelMetaById(props.model.id)
.then((ok: any) => { .then((ok: any) => {
downModel.value = ok.data downModel.value = ok.data

View File

@ -95,7 +95,7 @@ const props = defineProps<{
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -112,7 +112,7 @@ const AddParamRef = ref()
const open = () => { const open = () => {
dialogVisible.value = true dialogVisible.value = true
loading.value = true loading.value = true
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.getModelParamsForm(props.model.id, loading) .getModelParamsForm(props.model.id, loading)
.then((ok: any) => { .then((ok: any) => {
loading.value = false loading.value = false
@ -164,7 +164,7 @@ function refresh(data: any, index: any) {
} }
function submit() { function submit() {
loadSharedApi({ type: 'model', systemType: type.value }) loadSharedApi({ type: 'model', systemType: apiType.value })
.updateModelParamsForm(props.model.id, modelParamsForm.value, loading) .updateModelParamsForm(props.model.id, modelParamsForm.value, loading)
.then((ok: any) => { .then((ok: any) => {
MsgSuccess(t('views.model.tip.saveSuccessMessage')) MsgSuccess(t('views.model.tip.saveSuccessMessage'))

View File

@ -131,7 +131,7 @@ import permissionMap from '@/permission'
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -141,10 +141,10 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['model'][type.value] return permissionMap['model'][apiType.value]
}) })
const isSystemShare = computed(() => { const isSystemShare = computed(() => {
return type.value === 'systemShare' return apiType.value === 'systemShare'
}) })
const commonList1 = ref() const commonList1 = ref()
const commonList2 = ref() const commonList2 = ref()
@ -202,7 +202,7 @@ const openCreateModel = (provider?: Provider, model_type?: string) => {
const list_model = () => { const list_model = () => {
const params = active_provider.value?.provider ? { provider: active_provider.value.provider } : {} const params = active_provider.value?.provider ? { provider: active_provider.value.provider } : {}
loadSharedApi({ type: 'model', isShared: isShared.value, systemType: type.value }) loadSharedApi({ type: 'model', isShared: isShared.value, systemType: apiType.value })
.getModel({ ...model_search_form.value, ...params }, list_model_loading) .getModel({ ...model_search_form.value, ...params }, list_model_loading)
.then((ok: any) => { .then((ok: any) => {
model_list.value = ok.data model_list.value = ok.data

View File

@ -68,11 +68,11 @@
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" /> <ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
<SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" /> <SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" />
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" /> <GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" :apiType="apiType" />
</el-card> </el-card>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, useSlots } from 'vue' import { ref, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { t } from '@/locales' import { t } from '@/locales'
import useStore from '@/stores' import useStore from '@/stores'
@ -80,17 +80,21 @@ import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vu
import ParagraphDialog from '@/views/paragraph/component/ParagraphDialog.vue' import ParagraphDialog from '@/views/paragraph/component/ParagraphDialog.vue'
import SelectDocumentDialog from '@/views/paragraph/component/SelectDocumentDialog.vue' import SelectDocumentDialog from '@/views/paragraph/component/SelectDocumentDialog.vue'
import { MsgSuccess, MsgConfirm } from '@/utils/message' import { MsgSuccess, MsgConfirm } from '@/utils/message'
const props = defineProps<{
data: any
disabled?: boolean
}>()
const { paragraph } = useStore() const { paragraph } = useStore()
const route = useRoute() const route = useRoute()
const { const {
params: { id, documentId }, params: { id, documentId },
query: { type },
} = route as any } = route as any
const props = defineProps<{
data: any const apiType = computed(() => {
disabled?: boolean return type as 'systemShare' | 'workspace' | 'systemManage'
}>() })
const emit = defineEmits(['changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph']) const emit = defineEmits(['changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph'])
const loading = ref(false) const loading = ref(false)

View File

@ -90,7 +90,7 @@ const {
params: { id, documentId }, // idknowledgeID params: { id, documentId }, // idknowledgeID
} = route as any } = route as any
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -147,7 +147,7 @@ const defaultProps = {
const loadTree = (node: any, resolve: any) => { const loadTree = (node: any, resolve: any) => {
if (node.isLeaf) return resolve([]) if (node.isLeaf) return resolve([])
const folder_id = node.level === 0 ? '' : node.data.id const folder_id = node.level === 0 ? '' : node.data.id
loadSharedApi({ type: 'knowledge', systemType: type.value }) loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getKnowledgeList(folder_id, optionLoading) .getKnowledgeList(folder_id, optionLoading)
.then((res: any) => { .then((res: any) => {
resolve(res.data) resolve(res.data)

View File

@ -138,30 +138,31 @@
</el-card> </el-card>
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" /> <ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
<SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" /> <SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" />
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" /> <GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" :apiType="apiType" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, onMounted, computed } from 'vue' import { reactive, ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { cloneDeep } from 'lodash'
import documentApi from '@/api/knowledge/document'
import paragraphApi from '@/api/knowledge/paragraph'
import ParagraphDialog from './component/ParagraphDialog.vue' import ParagraphDialog from './component/ParagraphDialog.vue'
import ParagraphCard from './component/ParagraphCard.vue' import ParagraphCard from './component/ParagraphCard.vue'
import SelectDocumentDialog from './component/SelectDocumentDialog.vue' import SelectDocumentDialog from './component/SelectDocumentDialog.vue'
import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue' import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue'
import { VueDraggable } from 'vue-draggable-plus' import { VueDraggable } from 'vue-draggable-plus'
import { MsgSuccess, MsgConfirm } from '@/utils/message' import { MsgSuccess, MsgConfirm } from '@/utils/message'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import useStore from '@/stores' import useStore from '@/stores'
import { t } from '@/locales' import { t } from '@/locales'
import disable$ from 'dingtalk-jsapi/api/ui/pullToRefresh/disable'
const { paragraph } = useStore()
const route = useRoute() const route = useRoute()
const { const {
params: { id, documentId }, params: { id, documentId },
query: { type },
} = route as any } = route as any
const apiType = computed(() => {
return type as 'systemShare' | 'workspace' | 'systemManage'
})
const SelectDocumentDialogRef = ref() const SelectDocumentDialogRef = ref()
const ParagraphDialogRef = ref() const ParagraphDialogRef = ref()
const loading = ref(false) const loading = ref(false)
@ -224,7 +225,7 @@ function deleteMulParagraph() {
}, },
) )
.then(() => { .then(() => {
paragraphApi loadSharedApi({ type: 'paragraph', systemType: apiType.value })
.putMulParagraph(id, documentId, multipleSelection.value, changeStateloading) .putMulParagraph(id, documentId, multipleSelection.value, changeStateloading)
.then(() => { .then(() => {
paragraphDetail.value = paragraphDetail.value.filter( paragraphDetail.value = paragraphDetail.value.filter(
@ -242,14 +243,6 @@ function batchSelectedHandle(bool: boolean) {
multipleSelection.value = [] multipleSelection.value = []
} }
function selectHandle(id: string) {
if (multipleSelection.value.includes(id)) {
multipleSelection.value.splice(multipleSelection.value.indexOf(id), 1)
} else {
multipleSelection.value.push(id)
}
}
function searchHandle() { function searchHandle() {
paginationConfig.current_page = 1 paginationConfig.current_page = 1
paragraphDetail.value = [] paragraphDetail.value = []
@ -262,13 +255,15 @@ function addParagraph() {
} }
function getDetail() { function getDetail() {
documentApi.getDocumentDetail(id, documentId, loading).then((res) => { loadSharedApi({ type: 'document', systemType: apiType.value })
documentDetail.value = res.data .getDocumentDetail(id, documentId, loading)
}) .then((res: any) => {
documentDetail.value = res.data
})
} }
function getParagraphList() { function getParagraphList() {
paragraphApi loadSharedApi({ type: 'paragraph', systemType: apiType.value })
.getParagraphPage( .getParagraphPage(
id, id,
documentId, documentId,
@ -276,7 +271,7 @@ function getParagraphList() {
search.value && { [searchType.value]: search.value }, search.value && { [searchType.value]: search.value },
loading, loading,
) )
.then((res) => { .then((res: any) => {
paragraphDetail.value = [...paragraphDetail.value, ...res.data.records] paragraphDetail.value = [...paragraphDetail.value, ...res.data.records]
paginationConfig.total = res.data.total paginationConfig.total = res.data.total
}) })
@ -314,7 +309,12 @@ function onEnd(event?: any) {
paragraph_id: paragraphDetail.value[event.newIndex].id, paragraph_id: paragraphDetail.value[event.newIndex].id,
new_position: paragraphDetail.value[event.newIndex].position, new_position: paragraphDetail.value[event.newIndex].position,
} }
paragraphApi.putAdjustPosition(id, documentId, obj, loading) loadSharedApi({ type: 'paragraph', systemType: apiType.value }).putAdjustPosition(
id,
documentId,
obj,
loading,
)
} }
onMounted(() => { onMounted(() => {

View File

@ -7,17 +7,17 @@
<div class="flex-between"> <div class="flex-between">
<div> <div>
<el-button type="primary" @click="createProblem" <el-button type="primary" @click="createProblem"
v-if="permissionPrecise.problem_create(id)" v-if="permissionPrecise.problem_create(id)"
> >
{{ $t('views.problem.createProblem') }} {{ $t('views.problem.createProblem') }}
</el-button> </el-button>
<el-button @click="relateProblem()" :disabled="multipleSelection.length === 0" <el-button @click="relateProblem()" :disabled="multipleSelection.length === 0"
v-if="permissionPrecise.problem_relate(id)" v-if="permissionPrecise.problem_relate(id)"
> >
{{ $t('views.problem.relateParagraph.title') }} {{ $t('views.problem.relateParagraph.title') }}
</el-button> </el-button>
<el-button @click="deleteMulDocument" :disabled="multipleSelection.length === 0" <el-button @click="deleteMulDocument" :disabled="multipleSelection.length === 0"
v-if="permissionPrecise.problem_delete(id)" v-if="permissionPrecise.problem_delete(id)"
> >
{{ $t('views.problem.setting.batchDelete') }} {{ $t('views.problem.setting.batchDelete') }}
</el-button> </el-button>
@ -160,9 +160,12 @@ import permissionMap from '@/permission'
const route = useRoute() const route = useRoute()
const {
params: { id }, // id
} = route as any
const { folder, user } = useStore() const { folder, user } = useStore()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -172,11 +175,9 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['knowledge'][type.value] return permissionMap['knowledge'][apiType.value]
}) })
const {
params: { id }, // id
} = route as any
const { problem } = useStore() const { problem } = useStore()

View File

@ -202,6 +202,7 @@ import { MsgError } from '@/utils/message'
import documentApi from '@/api/resource-management/document' import documentApi from '@/api/resource-management/document'
import useStore from '@/stores/modules-resource-management' import useStore from '@/stores/modules-resource-management'
import { t } from '@/locales' import { t } from '@/locales'
const { knowledge } = useStore() const { knowledge } = useStore()
const documentsFiles = computed(() => knowledge.documentsFiles) const documentsFiles = computed(() => knowledge.documentsFiles)
const documentsType = computed(() => knowledge.documentsType) const documentsType = computed(() => knowledge.documentsType)

View File

@ -134,14 +134,13 @@
</el-card> </el-card>
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" /> <ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
<SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" /> <SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" />
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" /> <GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" :apiType="apiType" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, onMounted, computed } from 'vue' import { reactive, ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import documentApi from '@/api/resource-management/document'
import paragraphApi from '@/api/resource-management/paragraph' import paragraphApi from '@/api/resource-management/paragraph'
import ParagraphDialog from './component/ParagraphDialog.vue' import ParagraphDialog from './component/ParagraphDialog.vue'
import ParagraphCard from './component/ParagraphCard.vue' import ParagraphCard from './component/ParagraphCard.vue'
@ -149,14 +148,18 @@ import SelectDocumentDialog from './component/SelectDocumentDialog.vue'
import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue' import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue'
import { VueDraggable } from 'vue-draggable-plus' import { VueDraggable } from 'vue-draggable-plus'
import { MsgSuccess, MsgConfirm } from '@/utils/message' import { MsgSuccess, MsgConfirm } from '@/utils/message'
import useStore from '@/stores/modules-resource-management'
import { t } from '@/locales' import { t } from '@/locales'
const { paragraph } = useStore() import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const { const {
params: { id, documentId }, params: { id, documentId },
query: { type },
} = route as any } = route as any
const apiType = computed(() => {
return type as 'systemShare' | 'workspace' | 'systemManage'
})
const SelectDocumentDialogRef = ref() const SelectDocumentDialogRef = ref()
const ParagraphDialogRef = ref() const ParagraphDialogRef = ref()
const loading = ref(false) const loading = ref(false)
@ -254,9 +257,11 @@ function addParagraph() {
} }
function getDetail() { function getDetail() {
documentApi.getDocumentDetail(id, documentId, loading).then((res) => { loadSharedApi({ type: 'document', systemType: apiType.value })
documentDetail.value = res.data .getDocumentDetail(id, documentId, loading)
}) .then((res) => {
documentDetail.value = res.data
})
} }
function getParagraphList() { function getParagraphList() {

View File

@ -117,7 +117,7 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -160,7 +160,7 @@ watch(debugVisible, (bool) => {
const submit = async (formEl: FormInstance | undefined) => { const submit = async (formEl: FormInstance | undefined) => {
const validate = formEl ? formEl.validate() : Promise.resolve() const validate = formEl ? formEl.validate() : Promise.resolve()
Promise.all([dynamicsFormRef.value?.validate(), validate]).then(() => { Promise.all([dynamicsFormRef.value?.validate(), validate]).then(() => {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.postToolDebug(form.value, loading) .postToolDebug(form.value, loading)
.then((res: any) => { .then((res: any) => {
if (res.code === 500) { if (res.code === 500) {

View File

@ -264,10 +264,13 @@ import useStore from '@/stores'
import permissionMap from '@/permission' import permissionMap from '@/permission'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const props = defineProps({
title: String,
})
const route = useRoute() const route = useRoute()
const { folder, user } = useStore() const { folder, user } = useStore()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -277,12 +280,10 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['tool'][type.value] return permissionMap['tool'][apiType.value]
}) })
const props = defineProps({
title: String,
})
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
const FieldFormDialogRef = ref() const FieldFormDialogRef = ref()
@ -424,7 +425,7 @@ const submit = async (formEl: FormInstance | undefined) => {
await formEl.validate((valid: any) => { await formEl.validate((valid: any) => {
if (valid) { if (valid) {
if (isEdit.value) { if (isEdit.value) {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(form.value?.id as string, form.value, loading) .putTool(form.value?.id as string, form.value, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.editSuccess')) MsgSuccess(t('common.editSuccess'))
@ -436,7 +437,7 @@ const submit = async (formEl: FormInstance | undefined) => {
folder_id: folder.currentFolder?.id, folder_id: folder.currentFolder?.id,
...form.value, ...form.value,
} }
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.postTool(obj, loading) .postTool(obj, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.createSuccess')) MsgSuccess(t('common.createSuccess'))

View File

@ -39,7 +39,7 @@ const emit = defineEmits(['refresh'])
const route = useRoute() const route = useRoute()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -68,7 +68,7 @@ watch(debugVisible, (bool) => {
const submit = async () => { const submit = async () => {
dynamicsFormRef.value.validate().then(() => { dynamicsFormRef.value.validate().then(() => {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(form.value?.id as string, form.value, loading) .putTool(form.value?.id as string, form.value, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.editSuccess')) MsgSuccess(t('common.editSuccess'))

View File

@ -313,7 +313,7 @@ import { t } from '@/locales'
const route = useRoute() const route = useRoute()
const { folder, user, tool } = useStore() const { folder, user, tool } = useStore()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -327,11 +327,11 @@ const isShared = computed(() => {
return folder.currentFolder.id === 'share' return folder.currentFolder.id === 'share'
}) })
const isSystemShare = computed(() => { const isSystemShare = computed(() => {
return type.value === 'systemShare' return apiType.value === 'systemShare'
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['tool'][type.value] return permissionMap['tool'][apiType.value]
}) })
const InitParamDrawerRef = ref() const InitParamDrawerRef = ref()
@ -370,7 +370,7 @@ function openCreateDialog(data?: any) {
} }
ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool') ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool')
if (data) { if (data) {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.getToolById(data?.id, loading) .getToolById(data?.id, loading)
.then((res: any) => { .then((res: any) => {
ToolFormDrawerRef.value.open(res.data) ToolFormDrawerRef.value.open(res.data)
@ -393,7 +393,7 @@ async function changeState(row: any) {
const obj = { const obj = {
is_active: !row.is_active, is_active: !row.is_active,
} }
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(row.id, obj, changeStateloading) .putTool(row.id, obj, changeStateloading)
.then(() => { .then(() => {
const list = cloneDeep(tool.toolList) const list = cloneDeep(tool.toolList)
@ -407,7 +407,7 @@ async function changeState(row: any) {
}) })
}) })
} else { } else {
const res = await loadSharedApi({ type: 'tool', systemType: type.value }).getToolById( const res = await loadSharedApi({ type: 'tool', systemType: apiType.value }).getToolById(
row.id, row.id,
changeStateloading, changeStateloading,
) )
@ -424,7 +424,7 @@ async function changeState(row: any) {
const obj = { const obj = {
is_active: !row.is_active, is_active: !row.is_active,
} }
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(row.id, obj, changeStateloading) .putTool(row.id, obj, changeStateloading)
.then(() => { .then(() => {
const list = cloneDeep(tool.toolList) const list = cloneDeep(tool.toolList)
@ -462,7 +462,7 @@ function copyTool(row: any) {
} }
function exportTool(row: any) { function exportTool(row: any) {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.exportTool(row.id, row.name, loading) .exportTool(row.id, row.name, loading)
.catch((e: any) => { .catch((e: any) => {
if (e.response.status !== 403) { if (e.response.status !== 403) {
@ -484,7 +484,7 @@ function deleteTool(row: any) {
}, },
) )
.then(() => { .then(() => {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.delTool(row.id, loading) .delTool(row.id, loading)
.then(() => { .then(() => {
const list = cloneDeep(tool.toolList) const list = cloneDeep(tool.toolList)
@ -498,7 +498,7 @@ function deleteTool(row: any) {
} }
function configInitParams(item: any) { function configInitParams(item: any) {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.getToolById(item?.id, changeStateloading) .getToolById(item?.id, changeStateloading)
.then((res: any) => { .then((res: any) => {
InitParamDrawerRef.value.open(res.data) InitParamDrawerRef.value.open(res.data)
@ -517,7 +517,7 @@ function addInternalFunction(data?: any, isEdit?: boolean) {
function confirmAddInternalFunction(data?: any, isEdit?: boolean) { function confirmAddInternalFunction(data?: any, isEdit?: boolean) {
if (isEdit) { if (isEdit) {
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.putTool(data?.id as string, { name: data.name }, loading) .putTool(data?.id as string, { name: data.name }, loading)
.then((res: any) => { .then((res: any) => {
MsgSuccess(t('common.saveSuccess')) MsgSuccess(t('common.saveSuccess'))
@ -531,7 +531,7 @@ function importTool(file: any) {
const formData = new FormData() const formData = new FormData()
formData.append('file', file.raw, file.name) formData.append('file', file.raw, file.name)
elUploadRef.value.clearFiles() elUploadRef.value.clearFiles()
loadSharedApi({ type: 'tool', systemType: type.value }) loadSharedApi({ type: 'tool', systemType: apiType.value })
.postImportTool(formData, loading) .postImportTool(formData, loading)
.then(async (res: any) => { .then(async (res: any) => {
if (res?.data) { if (res?.data) {
@ -572,7 +572,7 @@ function getList() {
[search_type.value]: search_form.value[search_type.value], [search_type.value]: search_form.value[search_type.value],
} }
tool tool
.asyncGetToolListPage(paginationConfig, isShared.value, type.value, params, loading) .asyncGetToolListPage(paginationConfig, isShared.value, apiType.value, params, loading)
.then((res: any) => { .then((res: any) => {
paginationConfig.total = res.data?.total paginationConfig.total = res.data?.total
tool.setToolList([...tool.toolList, ...res.data?.records]) tool.setToolList([...tool.toolList, ...res.data?.records])
@ -584,7 +584,7 @@ function clickFolder(item: any) {
} }
onMounted(() => { onMounted(() => {
if (type.value !== 'workspace') { if (apiType.value !== 'workspace') {
getList() getList()
} }
}) })

View File

@ -31,7 +31,7 @@ import useStore from '@/stores'
const route = useRoute() const route = useRoute()
const { folder, tool } = useStore() const { folder, tool } = useStore()
const type = computed(() => { const apiType = computed(() => {
if (route.path.includes('shared')) { if (route.path.includes('shared')) {
return 'systemShare' return 'systemShare'
} else if (route.path.includes('resource-management')) { } else if (route.path.includes('resource-management')) {
@ -41,7 +41,7 @@ const type = computed(() => {
} }
}) })
const permissionPrecise = computed(() => { const permissionPrecise = computed(() => {
return permissionMap['tool'][type.value] return permissionMap['tool'][apiType.value]
}) })
const loading = ref(false) const loading = ref(false)