From 3f47005f76cb4b6f8132175a7d5a694456adaa94 Mon Sep 17 00:00:00 2001 From: ZhuRui Date: Fri, 7 Aug 2026 18:19:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/params/index.ts | 49 ++++ src/api/params/types.ts | 40 +++ src/config/fallbackRoutes.ts | 9 + .../components/ParamFormModal.module.less | 10 + .../params/components/ParamFormModal.tsx | 141 +++++++++ src/pages/system/params/index.module.less | 36 +++ src/pages/system/params/index.tsx | 270 ++++++++++++++++++ src/pages/system/params/model/config.ts | 29 ++ src/pages/system/params/model/form.ts | 19 ++ src/pages/system/params/model/services.ts | 81 ++++++ .../system/params/model/useParamsColumns.ts | 36 +++ .../system/params/model/useParamsModel.ts | 111 +++++++ 12 files changed, 831 insertions(+) create mode 100644 src/api/params/index.ts create mode 100644 src/api/params/types.ts create mode 100644 src/pages/system/params/components/ParamFormModal.module.less create mode 100644 src/pages/system/params/components/ParamFormModal.tsx create mode 100644 src/pages/system/params/index.module.less create mode 100644 src/pages/system/params/index.tsx create mode 100644 src/pages/system/params/model/config.ts create mode 100644 src/pages/system/params/model/form.ts create mode 100644 src/pages/system/params/model/services.ts create mode 100644 src/pages/system/params/model/useParamsColumns.ts create mode 100644 src/pages/system/params/model/useParamsModel.ts diff --git a/src/api/params/index.ts b/src/api/params/index.ts new file mode 100644 index 0000000..593e017 --- /dev/null +++ b/src/api/params/index.ts @@ -0,0 +1,49 @@ +/** + * 参数配置 API + * + * TODO: 等后端接口确定后,替换占位的 URL 和返回类型 + */ +import { get, post, put, del } from '@/utils/request'; +import type { ParamQueryParams, SysParamVO, PageData, ApiResult } from './types'; + +// 类型重导出,方便页面 model 层统一引用 +export type { SysParamVO, ParamQueryParams, PageData, ApiResult } from './types'; + +// ============================================================ +// URL 常量(占位,等后端接口确定后替换) +// ============================================================ + +/** 配置列表分页查询 */ +const PARAM_LIST = '/admin/sys/param/page'; +/** 新增配置 */ +const PARAM_ADD = '/admin/sys/param/add'; +/** 编辑配置 */ +const PARAM_UPDATE = '/admin/sys/param/update'; +/** 删除配置 */ +const PARAM_DELETE = '/admin/sys/param/delete'; + +// ============================================================ +// API 函数(占位) +// ============================================================ + +/** 配置列表分页 */ +export async function getParamList( + params: ParamQueryParams, +): Promise>> { + return get(PARAM_LIST, params as Record); +} + +/** 新增配置 */ +export async function addParam(data: Partial): Promise> { + return post(PARAM_ADD, data); +} + +/** 编辑配置 */ +export async function updateParam(data: Partial): Promise> { + return put(PARAM_UPDATE, data); +} + +/** 删除配置 */ +export async function deleteParam(id: number): Promise> { + return del(`${PARAM_DELETE}`, { id }); +} diff --git a/src/api/params/types.ts b/src/api/params/types.ts new file mode 100644 index 0000000..5a6c40c --- /dev/null +++ b/src/api/params/types.ts @@ -0,0 +1,40 @@ +/** + * 参数配置 — 类型定义 + * + * TODO: 等后端接口确定后,根据实际字段补充完整类型 + */ + +/** 配置项列表项 */ +export interface SysParamVO { + /** 配置项 ID */ + id: number; + /** 配置项 key */ + // paramKey: string; + /** 配置项 value */ + // paramValue: string; + /** 备注 */ + // remark: string; + /** 更新时间 */ + // updateTime: string; +} + +/** 配置列表查询参数 */ +export interface ParamQueryParams { + page?: string; + limit?: string; + /** 搜索关键字 */ + // keyword?: string; +} + +/** 分页数据结构 */ +export interface PageData { + total: number; + list: T[]; +} + +/** API 统一响应格式 */ +export interface ApiResult { + code: number | string; + msg: string; + data: T; +} diff --git a/src/config/fallbackRoutes.ts b/src/config/fallbackRoutes.ts index efe6173..67eb757 100644 --- a/src/config/fallbackRoutes.ts +++ b/src/config/fallbackRoutes.ts @@ -164,6 +164,15 @@ export const FALLBACK_MENU_NODES: MenuNode[] = [ icon: 'AiOutlineSafetyCertificate', permission: 'system.roles.view', }, + { + id: 'system_params', + name: '参数配置', + path: 'system/params', + component: 'system/params', + componentName: 'SystemParams', + icon: 'AiOutlineSetting', + permission: 'system.params.view', + }, { id: 'system_logs', name: '操作日志', diff --git a/src/pages/system/params/components/ParamFormModal.module.less b/src/pages/system/params/components/ParamFormModal.module.less new file mode 100644 index 0000000..d26e83b --- /dev/null +++ b/src/pages/system/params/components/ParamFormModal.module.less @@ -0,0 +1,10 @@ +.paramFormModalMain { + .footer { + display: flex; + justify-content: flex-end; + gap: 8px; + padding-top: 16px; + border-top: 1px solid #f0f0f0; + margin-top: 8px; + } +} diff --git a/src/pages/system/params/components/ParamFormModal.tsx b/src/pages/system/params/components/ParamFormModal.tsx new file mode 100644 index 0000000..ea1485b --- /dev/null +++ b/src/pages/system/params/components/ParamFormModal.tsx @@ -0,0 +1,141 @@ +import { defineComponent, ref, reactive, nextTick } from 'vue'; +import { useEffect } from '@/hooks'; +import { Modal, Form, Input, Button } from 'ant-design-vue'; +import { paramCodeRules, paramValueRules, remarkRules } from '../model/form'; +import type { SysParamsDTO } from '../model/services'; +import styles from './ParamFormModal.module.less'; + +const { TextArea } = Input; + +interface ParamFormModalProps { + visible: boolean; + record: SysParamsDTO | null; + submitting?: boolean; + onClose: () => void; + onSave: (formData: { paramCode: string; paramValue: string; remark: string }) => void; +} + +/** 默认表单数据 */ +const getDefaultForm = () => ({ + paramCode: '', + paramValue: '', + remark: '', +}); + +export default defineComponent({ + name: 'ParamFormModal', + props: { + visible: { type: Boolean, default: false }, + record: { type: Object, default: null }, + submitting: { type: Boolean, default: false }, + onClose: { type: Function, required: true }, + onSave: { type: Function, required: true }, + }, + setup(props: ParamFormModalProps) { + const formRef = ref(); + const formData = reactive(getDefaultForm()); + + /** 根据 record 初始化表单 */ + const initFormFromRecord = (record: SysParamsDTO | null) => { + if (record) { + Object.assign(formData, { + paramCode: record.paramCode || '', + paramValue: record.paramValue || '', + remark: record.remark || '', + }); + } else { + Object.assign(formData, getDefaultForm()); + } + }; + + /** 监听 visible 变化重置表单 */ + useEffect(() => { + if (props.visible) { + initFormFromRecord(props.record); + nextTick().then(() => formRef.value?.clearValidate()); + } + }, [() => props.visible]); + + /** 提交 */ + const handleSubmit = async () => { + try { + await formRef.value?.validate(); + } catch { + return; + } + + props.onSave({ + paramCode: formData.paramCode, + paramValue: formData.paramValue, + remark: formData.remark, + }); + }; + + /** 关闭 */ + const handleClose = () => { + props.onClose(); + }; + + return () => { + const isEdit = !!props.record; + + return ( + +
+ + { + formData.paramCode = val?.target?.value ?? val ?? ''; + }} + placeholder="请输入参数编码" + allowClear + /> + + + + { + formData.paramValue = val?.target?.value ?? val ?? ''; + }} + placeholder="请输入参数值" + allowClear + /> + + + +