Skip to content

Commit 34d4faa

Browse files
committed
fix: 默认选中第一个字典
1 parent 4b90247 commit 34d4faa

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

src/views/system/dict/index.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
</a-col>
1212
<a-col :xs="24" :sm="16" :md="17" :lg="18" :xl="19" :xxl="20" flex="1" class="h-full ov-hidden">
1313
<GiTable
14-
row-key="id"
15-
:data="dataList"
16-
:columns="columns"
17-
:loading="loading"
18-
:scroll="{ x: '100%', y: '100%', minWidth: 600 }"
19-
:pagination="pagination"
20-
:disabled-tools="['size']"
21-
:disabled-column-keys="['label']"
22-
@refresh="search"
14+
row-key="id"
15+
:data="dataList"
16+
:columns="columns"
17+
:loading="loading"
18+
:scroll="{ x: '100%', y: '100%', minWidth: 600 }"
19+
:pagination="pagination"
20+
:disabled-tools="['size']"
21+
:disabled-column-keys="['label']"
22+
@refresh="search"
2323
>
2424
<template #toolbar-left>
2525
<a-input v-model="queryForm.description" placeholder="请输入标签/描述" allow-clear @change="search">

src/views/system/dict/tree/index.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
</div>
1111
<div class="dict-tree__container">
1212
<div class="dict-tree__tree">
13-
<a-tree :data="(treeData as unknown as TreeNodeData[])" :field-names="{ key: 'id' }" block-node
14-
@select="select">
13+
<a-tree
14+
:data="(treeData as unknown as TreeNodeData[])"
15+
:field-names="{ key: 'id' }"
16+
block-node
17+
:selected-keys="selectedKeys"
18+
@select="select"
19+
>
1520
<template #title="node">
1621
<a-typography-paragraph
1722
:ellipsis="{
@@ -33,10 +38,10 @@
3338
</template>
3439
</a-tree>
3540
</div>
36-
</div>
41+
</div>
3742

38-
<DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
39-
</div>
43+
<DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
44+
</div>
4045
</template>
4146

4247
<script setup lang="tsx">
@@ -58,13 +63,13 @@ const emit = defineEmits<{
5863
(e: 'node-click', keys: Array<any>): void
5964
}>()
6065
61-
const selectKey = ref()
66+
const selectedKeys = ref()
6267
// 选中节点
6368
const select = (keys: Array<any>) => {
64-
if (selectKey.value === keys[0]) {
69+
if (selectedKeys.value && selectedKeys.value[0] === keys[0]) {
6570
return
6671
}
67-
selectKey.value = keys[0]
72+
selectedKeys.value = keys
6873
emit('node-click', keys)
6974
}
7075
@@ -89,6 +94,9 @@ const getTreeData = async (query: DictQuery = { ...queryForm }) => {
8994
return null
9095
}
9196
}))
97+
await nextTick(() => {
98+
select([treeData.value[0]?.id])
99+
})
92100
} finally {
93101
loading.value = false
94102
}
@@ -122,7 +130,7 @@ const onMenuItemClick = (mode: string, node: DictResp) => {
122130
const res = await deleteDict(node.id)
123131
if (res.success) {
124132
Message.success('删除成功')
125-
getTreeData()
133+
await getTreeData()
126134
}
127135
return res.success
128136
} catch (error) {

src/views/system/user/dept/index.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
<IconCaretDown v-if="!isLeaf" />
2121
<IconIdcard v-else />
2222
</template>
23-
<template #title="nodeData">
24-
<template v-if="index = getMatchIndex(nodeData?.title), index < 0">{{ nodeData?.title }}</template>
25-
<span v-else>{{ nodeData?.title?.substr(0, index) }}
26-
<span style="color: rgb(var(--arcoblue-6));">{{ nodeData?.title?.substr(index, searchKey.length) }}</span>
27-
{{ nodeData?.title?.substr(index + searchKey.length) }}
23+
<template #title="node">
24+
<template v-if="index = getMatchIndex(node?.title), index < 0">{{ node?.title }}</template>
25+
<span v-else>{{ node?.title?.substr(0, index) }}
26+
<span style="color: rgb(var(--arcoblue-6));">{{ node?.title?.substr(index, searchKey.length) }}</span>
27+
{{ node?.title?.substr(index + searchKey.length) }}
2828
</span>
2929
</template>
3030
</a-tree>
@@ -50,6 +50,9 @@ const emit = defineEmits<{
5050
// 选中节点
5151
const selectedKeys = ref()
5252
const select = (keys: Array<any>) => {
53+
if (selectedKeys.value && selectedKeys.value[0] === keys[0]) {
54+
return
55+
}
5356
selectedKeys.value = keys
5457
emit('node-click', keys)
5558
}

0 commit comments

Comments
 (0)