Feature/event platform 1.09 cst #21
@@ -49,6 +49,6 @@ export function updateNotice(params: NoticeSaveParams): Promise<ApiResult<null>>
|
||||
}
|
||||
|
||||
/** 删除公告(物理删除,单个)— 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 });
|
||||
}
|
||||
|
||||
+10
-10
@@ -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<T> {
|
||||
|
||||
/** 接口通用返回结构 */
|
||||
export interface ApiResult<T> {
|
||||
code: number;
|
||||
code: number | string;
|
||||
msg: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
{/* 类型 */}
|
||||
<Form.Item label="类型" name="type" rules={typeRules}>
|
||||
<Select
|
||||
value={Number(formData.type)}
|
||||
value={formData.type}
|
||||
options={NOTICE_TYPE_OPTIONS as any}
|
||||
placeholder="请选择"
|
||||
onUpdate:value={(val: any) => (formData.type = Number(val) || 1)}
|
||||
onUpdate:value={(val: any) => (formData.type = String(val || '1'))}
|
||||
/>
|
||||
</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 为空时使用) */
|
||||
export const NOTICE_TYPE_MAP: Record<number, string> = {
|
||||
1: '首页公告提示',
|
||||
2: '产品更新公告',
|
||||
export const NOTICE_TYPE_MAP: Record<string, string> = {
|
||||
'1': '首页公告提示',
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
@@ -66,8 +65,12 @@ export function useNoticeModel() {
|
||||
|
||||
const dataSource = computed<NoticeVO[]>(() => {
|
||||
const list = (data.value as any)?.data?.list || [];
|
||||
// 后端 type 可能返回字符串,统一归一化为数字,保证编辑弹窗 Select 能匹配选项
|
||||
return list.map((item: NoticeVO) => ({ ...item, type: Number(item.type) }));
|
||||
// 后端 id / type 可能返回数字,统一归一化为字符串,保证与选项 value 类型一致
|
||||
return list.map((item: NoticeVO) => ({
|
||||
...item,
|
||||
id: String(item.id),
|
||||
type: String(item.type),
|
||||
}));
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user