diff --git a/src/layout/components/notice/index.vue b/src/layout/components/notice/index.vue index 0361808..10de4e0 100644 --- a/src/layout/components/notice/index.vue +++ b/src/layout/components/notice/index.vue @@ -70,10 +70,7 @@ const onNewsClick = async (item: any) => { currentNewsList.value[item].read = true; const current = currentNewsList.value[item]; if (current?.path) { - await router.push({ - path: current.path, - query: current.query || undefined - }); + await router.push(current.path); } }; diff --git a/src/store/modules/notice.ts b/src/store/modules/notice.ts index eda6473..ed149a0 100644 --- a/src/store/modules/notice.ts +++ b/src/store/modules/notice.ts @@ -11,7 +11,6 @@ export interface NoticeItem { content?: string; data?: Record | null; path?: string; - query?: Record | null; time: string; } diff --git a/src/utils/push-message.ts b/src/utils/push-message.ts index 81fe6b0..bb5552c 100644 --- a/src/utils/push-message.ts +++ b/src/utils/push-message.ts @@ -25,7 +25,6 @@ export interface PushMessagePayload { message?: string; data?: Record | null; path?: string; - query?: Record | null; timestamp?: number; } @@ -40,7 +39,6 @@ export const parsePushMessage = (raw: string): PushMessagePayload => { message: payload.message ?? '', data: payload.data ?? null, path: payload.path, - query: payload.query ?? null, timestamp: payload.timestamp ?? Date.now() }; } catch { @@ -50,7 +48,6 @@ export const parsePushMessage = (raw: string): PushMessagePayload => { message: raw, data: null, path: undefined, - query: null, timestamp: Date.now() }; } diff --git a/src/utils/push.ts b/src/utils/push.ts index f7f81fb..508040b 100644 --- a/src/utils/push.ts +++ b/src/utils/push.ts @@ -20,7 +20,6 @@ const appendNotice = (raw: string) => { content: payload.data?.noticeContent, data: payload.data, path: payload.path, - query: payload.query, read: false, time: new Date(payload.timestamp ?? Date.now()).toLocaleString() }); diff --git a/src/views/system/notice/index.vue b/src/views/system/notice/index.vue index fdd7fdc..e1cdbc5 100644 --- a/src/views/system/notice/index.vue +++ b/src/views/system/notice/index.vue @@ -73,6 +73,9 @@ + + +
+
+
{{ detailForm.noticeTitle || '-' }}
+
+
+ 类型: + +
+
+ 状态: + +
+
+ 创建者: + {{ detailForm.createByName || '-' }} +
+
+ 创建时间: + {{ proxy.parseTime(detailForm.createTime, '{y}-{m}-{d} {h}:{i}:{s}') || '-' }} +
+
+
+ +
+
+
@@ -131,6 +162,8 @@ import { NoticeForm, NoticeQuery, NoticeVO } from '@/api/system/notice/types'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { sys_notice_status, sys_notice_type } = toRefs(proxy?.useDict('sys_notice_status', 'sys_notice_type')); +const route = useRoute(); +const router = useRouter(); const noticeList = ref([]); const loading = ref(true); @@ -147,6 +180,10 @@ const dialog = reactive({ visible: false, title: '' }); +const detailDialog = reactive({ + visible: false +}); +const routeDetailSyncing = ref(false); const initFormData: NoticeForm = { noticeId: undefined, @@ -157,6 +194,7 @@ const initFormData: NoticeForm = { remark: '', createByName: '' }; +const detailForm = ref({} as NoticeVO); const data = reactive>({ form: { ...initFormData }, queryParams: { @@ -227,6 +265,31 @@ const handleUpdate = async (row?: NoticeVO) => { dialog.visible = true; dialog.title = '修改公告'; }; +/** 详情按钮操作 */ +const handleDetail = async (row: NoticeVO) => { + await openDetail(row.noticeId); +}; +/** 打开详情 */ +const openDetail = async (noticeId: string | number) => { + const { data } = await getNotice(noticeId); + detailForm.value = data; + detailDialog.visible = true; +}; +/** 详情弹窗关闭后移除路由参数 */ +const handleDetailDialogClosed = async () => { + if (!route.query.noticeId) { + return; + } + routeDetailSyncing.value = true; + await router.replace({ + path: route.path, + query: { + ...route.query, + noticeId: undefined + } + }); + routeDetailSyncing.value = false; +}; /** 提交按钮 */ const submitForm = () => { noticeFormRef.value?.validate(async (valid: boolean) => { @@ -250,10 +313,69 @@ const handleDelete = async (row?: NoticeVO) => { onMounted(() => { getList(); }); + +watch( + () => route.query.noticeId, + async (noticeId) => { + if (routeDetailSyncing.value || !noticeId) { + return; + } + await openDetail(String(noticeId)); + }, + { immediate: true } +);