f
Some checks are pending
CI / Test (ubuntu-latest) (push) Waiting to run
CI / Test (windows-latest) (push) Waiting to run
CI / Lint (ubuntu-latest) (push) Waiting to run
CI / Lint (windows-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / CI OK (push) Blocked by required conditions
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Deploy Website on push / Deploy Push Playground Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Docs Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Antd Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Element Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Naive Ftp (push) Waiting to run
Deploy Website on push / Rerun on failure (push) Blocked by required conditions
Release Drafter / update_release_draft (push) Waiting to run

This commit is contained in:
2026-04-18 12:05:45 +08:00
parent e91a8f8664
commit beddbf97ee
6 changed files with 65 additions and 26 deletions

View File

@@ -58,11 +58,29 @@ async function getNotificationList(params: Recordable<any>) {
return requestClient.get<NotificationApi.NotificationList>(
'/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<NotificationApi.NotificationItem>(
`/notification/detail/${id}`,
);
}
/**
* 创建通知
*/
@@ -100,6 +118,7 @@ async function deleteNotification(id: number) {
export {
createNotification,
deleteNotification,
getNotificationDetail,
getNotificationList,
updateNotification,
};

Binary file not shown.

View File

@@ -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<T = NotificationApi.NotificationItem>(
width: 200,
},
{
field: 'show_date',
field: 'start_date',
title: '展示日期',
width: 300,
formatter: ({ row }) => {
@@ -125,7 +125,7 @@ export function useColumns<T = NotificationApi.NotificationItem>(
},
},
{
field: 'show_time',
field: 'start_time',
title: '展示时间',
width: 300,
formatter: ({ row }) => {

View File

@@ -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<NotificationApi.NotificationItem>(
},
);
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;

Binary file not shown.

View File

@@ -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: {