|
@ -9,7 +9,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
<a-row :gutter="16"> |
|
|
<a-row :gutter="16"> |
|
|
<!-- 左侧目录树 --> |
|
|
<!-- 左侧目录树 --> |
|
|
<a-col :span="4"> |
|
|
|
|
|
|
|
|
<a-col :span="5"> |
|
|
<a-card class="tree-card"> |
|
|
<a-card class="tree-card"> |
|
|
<template #title> |
|
|
<template #title> |
|
|
<span class="card-title"> |
|
|
<span class="card-title"> |
|
@ -17,12 +17,27 @@ |
|
|
<span class="title-text">知识库目录</span> |
|
|
<span class="title-text">知识库目录</span> |
|
|
</span> |
|
|
</span> |
|
|
</template> |
|
|
</template> |
|
|
<a-tree v-model:selectedKeys="selectedKeys" :tree-data="treeData" @select="onSelect" /> |
|
|
|
|
|
|
|
|
<div class="h-full w-full overflow-auto"> |
|
|
|
|
|
<a-tree |
|
|
|
|
|
v-model:selectedKeys="selectedKeys" |
|
|
|
|
|
:tree-data="treeData" |
|
|
|
|
|
show-icon |
|
|
|
|
|
@select="onSelect" |
|
|
|
|
|
> |
|
|
|
|
|
<template #title="{ title, key, isLeafCustom }"> |
|
|
|
|
|
<span v-if="!isLeafCustom">{{ title }}</span> |
|
|
|
|
|
<div v-else class="w-[100%] flex items-center"> |
|
|
|
|
|
<FileOutlined class="mr-2" v-if="isLeafCustom" /> |
|
|
|
|
|
<span class="truncate">{{ title }}</span> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
</a-tree> |
|
|
|
|
|
</div> |
|
|
</a-card> |
|
|
</a-card> |
|
|
</a-col> |
|
|
</a-col> |
|
|
|
|
|
|
|
|
<!-- 右侧内容区 --> |
|
|
<!-- 右侧内容区 --> |
|
|
<a-col :span="20"> |
|
|
|
|
|
|
|
|
<a-col :span="19"> |
|
|
<a-card class="content-card"> |
|
|
<a-card class="content-card"> |
|
|
<template #title> |
|
|
<template #title> |
|
|
<span class="card-title"> |
|
|
<span class="card-title"> |
|
@ -108,11 +123,15 @@ |
|
|
ExportOutlined, |
|
|
ExportOutlined, |
|
|
LeftOutlined, |
|
|
LeftOutlined, |
|
|
PaperClipOutlined, |
|
|
PaperClipOutlined, |
|
|
|
|
|
CarryOutOutlined, |
|
|
FileOutlined, |
|
|
FileOutlined, |
|
|
} from '@ant-design/icons-vue'; |
|
|
} from '@ant-design/icons-vue'; |
|
|
import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase'; |
|
|
import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase'; |
|
|
import { useRoute, useRouter } from 'vue-router'; |
|
|
import { useRoute, useRouter } from 'vue-router'; |
|
|
import { useUserStore } from '@/store/modules/user'; |
|
|
import { useUserStore } from '@/store/modules/user'; |
|
|
|
|
|
import { getDictionaryByTypeName } from '@/utils/dict'; |
|
|
|
|
|
import { DictEnum } from '@/enums/dictEnum'; |
|
|
|
|
|
|
|
|
// 添加下载方法 |
|
|
// 添加下载方法 |
|
|
const handleDownload = (file) => { |
|
|
const handleDownload = (file) => { |
|
|
window.open(file.url, '_blank'); |
|
|
window.open(file.url, '_blank'); |
|
@ -157,12 +176,23 @@ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
watch(selectedKeys, async (newVal) => { |
|
|
watch(selectedKeys, async (newVal) => { |
|
|
|
|
|
console.log('newVal: ', newVal); |
|
|
if (!newVal.length) return; |
|
|
if (!newVal.length) return; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 树节点选择事件 |
|
|
|
|
|
const onSelect = async (selectedKeys: string[], info: any) => { |
|
|
|
|
|
console.log('selected', selectedKeys, info); |
|
|
|
|
|
if (!selectedKeys.length || !info?.node?.dataRef?.isLeafCustom) { |
|
|
|
|
|
curRowDetail.value = {}; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
loading.value = true; |
|
|
loading.value = true; |
|
|
try { |
|
|
try { |
|
|
const res = await findOneById({ id: newVal[0] }); |
|
|
|
|
|
|
|
|
const res = await findOneById({ id: selectedKeys[0] }); |
|
|
curRowDetail.value = res; |
|
|
curRowDetail.value = res; |
|
|
const count = await addReadCount({ id: newVal[0] }); |
|
|
|
|
|
|
|
|
const count = await addReadCount({ id: selectedKeys[0] }); |
|
|
console.log('count: ', count); |
|
|
console.log('count: ', count); |
|
|
if (count) { |
|
|
if (count) { |
|
|
curRowDetail.value.readCount = count; |
|
|
curRowDetail.value.readCount = count; |
|
@ -172,21 +202,36 @@ |
|
|
} finally { |
|
|
} finally { |
|
|
loading.value = false; |
|
|
loading.value = false; |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 树节点选择事件 |
|
|
|
|
|
const onSelect = (selectedKeys: string[], info: any) => { |
|
|
|
|
|
console.log('selected', selectedKeys, info); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const initTreeData = async () => { |
|
|
const initTreeData = async () => { |
|
|
const list = await fetchKnowledgeBaseList(); |
|
|
|
|
|
treeData.value = list.map((e) => { |
|
|
|
|
|
|
|
|
let tree: any = []; |
|
|
|
|
|
// 获取功能模块字典 |
|
|
|
|
|
const tagList = await getDictionaryByTypeName(DictEnum.TAG_TYPE); |
|
|
|
|
|
console.log('tagList: ', tagList); |
|
|
|
|
|
|
|
|
|
|
|
const list = await fetchKnowledgeBaseList({}); |
|
|
|
|
|
|
|
|
|
|
|
tree = tagList?.map((e) => { |
|
|
|
|
|
let tagName = e.label; |
|
|
return { |
|
|
return { |
|
|
title: e.title, |
|
|
|
|
|
key: e.id, |
|
|
|
|
|
|
|
|
title: e.label, |
|
|
|
|
|
key: e.value, |
|
|
|
|
|
isLeafCustom: false, |
|
|
|
|
|
selectable: false, |
|
|
|
|
|
children: list |
|
|
|
|
|
.filter((e) => e.tags?.includes(tagName)) |
|
|
|
|
|
.map((item) => { |
|
|
|
|
|
return { |
|
|
|
|
|
title: item.title, |
|
|
|
|
|
key: item.id, |
|
|
|
|
|
isLeafCustom: true, |
|
|
|
|
|
}; |
|
|
|
|
|
}), |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
treeData.value = tree; |
|
|
console.log('route: ', route); |
|
|
console.log('route: ', route); |
|
|
if (route.query.id) { |
|
|
if (route.query.id) { |
|
|
selectedKeys.value = [route.query.id as string]; |
|
|
selectedKeys.value = [route.query.id as string]; |
|
|