reactor:【system 系统管理】menu 进一步统一代码风格

This commit is contained in:
YunaiV
2025-09-08 22:53:18 +08:00
parent 3564c123a1
commit 2becb1b09d
6 changed files with 33 additions and 70 deletions

View File

@@ -271,6 +271,7 @@ export function useGridColumns(): VxeTableGridOptions<SystemMenuApi.Menu>['colum
{
field: 'name',
title: '菜单名称',
minWidth: 250,
align: 'left',
fixed: 'left',
slots: { default: 'name' },
@@ -279,6 +280,7 @@ export function useGridColumns(): VxeTableGridOptions<SystemMenuApi.Menu>['colum
{
field: 'type',
title: '菜单类型',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_MENU_TYPE },
@@ -287,22 +289,27 @@ export function useGridColumns(): VxeTableGridOptions<SystemMenuApi.Menu>['colum
{
field: 'sort',
title: '显示排序',
minWidth: 100,
},
{
field: 'permission',
title: '权限标识',
minWidth: 200,
},
{
field: 'path',
title: '组件路径',
minWidth: 200,
},
{
field: 'componentName',
title: '组件名称',
minWidth: 200,
},
{
field: 'status',
title: '状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },

View File

@@ -23,7 +23,7 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
@@ -34,7 +34,7 @@ function handleCreate() {
/** 添加下级菜单 */
function handleAppend(row: SystemMenuApi.Menu) {
formModalApi.setData({ pid: row.id }).open();
formModalApi.setData({ parentId: row.id }).open();
}
/** 编辑菜单 */
@@ -46,15 +46,12 @@ function handleEdit(row: SystemMenuApi.Menu) {
async function handleDelete(row: SystemMenuApi.Menu) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
key: 'action_key_msg',
duration: 0,
});
try {
await deleteMenu(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
key: 'action_key_msg',
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
hideLoading();
}
@@ -62,7 +59,7 @@ async function handleDelete(row: SystemMenuApi.Menu) {
/** 切换树形展开/收缩状态 */
const isExpanded = ref(false);
function toggleExpand() {
function handleExpand() {
isExpanded.value = !isExpanded.value;
gridApi.grid.setAllTreeExpand(isExpanded.value);
}
@@ -84,6 +81,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
@@ -94,7 +92,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
transform: true,
reserve: true,
},
} as VxeTableGridOptions,
} as VxeTableGridOptions<SystemMenuApi.Menu>,
});
</script>
@@ -108,8 +106,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="菜单路由" url="https://doc.iocoder.cn/vue3/route/" />
</template>
<FormModal @success="onRefresh" />
<Grid>
<FormModal @success="handleRefresh" />
<Grid table-title="菜单列表">
<template #toolbar-tools>
<TableAction
:actions="[
@@ -123,7 +121,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
{
label: isExpanded ? '收缩' : '展开',
type: 'primary',
onClick: toggleExpand,
onClick: handleExpand,
},
]"
/>

View File

@@ -59,21 +59,22 @@ const [Modal, modalApi] = useVbenModal({
return;
}
// 加载数据
let data = modalApi.getData<SystemMenuApi.Menu>();
if (!data) {
const data = modalApi.getData<SystemMenuApi.Menu>();
if (!data || !data.id) {
// 设置上级
await formApi.setValues(data);
return;
}
if (data.id) {
modalApi.lock();
try {
data = await getMenu(data.id);
} finally {
modalApi.unlock();
modalApi.lock();
try {
formData.value = await getMenu(data.id);
// 设置到 values
if (formData.value) {
await formApi.setValues(formData.value);
}
} finally {
modalApi.unlock();
}
// 设置到 values
formData.value = data;
await formApi.setValues(formData.value);
},
});
</script>

View File

@@ -46,7 +46,6 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'Input',
rules: 'required',
},
// TODO @xingyu【重要】这个字段出不来
{
fieldName: 'deptId',
label: '归属部门',
@@ -228,7 +227,6 @@ export function useImportFormSchema(): VbenFormSchema[] {
rules: 'required',
help: '仅允许导入 xls、xlsx 格式文件',
},
// TODO @xingyu【重要】看不到 switch 这个按钮
{
fieldName: 'updateSupport',
label: '是否覆盖',