mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-06 00:57:08 +08:00
fix: 默认选中第一个字典
This commit is contained in:
@@ -11,15 +11,15 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :xs="24" :sm="16" :md="17" :lg="18" :xl="19" :xxl="20" flex="1" class="h-full ov-hidden">
|
<a-col :xs="24" :sm="16" :md="17" :lg="18" :xl="19" :xxl="20" flex="1" class="h-full ov-hidden">
|
||||||
<GiTable
|
<GiTable
|
||||||
row-key="id"
|
row-key="id"
|
||||||
:data="dataList"
|
:data="dataList"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:scroll="{ x: '100%', y: '100%', minWidth: 600 }"
|
:scroll="{ x: '100%', y: '100%', minWidth: 600 }"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
:disabled-tools="['size']"
|
:disabled-tools="['size']"
|
||||||
:disabled-column-keys="['label']"
|
:disabled-column-keys="['label']"
|
||||||
@refresh="search"
|
@refresh="search"
|
||||||
>
|
>
|
||||||
<template #toolbar-left>
|
<template #toolbar-left>
|
||||||
<a-input v-model="queryForm.description" placeholder="请输入标签/描述" allow-clear @change="search">
|
<a-input v-model="queryForm.description" placeholder="请输入标签/描述" allow-clear @change="search">
|
||||||
|
|||||||
@@ -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="{
|
||||||
@@ -33,10 +38,10 @@
|
|||||||
</template>
|
</template>
|
||||||
</a-tree>
|
</a-tree>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
|
<DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
@@ -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