From 33e3a1f1a124aeb2b3fae7a36c3736e59a85ab85 Mon Sep 17 00:00:00 2001 From: cst Date: Sat, 7 Nov 2026 14:59:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B5=9B=E4=BA=8B1.09?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/notices/index.ts | 2 +- src/api/notices/types.ts | 20 +++++++++---------- .../notices/components/NoticeFormModal.tsx | 12 +++++------ .../system/notices/model/useNoticeModel.ts | 15 ++++++++------ 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/api/notices/index.ts b/src/api/notices/index.ts index b839fbb..97790cc 100644 --- a/src/api/notices/index.ts +++ b/src/api/notices/index.ts @@ -49,6 +49,6 @@ export function updateNotice(params: NoticeSaveParams): Promise> } /** 删除公告(物理删除,单个)— POST /admin/sys/announcement/delete(id 放在请求体) */ -export function deleteNotice(id: number): Promise> { +export function deleteNotice(id: string): Promise> { return post(ANNOUNCEMENT_DELETE, { id }); } diff --git a/src/api/notices/types.ts b/src/api/notices/types.ts index 1cc43a7..e527a74 100644 --- a/src/api/notices/types.ts +++ b/src/api/notices/types.ts @@ -2,17 +2,17 @@ * 公告管理 - 类型定义 */ -/** 公告类型:1=首页公告提示,2=产品更新公告 */ -export type NoticeType = 1 | 2; +/** 公告类型:1=首页公告提示 */ +export type NoticeType = '1'; /** 公告 VO */ export interface NoticeVO { /** 公告 ID */ - id: number; + id: string; /** 标题(最多 30 字) */ title: string; - /** 公告类型:1=首页公告提示,2=产品更新公告 */ - type: number; + /** 公告类型:1=首页公告提示 */ + type: string; /** 公告类型名称 */ typeName: string; /** 生效开始时间(YYYY-MM-DD HH:mm:ss) */ @@ -32,14 +32,14 @@ export interface NoticeListQueryParams { /** 标题,模糊搜索 */ title?: string; /** 公告类型 */ - type?: number; + type?: string; } -/** 新增/修改公告参数(id:新增不传或为 0,修改必传) */ +/** 新增/修改公告参数(id:新增不传,修改必传) */ export interface NoticeSaveParams { - id?: number; + id?: string; title: string; - type: number; + type: string; startTime: string; endTime: string; context: string; @@ -54,7 +54,7 @@ export interface PageData { /** 接口通用返回结构 */ export interface ApiResult { - code: number; + code: number | string; msg: string; data: T; } diff --git a/src/pages/system/notices/components/NoticeFormModal.tsx b/src/pages/system/notices/components/NoticeFormModal.tsx index 923b285..34ec7de 100644 --- a/src/pages/system/notices/components/NoticeFormModal.tsx +++ b/src/pages/system/notices/components/NoticeFormModal.tsx @@ -30,7 +30,7 @@ interface NoticeFormModalProps { /** 默认表单数据 */ const getDefaultForm = () => ({ - type: 1 as number, + type: '1' as string, timeRange: null as [Dayjs, Dayjs] | null, title: '', context: '', @@ -61,7 +61,7 @@ export default defineComponent({ const startTime = record.startTime ? dayjs(record.startTime).second(0) : null; const endTime = record.endTime ? dayjs(record.endTime).second(0) : null; Object.assign(formData, { - type: Number(record.type) || 1, + type: String(record.type || '1'), timeRange: startTime?.isValid() && endTime?.isValid() ? [startTime, endTime] : null, title: record.title || '', context: record.context || '', @@ -86,7 +86,7 @@ export default defineComponent({ const res = await getNoticeList({ page: '1', limit: '999', - type: Number(formData.type) || 1, + type: String(formData.type || '1'), }); if (res.code != 200) return true; @@ -125,7 +125,7 @@ export default defineComponent({ if (!isTimeRangeValid) return; props.onSave({ - type: Number(formData.type) || 1, + type: String(formData.type || '1'), title: formData.title.trim(), context: formData.context.trim(), startTime: startTime.format(SUBMIT_TIME_FORMAT), @@ -152,10 +152,10 @@ export default defineComponent({ {/* 类型 */}