优化修复网站导航的bug

This commit is contained in:
2024-08-28 23:55:01 +08:00
parent 31ec8e057a
commit 2655874948
34 changed files with 1764 additions and 849 deletions
@@ -47,9 +47,23 @@
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'title'">
<a-button
size="small"
type="link"
@click="onRadio"
:disabled="record.type == model"
class="cursor-pointer"
>{{ record.title }}</a-button
>
</template>
<template v-if="column.key === 'action'">
<template v-if="pageId == record.id">
<a-radio v-model:checked="checked" @click="onRadio(record)" />
<a-radio
v-model:checked="checked"
disabled
@click="onRadio(record)"
/>
</template>
<template v-else>
<lebal>
@@ -65,14 +79,16 @@
<script lang="ts" setup>
import { ref } from 'vue';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { listNavigation, pageNavigation } from '@/api/cms/navigation';
import { EleProTable } from 'ele-admin-pro';
import { toTreeData } from 'ele-admin-pro/es';
import { toTreeData, eachTreeData } from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types';
import type { Navigation, NavigationParam } from '@/api/cms/navigation/model';
import type { Menu } from '@/api/system/menu/model';
const props = defineProps<{
// 弹窗是否打开
@@ -81,6 +97,8 @@
title?: string;
// 修改回显的数据
data?: Navigation | null;
// 当前模型
model?: string;
}>();
const emit = defineEmits<{
@@ -100,6 +118,8 @@
const expandedRowKeys = ref<number[]>([]);
const searchText = ref('');
const position = ref(1);
// 菜单数据
const menuData = ref<Navigation[]>([]);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -137,9 +157,13 @@
return listNavigation({ ...where });
};
/* 表格渲染完成回调 */
const onDone: EleProTableDone<Navigation> = ({ data }) => {
menuData.value = data;
};
/* 数据转为树形结构 */
const parseData = (data: Navigation[]) => {
console.log(data);
return toTreeData({
data: data.map((d) => {
return { ...d, key: d.navigationId, value: d.navigationId };
@@ -149,6 +173,22 @@
});
};
/* 展开全部 */
const expandAll = () => {
let keys: number[] = [];
eachTreeData(menuData.value, (d) => {
if (d.children && d.children.length && d.navigationId) {
keys.push(d.navigationId);
}
});
expandedRowKeys.value = keys;
};
/* 折叠全部 */
const foldAll = () => {
expandedRowKeys.value = [];
};
/* 点击展开图标时触发 */
const onExpand = (expanded: boolean, record: Navigation) => {
if (expanded) {
@@ -16,6 +16,7 @@
v-model:visible="showEdit"
:data="current"
:title="placeholder"
:model="model"
@done="onChange"
/>
</div>
@@ -31,6 +32,7 @@
defineProps<{
value?: any;
placeholder?: string;
model?: string;
}>(),
{
placeholder: '请选择'