From 34cd91944173a0877c7a38638ac86253a3272f1e Mon Sep 17 00:00:00 2001 From: qianpw <2233607957@qq.com> Date: Wed, 24 Sep 2025 15:28:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 4 +- config/proxy.ts | 16 +-- src/pages/system/dict/config.tsx | 7 +- src/pages/system/dict/data/config.tsx | 189 ++++++++++++++++++++++++++ src/pages/system/dict/data/index.tsx | 139 +++++++++++++++++++ src/pages/system/dict/index.tsx | 13 ++ src/services/system/dict/dict.data.ts | 9 +- 7 files changed, 364 insertions(+), 13 deletions(-) create mode 100644 src/pages/system/dict/data/config.tsx create mode 100644 src/pages/system/dict/data/index.tsx diff --git a/.env.local b/.env.local index c2c5dac..9b994ea 100644 --- a/.env.local +++ b/.env.local @@ -4,8 +4,8 @@ NODE_ENV=development VITE_DEV=true # 请求路径 -# VITE_BASE_URL='http://114.132.60.20:48080' -VITE_BASE_URL='http://192.168.1.114:48080' # 理君 +VITE_BASE_URL='http://114.132.60.20:48080' +# VITE_BASE_URL='http://192.168.1.114:48080' # 理君 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务 diff --git a/config/proxy.ts b/config/proxy.ts index 279a12f..e1a47c0 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -13,9 +13,9 @@ export default { // 如果需要自定义本地开发服务器 请取消注释按需调整 dev: { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** - "/admin-api/": { + '/admin-api/': { // 要代理的地址 - target: "http://192.168.1.114:48080", + target: 'http://114.132.60.20:48080', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie changeOrigin: true, @@ -27,17 +27,17 @@ export default { */ test: { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** - "/api/": { - target: "https://proapi.azurewebsites.net", + '/api/': { + target: 'https://proapi.azurewebsites.net', changeOrigin: true, - pathRewrite: { "^": "" }, + pathRewrite: { '^': '' }, }, }, pre: { - "/api/": { - target: "your pre url", + '/api/': { + target: 'your pre url', changeOrigin: true, - pathRewrite: { "^": "" }, + pathRewrite: { '^': '' }, }, }, }; diff --git a/src/pages/system/dict/config.tsx b/src/pages/system/dict/config.tsx index c2092d8..3e90129 100644 --- a/src/pages/system/dict/config.tsx +++ b/src/pages/system/dict/config.tsx @@ -13,6 +13,7 @@ export const baseDictTypeColumns: ProColumns[] = [ dataIndex: 'id', width: 80, align: 'left', + hideInSearch: true, }, { title: '字典名称', @@ -41,6 +42,7 @@ export const baseDictTypeColumns: ProColumns[] = [ title: '备注', dataIndex: 'remark', width: 120, + hideInSearch: true, // 在搜索表单中隐藏 }, { title: '创建时间', @@ -63,7 +65,7 @@ export const baseDictTypeColumns: ProColumns[] = [ }, ]; -export const formColumns = (_type: string): ProFormColumnsType[] => [ +export const formColumns = (type: string): ProFormColumnsType[] => [ { title: '字典名称', dataIndex: 'name', @@ -84,6 +86,9 @@ export const formColumns = (_type: string): ProFormColumnsType[] => [ title: '字典类型', dataIndex: 'type', valueType: 'text', + fieldProps: { + disabled: type === 'update', + }, colProps: { span: 12, }, diff --git a/src/pages/system/dict/data/config.tsx b/src/pages/system/dict/data/config.tsx new file mode 100644 index 0000000..2eeb93c --- /dev/null +++ b/src/pages/system/dict/data/config.tsx @@ -0,0 +1,189 @@ +import type { + ProColumns, + ProFormColumnsType, +} from '@ant-design/pro-components'; +import { Tag } from 'antd'; +import dayjs from 'dayjs'; +import { tenantStatus } from '@/constants'; +import type { DictDataVO } from '@/services/system/dict/dict.data'; +import { getStatusLabel } from '@/utils/constant'; + +export const baseDictDataColumns: ProColumns[] = [ + { + title: '字典编码', + dataIndex: 'id', + width: 80, + hideInSearch: true, + }, + { + title: '字典标签', + dataIndex: 'label', + width: 120, + }, + { + title: '字典键值', + dataIndex: 'value', + width: 120, + }, + { + title: '字典排序', + dataIndex: 'sort', + width: 80, + }, + { + title: '状态', + dataIndex: 'status', + width: 80, + render: (_, record) => ( + + {getStatusLabel(tenantStatus, record.status)} + + ), + }, + { + title: '颜色类型', + dataIndex: 'colorType', + width: 80, + }, + { + title: 'CSS Class', + dataIndex: 'cssClass', + width: 120, + }, + { + title: '备注', + dataIndex: 'remark', + width: 120, + }, + { + title: '创建时间', + dataIndex: 'createTime', + valueType: 'dateRange', + search: { + transform: (value) => { + return { + 'createTime[0]': dayjs(value[0]) + .startOf('day') + .format('YYYY-MM-DD HH:mm:ss'), + 'createTime[1]': dayjs(value[1]) + .endOf('day') + .format('YYYY-MM-DD HH:mm:ss'), + }; + }, + }, + render: (_, record: DictDataVO) => + dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'), + }, +]; + +export const formColumns = (_type: string): ProFormColumnsType[] => [ + { + title: '字典类型', + dataIndex: 'dictType', + fieldProps: { + disabled: true, + }, + }, + { + title: '字典标签', + dataIndex: 'label', + formItemProps: { + rules: [ + { + required: true, + message: '请输入字典标签', + }, + ], + }, + }, + { + title: '字典键值', + dataIndex: 'value', + formItemProps: { + rules: [ + { + required: true, + message: '请输入字典键值', + }, + ], + }, + }, + { + title: '显示排序', + dataIndex: 'sort', + valueType: 'digit', + fieldProps: { + min: 0, + max: 9999, + }, + formItemProps: { + rules: [ + { + required: true, + message: '请输入排序', + }, + ], + }, + }, + { + title: '状态', + dataIndex: 'status', + valueType: 'select', + fieldProps: { + options: [ + { + label: '启用', + value: 1, + }, + { + label: '禁用', + value: 0, + }, + ], + }, + formItemProps: { + rules: [ + { + required: true, + }, + ], + }, + }, + { + title: '颜色类型', + dataIndex: 'colorType', + valueType: 'select', + fieldProps: { + options: [ + { + label: '默认(waiting)', + value: 'waiting', + }, + { + label: '成功(success)', + value: 'success', + }, + { + label: '信息(processing)', + value: 'processing', + }, + { + label: '失败(error)', + value: 'error', + }, + { + label: '警告(warning)', + value: 'warning', + }, + ], + }, + }, + { + title: 'CSS Class', + dataIndex: 'cssClass', + }, + { + title: '备注', + dataIndex: 'remark', + }, +]; diff --git a/src/pages/system/dict/data/index.tsx b/src/pages/system/dict/data/index.tsx new file mode 100644 index 0000000..7cdb76f --- /dev/null +++ b/src/pages/system/dict/data/index.tsx @@ -0,0 +1,139 @@ +import { PlusOutlined } from '@ant-design/icons'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { useParams } from '@umijs/max'; +import { Popconfirm } from 'antd'; +import React, { useCallback, useRef, useState } from 'react'; +import ConfigurableDrawerForm, { + type ConfigurableDrawerFormRef, +} from '@/components/DrawerForm'; +import EnhancedProTable from '@/components/EnhancedProTable'; +import type { ToolbarAction } from '@/components/EnhancedProTable/types'; +import { formStatusType } from '@/constants'; +import { + createDictData, + type DictDataVO, + deleteDictData, + getDictDataPage, + updateDictData, +} from '@/services/system/dict/dict.data'; +import { baseDictDataColumns, formColumns } from './config'; + +const SyStemDictData = () => { + const configurableDrawerRef = useRef(null); + const tableRef = useRef(null); + + const [type, setType] = useState<'create' | 'update'>('create'); + const [id, setId] = useState(0); + + const routerParams = useParams(); + + console.log(routerParams); + + const handleEdit = (record: DictDataVO) => { + setType('update'); + setId(record.id); + + configurableDrawerRef.current?.open(record); + }; + + const onFetch = async (params: { pageSize?: number; current?: number }) => { + const data = await getDictDataPage({ + ...params, + dictType: routerParams.type, + pageNo: params.current, + pageSize: params.pageSize, + }); + return { + data: data.list, + success: true, + total: data.total, + }; + }; + + const handleAdd = () => { + setType('create'); + configurableDrawerRef.current?.open({ + dictType: routerParams.type, + }); + }; + + const handleSubmit = useCallback( + async (values: DictDataVO) => { + if (type === 'create') { + await createDictData(values); + } else { + await updateDictData({ + ...values, + id, + }); + } + tableRef.current?.reload(); + return true; + }, + [type, id], + ); + + const toolbarActions: ToolbarAction[] = [ + { + key: 'add', + label: '新建', + type: 'primary', + icon: , + onClick: handleAdd, + }, + ]; + + const actionColumns: ProColumns = { + title: '操作', + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + width: 120, + render: ( + _text: React.ReactNode, + record: DictDataVO, + _: any, + action: any, + ) => [ + handleEdit(record)}> + 编辑 + , + { + await deleteDictData(record.id); + action?.reload(); + }} + okText="是" + cancelText="否" + > + 删除 + , + ], + }; + + const columns = [...baseDictDataColumns, actionColumns]; + return ( + <> + + ref={tableRef} + columns={columns} + request={onFetch} + toolbarActions={toolbarActions} + headerTitle="租户列表" + showIndex={false} + showSelection={false} + /> + + + + ); +}; + +export default SyStemDictData; diff --git a/src/pages/system/dict/index.tsx b/src/pages/system/dict/index.tsx index 302b631..a99deb3 100644 --- a/src/pages/system/dict/index.tsx +++ b/src/pages/system/dict/index.tsx @@ -1,5 +1,6 @@ import { PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { history } from '@umijs/max'; import { Popconfirm } from 'antd'; import React, { useCallback, useRef, useState } from 'react'; import ConfigurableDrawerForm, { @@ -24,6 +25,8 @@ const SyStemDict = () => { const [type, setType] = useState<'create' | 'update'>('create'); const [id, setId] = useState(0); + //获取路由数据 + const handleEdit = (record: DictTypeVO) => { setType('update'); setId(record.id); @@ -102,6 +105,16 @@ const SyStemDict = () => { > 删除 , + + history.push({ + pathname: '/system/dict/data/' + record.type, + }) + } + > + 数据 + , ], }; diff --git a/src/services/system/dict/dict.data.ts b/src/services/system/dict/dict.data.ts index 677e17a..2e0866b 100644 --- a/src/services/system/dict/dict.data.ts +++ b/src/services/system/dict/dict.data.ts @@ -1,7 +1,7 @@ import { request } from "@umijs/max"; export type DictDataVO = { - id: number | undefined; + id: number; sort: number | undefined; label: string; value: string; @@ -13,6 +13,11 @@ export type DictDataVO = { createTime: Date; }; +export interface DictDataReqVO extends PageParam { + dictType?: string; + createTime?: Date; +} + // 查询字典数据(精简)列表 // export const getSimpleDictDataList = () => { // return request.get({ url: "/system/dict-data/simple-list" }); @@ -29,7 +34,7 @@ export const getSimpleDictDataList = () => { // return request.get({ url: "/system/dict-data/page", params }); // }; -export const getDictDataPage = (params: PageParam) => { +export const getDictDataPage = (params: DictDataReqVO) => { return request("/system/dict-data/page", { method: "GET", params,