feat: add字典管理
Some checks failed
coverage CI / build (push) Has been cancelled

This commit is contained in:
2025-10-17 16:50:13 +08:00
parent b4d3535b91
commit 2821e864da
6 changed files with 54 additions and 18 deletions

View File

@@ -6,9 +6,23 @@ import {
ProFormText,
} from '@ant-design/pro-components';
import { Switch } from 'antd';
import { getSimpleMenusList, type MenuVO } from '@/services/system/menu';
import { CommonStatusEnum } from '@/constants';
import { useMessage } from '@/hooks/antd/useMessage';
import {
getSimpleMenusList,
type MenuVO,
updateMenu,
} from '@/services/system/menu';
import { handleTree } from '@/utils/tree';
const handleStatus = async (record: MenuVO) => {
const message = useMessage(); // 消息弹窗
const text = record.status === CommonStatusEnum.ENABLE ? '停用' : '启用';
await message.confirm(`确认要"${text}""${record.name}"菜单吗?`);
const status = record.status === 0 ? 1 : 0;
await updateMenu({ ...record, status });
};
export const baseMenuColumns: ProColumns<MenuVO>[] = [
{
title: '菜单名称',
@@ -54,10 +68,13 @@ export const baseMenuColumns: ProColumns<MenuVO>[] = [
title: '状态',
dataIndex: 'status',
width: 80,
render: (_, record: MenuVO) => (
render: (_dom, record: MenuVO, _: any, action: any) => (
<Switch
checked={record.status === 1}
disabled={true} // 可后续改为可编辑
onClick={async () => {
await handleStatus(record);
action?.reload();
}}
checked={record.status === 0}
/>
),
},
@@ -204,6 +221,7 @@ export const formColumns = (_type: string): ProFormColumnsType[] => [
renderFormItem: (_schema, _config, form) => {
const type = form.getFieldValue('type');
if (type !== 2) return null;
return (
<ProFormText
formItemProps={{
@@ -264,8 +282,8 @@ export const formColumns = (_type: string): ProFormColumnsType[] => [
valueType: 'radio',
fieldProps: {
options: [
{ label: '启用', value: 1 },
{ label: '禁用', value: 0 },
{ label: '启用', value: 0 },
{ label: '禁用', value: 1 },
],
},
},