diff --git a/apps/bdrp-admin-web/src/api/notification/index.ts b/apps/bdrp-admin-web/src/api/notification/index.ts index c74fcb3..04041c3 100644 --- a/apps/bdrp-admin-web/src/api/notification/index.ts +++ b/apps/bdrp-admin-web/src/api/notification/index.ts @@ -58,11 +58,29 @@ async function getNotificationList(params: Recordable) { return requestClient.get( '/notification/list', { - params, + // 某些环境下 GET 列表会被缓存,导致编辑后 query/search 仍看到旧数据。 + // 增加时间戳参数与 no-cache 头,确保每次都拿最新列表。 + params: { + ...params, + _ts: Date.now(), + }, + headers: { + 'Cache-Control': 'no-cache', + Pragma: 'no-cache', + }, }, ); } +/** + * 获取通知详情(按 ID) + */ +async function getNotificationDetail(id: number) { + return requestClient.get( + `/notification/detail/${id}`, + ); +} + /** * 创建通知 */ @@ -100,6 +118,7 @@ async function deleteNotification(id: number) { export { createNotification, deleteNotification, + getNotificationDetail, getNotificationList, updateNotification, }; diff --git a/apps/bdrp-admin-web/src/views/notification.zip b/apps/bdrp-admin-web/src/views/notification.zip new file mode 100644 index 0000000..4009997 Binary files /dev/null and b/apps/bdrp-admin-web/src/views/notification.zip differ diff --git a/apps/bdrp-admin-web/src/views/notification/data.ts b/apps/bdrp-admin-web/src/views/notification/data.ts index 2590926..2d82b55 100644 --- a/apps/bdrp-admin-web/src/views/notification/data.ts +++ b/apps/bdrp-admin-web/src/views/notification/data.ts @@ -58,18 +58,18 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', fieldName: 'title', label: '通知标题', + componentProps: { + allowClear: true, + placeholder: '模糊匹配标题', + }, }, { - component: 'Select', + component: 'Input', fieldName: 'notification_page', label: '通知页面', componentProps: { allowClear: true, - options: [ - { label: '首页', value: 'home' }, - { label: '个人中心', value: 'profile' }, - { label: '订单页', value: 'order' }, - ], + placeholder: '模糊匹配路径', }, }, { @@ -79,8 +79,8 @@ export function useGridFormSchema(): VbenFormSchema[] { componentProps: { allowClear: true, options: [ - { label: '启用', value: 'active' }, - { label: '禁用', value: 'inactive' }, + { label: '启用', value: 1 }, + { label: '禁用', value: 0 }, ], }, }, @@ -115,7 +115,7 @@ export function useColumns( width: 200, }, { - field: 'show_date', + field: 'start_date', title: '展示日期', width: 300, formatter: ({ row }) => { @@ -125,7 +125,7 @@ export function useColumns( }, }, { - field: 'show_time', + field: 'start_time', title: '展示时间', width: 300, formatter: ({ row }) => { diff --git a/apps/bdrp-admin-web/src/views/notification/list.vue b/apps/bdrp-admin-web/src/views/notification/list.vue index ada6e94..f893602 100644 --- a/apps/bdrp-admin-web/src/views/notification/list.vue +++ b/apps/bdrp-admin-web/src/views/notification/list.vue @@ -15,6 +15,7 @@ import { Button, message, Modal } from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteNotification, + getNotificationDetail, getNotificationList, updateNotification, } from '#/api/notification'; @@ -36,23 +37,51 @@ const columns = useColumns( }, ); +function buildNotificationListParams(formValues: Recordable) { + const params: Recordable = { ...formValues }; + delete params.date_range; + + for (const key of ['title', 'notification_page']) { + const v = params[key]; + if (v === '' || v === undefined || v === null) { + delete params[key]; + } + } + + const statusRaw = params.status; + if (statusRaw === '' || statusRaw === undefined || statusRaw === null) { + delete params.status; + } else { + const n = Number(String(statusRaw).trim()); + if (n === 0 || n === 1) { + params.status = n; + } else { + delete params.status; + } + } + + return params; +} + const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { - fieldMappingTime: [['date', ['startDate', 'endDate']]], + // 与表单字段 date_range 一致;后端 form 为 start_date / end_date + fieldMappingTime: [['date_range', ['start_date', 'end_date']]], schema: useGridFormSchema(), submitOnChange: true, }, gridOptions: { columns, height: 'auto', - keepSource: true, + // 该页不做行内编辑,关闭 source 缓存避免同 key 行数据刷新延迟。 + keepSource: false, proxyConfig: { ajax: { query: async ({ page }, formValues) => { return await getNotificationList({ page: page.currentPage, pageSize: page.pageSize, - ...formValues, + ...buildNotificationListParams(formValues), }); }, }, @@ -125,17 +154,8 @@ async function onStatusChange( `你要将通知"${row.title}"的状态切换为【${status[newStatus]}】吗?`, '切换状态', ); - // 获取完整的通知数据 - const notification = await getNotificationList({ - page: 1, - pageSize: 1, - id: row.id, - }); - const fullData = notification.items[0]; - if (!fullData) { - message.error('获取通知数据失败'); - return false; - } + // 列表接口不支持按 id 筛选,必须用详情接口取完整字段再更新 + const fullData = await getNotificationDetail(row.id); await updateNotification(row.id, { id: row.id, status: newStatus, @@ -147,6 +167,7 @@ async function onStatusChange( end_date: fullData.end_date, end_time: fullData.end_time, }); + onRefresh(); return true; } catch { return false; diff --git a/apps/bdrp-admin-web/src/views/system/role.zip b/apps/bdrp-admin-web/src/views/system/role.zip new file mode 100644 index 0000000..dc4a508 Binary files /dev/null and b/apps/bdrp-admin-web/src/views/system/role.zip differ diff --git a/apps/bdrp-admin-web/src/views/system/role/data.ts b/apps/bdrp-admin-web/src/views/system/role/data.ts index 57e6017..977c7bf 100644 --- a/apps/bdrp-admin-web/src/views/system/role/data.ts +++ b/apps/bdrp-admin-web/src/views/system/role/data.ts @@ -54,7 +54,6 @@ export function useGridFormSchema(): VbenFormSchema[] { fieldName: 'role_name', label: $t('system.role.roleName'), }, - { component: 'Input', fieldName: 'id', label: $t('system.role.id') }, { component: 'Select', componentProps: {