Skip to content

Commit b01172b

Browse files
fix: lark document
1 parent 19b9e52 commit b01172b

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

ui/src/styles/element-plus.scss

+4
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,7 @@
423423
.el-table .el-popper {
424424
max-width: 500px !important;
425425
}
426+
427+
.el-tree {
428+
--el-tree-node-content-height: 32px;
429+
}

ui/src/views/dataset/ImportDocumentDataset.vue

+37-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
:label="$t('views.document.feishu.allCheck')"
4040
size="large"
4141
class="ml-24"
42+
@change="handleAllCheckChange"
4243
/>
4344
</div>
4445

@@ -49,7 +50,15 @@
4950
show-checkbox
5051
node-key="token"
5152
ref="treeRef"
52-
/>
53+
>
54+
<template #default="{ node, data }">
55+
<div class="custom-tree-node flex align-center lighter">
56+
<el-icon v-if="data.type === 'folder'"><FolderOpened /></el-icon>
57+
<el-icon v-else><Document /></el-icon>
58+
<span class="ml-4">{{ node.label }}</span>
59+
</div>
60+
</template>
61+
</el-tree>
5362
</el-form>
5463
</div>
5564
</el-scrollbar>
@@ -67,8 +76,6 @@
6776
<script setup lang="ts">
6877
import { ref, reactive, computed, onUnmounted } from 'vue'
6978
import { useRouter, useRoute } from 'vue-router'
70-
71-
import documentApi from '@/api/document'
7279
import { MsgConfirm, MsgSuccess } from '@/utils/message'
7380
import { t } from '@/locales'
7481
import type Node from 'element-plus/es/components/tree/src/model/node'
@@ -113,24 +120,46 @@ const props = {
113120
}
114121
115122
const loadNode = (node: Node, resolve: (nodeData: Tree[]) => void) => {
116-
console.log(node)
117123
const token = node.level === 0 ? folderToken : node.data.token // 根节点使用 folder_token,其他节点使用 node.data.token
118124
dataset
119125
.getLarkDocumentList(datasetId, token, {}, loading)
120-
.then((res) => {
121-
const data: any = res.data
122-
resolve(data.files as Tree[])
126+
.then((res: any) => {
127+
const nodes = res.data.files as Tree[]
128+
129+
nodes.forEach((childNode) => {
130+
if (childNode.is_exist) {
131+
treeRef.value?.setchecked(childNode.token, true, false)
132+
}
133+
})
134+
resolve(nodes)
123135
})
136+
124137
.catch((err) => {
125138
console.error('Failed to load tree nodes:', err)
126139
})
127140
}
128141
142+
const handleAllCheckChange = (checked: boolean) => {
143+
if (checked) {
144+
// 获取所有已加载的节点
145+
const nodes = Object.values(treeRef.value?.store.nodesMap || {}) as any[]
146+
nodes.forEach((node) => {
147+
// 只选择未禁用且是文件的节点
148+
if (!node.disabled) {
149+
treeRef.value?.setChecked(node.data, true, false)
150+
}
151+
})
152+
} else {
153+
treeRef.value?.setCheckedKeys([])
154+
}
155+
}
156+
129157
function submit() {
130158
loading.value = true
131159
// 选中的节点的token
132160
const checkedNodes = treeRef.value?.getCheckedNodes() || []
133-
const newList = checkedNodes.map((node: any) => {
161+
const filteredNodes = checkedNodes.filter((node: any) => !node.is_exist)
162+
const newList = filteredNodes.map((node: any) => {
134163
return {
135164
name: node.name,
136165
token: node.token,

0 commit comments

Comments
 (0)