feat: 赛事1.09

This commit is contained in:
cst
2026-11-07 14:59:24 +08:00
parent 1f356a1112
commit 33e3a1f1a1
4 changed files with 26 additions and 23 deletions
+1 -1
View File
@@ -49,6 +49,6 @@ export function updateNotice(params: NoticeSaveParams): Promise<ApiResult<null>>
} }
/** 删除公告(物理删除,单个)— POST /admin/sys/announcement/delete(id 放在请求体) */ /** 删除公告(物理删除,单个)— POST /admin/sys/announcement/delete(id 放在请求体) */
export function deleteNotice(id: number): Promise<ApiResult<null>> { export function deleteNotice(id: string): Promise<ApiResult<null>> {
return post(ANNOUNCEMENT_DELETE, { id }); return post(ANNOUNCEMENT_DELETE, { id });
} }
+10 -10
View File
@@ -2,17 +2,17 @@
* 公告管理 - 类型定义 * 公告管理 - 类型定义
*/ */
/** 公告类型:1=首页公告提示,2=产品更新公告 */ /** 公告类型:1=首页公告提示 */
export type NoticeType = 1 | 2; export type NoticeType = '1';
/** 公告 VO */ /** 公告 VO */
export interface NoticeVO { export interface NoticeVO {
/** 公告 ID */ /** 公告 ID */
id: number; id: string;
/** 标题(最多 30 字) */ /** 标题(最多 30 字) */
title: string; title: string;
/** 公告类型:1=首页公告提示,2=产品更新公告 */ /** 公告类型:1=首页公告提示 */
type: number; type: string;
/** 公告类型名称 */ /** 公告类型名称 */
typeName: string; typeName: string;
/** 生效开始时间(YYYY-MM-DD HH:mm:ss) */ /** 生效开始时间(YYYY-MM-DD HH:mm:ss) */
@@ -32,14 +32,14 @@ export interface NoticeListQueryParams {
/** 标题,模糊搜索 */ /** 标题,模糊搜索 */
title?: string; title?: string;
/** 公告类型 */ /** 公告类型 */
type?: number; type?: string;
} }
/** 新增/修改公告参数(id:新增不传或为 0,修改必传) */ /** 新增/修改公告参数(id:新增不传,修改必传) */
export interface NoticeSaveParams { export interface NoticeSaveParams {
id?: number; id?: string;
title: string; title: string;
type: number; type: string;
startTime: string; startTime: string;
endTime: string; endTime: string;
context: string; context: string;
@@ -54,7 +54,7 @@ export interface PageData<T> {
/** 接口通用返回结构 */ /** 接口通用返回结构 */
export interface ApiResult<T> { export interface ApiResult<T> {
code: number; code: number | string;
msg: string; msg: string;
data: T; data: T;
} }
@@ -30,7 +30,7 @@ interface NoticeFormModalProps {
/** 默认表单数据 */ /** 默认表单数据 */
const getDefaultForm = () => ({ const getDefaultForm = () => ({
type: 1 as number, type: '1' as string,
timeRange: null as [Dayjs, Dayjs] | null, timeRange: null as [Dayjs, Dayjs] | null,
title: '', title: '',
context: '', context: '',
@@ -61,7 +61,7 @@ export default defineComponent({
const startTime = record.startTime ? dayjs(record.startTime).second(0) : null; const startTime = record.startTime ? dayjs(record.startTime).second(0) : null;
const endTime = record.endTime ? dayjs(record.endTime).second(0) : null; const endTime = record.endTime ? dayjs(record.endTime).second(0) : null;
Object.assign(formData, { Object.assign(formData, {
type: Number(record.type) || 1, type: String(record.type || '1'),
timeRange: startTime?.isValid() && endTime?.isValid() ? [startTime, endTime] : null, timeRange: startTime?.isValid() && endTime?.isValid() ? [startTime, endTime] : null,
title: record.title || '', title: record.title || '',
context: record.context || '', context: record.context || '',
@@ -86,7 +86,7 @@ export default defineComponent({
const res = await getNoticeList({ const res = await getNoticeList({
page: '1', page: '1',
limit: '999', limit: '999',
type: Number(formData.type) || 1, type: String(formData.type || '1'),
}); });
if (res.code != 200) return true; if (res.code != 200) return true;
@@ -125,7 +125,7 @@ export default defineComponent({
if (!isTimeRangeValid) return; if (!isTimeRangeValid) return;
props.onSave({ props.onSave({
type: Number(formData.type) || 1, type: String(formData.type || '1'),
title: formData.title.trim(), title: formData.title.trim(),
context: formData.context.trim(), context: formData.context.trim(),
startTime: startTime.format(SUBMIT_TIME_FORMAT), startTime: startTime.format(SUBMIT_TIME_FORMAT),
@@ -152,10 +152,10 @@ export default defineComponent({
{/* 类型 */} {/* 类型 */}
<Form.Item label="类型" name="type" rules={typeRules}> <Form.Item label="类型" name="type" rules={typeRules}>
<Select <Select
value={Number(formData.type)} value={formData.type}
options={NOTICE_TYPE_OPTIONS as any} options={NOTICE_TYPE_OPTIONS as any}
placeholder="请选择" placeholder="请选择"
onUpdate:value={(val: any) => (formData.type = Number(val) || 1)} onUpdate:value={(val: any) => (formData.type = String(val || '1'))}
/> />
</Form.Item> </Form.Item>
@@ -20,12 +20,11 @@ import {
// ============================================================ // ============================================================
/** 公告类型选项(筛选 / 表单共用):目前仅开放「首页公告提示」 */ /** 公告类型选项(筛选 / 表单共用):目前仅开放「首页公告提示」 */
export const NOTICE_TYPE_OPTIONS = [{ value: 1, label: '首页公告提示' }] as const; export const NOTICE_TYPE_OPTIONS = [{ value: '1', label: '首页公告提示' }] as const;
/** 公告类型文案映射(兜底,后端 typeName 为空时使用) */ /** 公告类型文案映射(兜底,后端 typeName 为空时使用) */
export const NOTICE_TYPE_MAP: Record<number, string> = { export const NOTICE_TYPE_MAP: Record<string, string> = {
1: '首页公告提示', '1': '首页公告提示',
2: '产品更新公告',
}; };
// ============================================================ // ============================================================
@@ -66,8 +65,12 @@ export function useNoticeModel() {
const dataSource = computed<NoticeVO[]>(() => { const dataSource = computed<NoticeVO[]>(() => {
const list = (data.value as any)?.data?.list || []; const list = (data.value as any)?.data?.list || [];
// 后端 type 可能返回字符串,统一归一化为数字,保证编辑弹窗 Select 能匹配选项 // 后端 id / type 可能返回数字,统一归一化为字符串,保证与选项 value 类型一致
return list.map((item: NoticeVO) => ({ ...item, type: Number(item.type) })); return list.map((item: NoticeVO) => ({
...item,
id: String(item.id),
type: String(item.type),
}));
}); });
useEffect(() => { useEffect(() => {