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

@@ -19,6 +19,9 @@ export const baseDictDataColumns: ProColumns<DictDataVO>[] = [
title: '字典标签',
dataIndex: 'label',
width: 120,
render: (_, record) => (
<Tag color={record.cssClass || record.colorType}>{record.label}</Tag>
),
},
{
title: '字典键值',
@@ -44,6 +47,9 @@ export const baseDictDataColumns: ProColumns<DictDataVO>[] = [
title: '颜色类型',
dataIndex: 'colorType',
width: 80,
render: (_, record) => (
<Tag color={record.colorType}>{record.colorType}</Tag>
),
},
{
title: 'CSS Class',
@@ -157,23 +163,23 @@ export const formColumns = (_type: string): ProFormColumnsType[] => [
fieldProps: {
options: [
{
label: '默认(waiting)',
value: 'waiting',
label: <Tag color="default">(default)</Tag>,
value: 'default',
},
{
label: '成功(success)',
label: <Tag color="success">(success)</Tag>,
value: 'success',
},
{
label: '信息(processing)',
label: <Tag color="processing">(processing)</Tag>,
value: 'processing',
},
{
label: '失败(error)',
label: <Tag color="error">(error)</Tag>,
value: 'error',
},
{
label: '警告(warning)',
label: <Tag color="warning">(warning)</Tag>,
value: 'warning',
},
],

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 },
],
},
},