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

@@ -15,7 +15,8 @@ export default {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
'/admin-api/': {
// 要代理的地址
target: 'http://114.132.60.20:48080',
// target: 'http://114.132.60.20:48080',
target: 'http://192.168.1.231:48080',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
changeOrigin: true,

View File

@@ -58,10 +58,11 @@ const DictTag: React.FC<DictTagProps> = ({
.filter((dict: DictDataType) => valueArr.includes(String(dict.value)))
.map((dict: DictDataType) => {
// 处理 tag 类型
let colorType: TagProps['color'];
if (dict.colorType !== 'primary' && dict.colorType !== 'default') {
colorType = dict.colorType || undefined;
}
const colorType: TagProps['color'] = dict.colorType || undefined;
// if (dict.colorType !== "primary" && dict.colorType !== "default") {
// colorType = dict.colorType || undefined;
// }
// 处理自定义颜色
const customColor =
@@ -69,6 +70,9 @@ const DictTag: React.FC<DictTagProps> = ({
? dict?.cssClass
: undefined;
console.log(customColor, 'customColor');
console.log(colorType, 'colorType');
return (
<Tag
key={`${dict.value}-${dict.label}`}

View File

@@ -34,3 +34,10 @@ export const systemDataScopetStatus = [
{ label: '部门及以下数据权限', value: 4 },
{ label: '仅本人数据权限', value: 5 },
];
// ========== COMMON 模块 ==========
// 全局通用状态枚举
export const CommonStatusEnum = {
ENABLE: 0, // 开启
DISABLE: 1, // 禁用
};

View File

@@ -1,5 +1,5 @@
import type { ActionType } from '@ant-design/pro-components';
import React, { useRef, useState } from 'react';
import React, { useRef } from 'react';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import UploadCard from '@/components/Upload/UploadCard';

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