mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-11 22:58:37 +08:00
fix: 默认选中第一个字典
This commit is contained in:
@@ -10,8 +10,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="dict-tree__container">
|
<div class="dict-tree__container">
|
||||||
<div class="dict-tree__tree">
|
<div class="dict-tree__tree">
|
||||||
<a-tree :data="(treeData as unknown as TreeNodeData[])" :field-names="{ key: 'id' }" block-node
|
<a-tree
|
||||||
@select="select">
|
:data="(treeData as unknown as TreeNodeData[])"
|
||||||
|
:field-names="{ key: 'id' }"
|
||||||
|
block-node
|
||||||
|
:selected-keys="selectedKeys"
|
||||||
|
@select="select"
|
||||||
|
>
|
||||||
<template #title="node">
|
<template #title="node">
|
||||||
<a-typography-paragraph
|
<a-typography-paragraph
|
||||||
:ellipsis="{
|
:ellipsis="{
|
||||||
@@ -58,13 +63,13 @@ const emit = defineEmits<{
|
|||||||
(e: 'node-click', keys: Array<any>): void
|
(e: 'node-click', keys: Array<any>): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const selectKey = ref()
|
const selectedKeys = ref()
|
||||||
// 选中节点
|
// 选中节点
|
||||||
const select = (keys: Array<any>) => {
|
const select = (keys: Array<any>) => {
|
||||||
if (selectKey.value === keys[0]) {
|
if (selectedKeys.value && selectedKeys.value[0] === keys[0]) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
selectKey.value = keys[0]
|
selectedKeys.value = keys
|
||||||
emit('node-click', keys)
|
emit('node-click', keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +94,9 @@ const getTreeData = async (query: DictQuery = { ...queryForm }) => {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
await nextTick(() => {
|
||||||
|
select([treeData.value[0]?.id])
|
||||||
|
})
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -122,7 +130,7 @@ const onMenuItemClick = (mode: string, node: DictResp) => {
|
|||||||
const res = await deleteDict(node.id)
|
const res = await deleteDict(node.id)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
Message.success('删除成功')
|
Message.success('删除成功')
|
||||||
getTreeData()
|
await getTreeData()
|
||||||
}
|
}
|
||||||
return res.success
|
return res.success
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
<IconCaretDown v-if="!isLeaf" />
|
<IconCaretDown v-if="!isLeaf" />
|
||||||
<IconIdcard v-else />
|
<IconIdcard v-else />
|
||||||
</template>
|
</template>
|
||||||
<template #title="nodeData">
|
<template #title="node">
|
||||||
<template v-if="index = getMatchIndex(nodeData?.title), index < 0">{{ nodeData?.title }}</template>
|
<template v-if="index = getMatchIndex(node?.title), index < 0">{{ node?.title }}</template>
|
||||||
<span v-else>{{ nodeData?.title?.substr(0, index) }}
|
<span v-else>{{ node?.title?.substr(0, index) }}
|
||||||
<span style="color: rgb(var(--arcoblue-6));">{{ nodeData?.title?.substr(index, searchKey.length) }}</span>
|
<span style="color: rgb(var(--arcoblue-6));">{{ node?.title?.substr(index, searchKey.length) }}</span>
|
||||||
{{ nodeData?.title?.substr(index + searchKey.length) }}
|
{{ node?.title?.substr(index + searchKey.length) }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</a-tree>
|
</a-tree>
|
||||||
@@ -50,6 +50,9 @@ const emit = defineEmits<{
|
|||||||
// 选中节点
|
// 选中节点
|
||||||
const selectedKeys = ref()
|
const selectedKeys = ref()
|
||||||
const select = (keys: Array<any>) => {
|
const select = (keys: Array<any>) => {
|
||||||
|
if (selectedKeys.value && selectedKeys.value[0] === keys[0]) {
|
||||||
|
return
|
||||||
|
}
|
||||||
selectedKeys.value = keys
|
selectedKeys.value = keys
|
||||||
emit('node-click', keys)
|
emit('node-click', keys)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user