reactor:【system 系统管理】notify/my 进一步统一代码风格
parent
11f507ed2b
commit
965ccdbea1
|
|
@ -4,12 +4,11 @@ import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { formatDateTime } from '@vben/utils';
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
|
||||||
import { getDictOptions } from '@vben/hooks';
|
|
||||||
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
|
|
@ -21,8 +20,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请选择是否已读',
|
placeholder: '请选择是否已读',
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +29,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '发送时间',
|
label: '发送时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
|
||||||
...getRangePickerDefaultProps(),
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
@ -48,15 +47,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'templateNickname',
|
field: 'templateNickname',
|
||||||
title: '发送人',
|
title: '发送人',
|
||||||
|
minWidth: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '发送时间',
|
title: '发送时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'templateType',
|
field: 'templateType',
|
||||||
title: '类型',
|
title: '类型',
|
||||||
|
minWidth: 120,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE },
|
props: { type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE },
|
||||||
|
|
@ -65,10 +67,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'templateContent',
|
field: 'templateContent',
|
||||||
title: '消息内容',
|
title: '消息内容',
|
||||||
|
minWidth: 300,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'readStatus',
|
field: 'readStatus',
|
||||||
title: '是否已读',
|
title: '是否已读',
|
||||||
|
minWidth: 100,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
|
@ -77,6 +81,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'readTime',
|
field: 'readTime',
|
||||||
title: '阅读时间',
|
title: '阅读时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
|
@ -22,7 +25,7 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,22 +36,19 @@ function handleDetail(row: SystemNotifyMessageApi.NotifyMessage) {
|
||||||
|
|
||||||
/** 标记一条站内信已读 */
|
/** 标记一条站内信已读 */
|
||||||
async function handleRead(row: SystemNotifyMessageApi.NotifyMessage) {
|
async function handleRead(row: SystemNotifyMessageApi.NotifyMessage) {
|
||||||
message.loading({
|
const hideLoading = message.loading({
|
||||||
content: '正在标记已读...',
|
content: '正在标记已读...',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
key: 'action_process_msg',
|
|
||||||
});
|
});
|
||||||
// 执行标记已读操作
|
try {
|
||||||
await updateNotifyMessageRead([row.id]);
|
await updateNotifyMessageRead([row.id]);
|
||||||
// 提示成功
|
message.success('标记已读成功');
|
||||||
message.success({
|
handleRefresh();
|
||||||
content: '标记已读成功',
|
|
||||||
key: 'action_process_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
|
|
||||||
// 打开详情
|
// 打开详情
|
||||||
handleDetail(row);
|
handleDetail(row);
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记选中的站内信为已读 */
|
/** 标记选中的站内信为已读 */
|
||||||
|
|
@ -62,39 +62,40 @@ async function handleMarkRead() {
|
||||||
const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id);
|
const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id);
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
content: '正在标记已读...',
|
content: '正在标记已读...',
|
||||||
key: 'action_key_msg',
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// 执行标记已读操作
|
|
||||||
await updateNotifyMessageRead(ids);
|
await updateNotifyMessageRead(ids);
|
||||||
// 提示成功
|
checkedIds.value = [];
|
||||||
message.success({
|
message.success('标记已读成功');
|
||||||
content: '标记已读成功',
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
await gridApi.grid.setAllCheckboxRow(false);
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: SystemNotifyMessageApi.NotifyMessage[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id);
|
||||||
|
}
|
||||||
|
|
||||||
/** 标记所有站内信为已读 */
|
/** 标记所有站内信为已读 */
|
||||||
async function handleMarkAllRead() {
|
async function handleMarkAllRead() {
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
content: '正在标记全部已读...',
|
content: '正在标记全部已读...',
|
||||||
key: 'action_key_msg',
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// 执行标记已读操作
|
|
||||||
await updateAllNotifyMessageRead();
|
await updateAllNotifyMessageRead();
|
||||||
// 提示成功
|
message.success('全部标记已读成功');
|
||||||
message.success({
|
checkedIds.value = [];
|
||||||
content: '全部标记已读成功',
|
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
await gridApi.grid.setAllCheckboxRow(false);
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
|
@ -132,6 +134,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
highlight: true,
|
highlight: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<SystemNotifyMessageApi.NotifyMessage>,
|
} as VxeTableGridOptions<SystemNotifyMessageApi.NotifyMessage>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -140,7 +146,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
<DocAlert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="我的站内信">
|
<Grid table-title="我的站内信">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
|
@ -148,13 +154,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
{
|
{
|
||||||
label: '标记已读',
|
label: '标记已读',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: 'mdi:checkbox-marked-circle-outline',
|
icon: ACTION_ICON.ADD,
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
onClick: handleMarkRead,
|
onClick: handleMarkRead,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '全部已读',
|
label: '全部已读',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: 'mdi:checkbox-marked-circle-outline',
|
icon: ACTION_ICON.ADD,
|
||||||
onClick: handleMarkAllRead,
|
onClick: handleMarkAllRead,
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
|
|
@ -174,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
label: '已读',
|
label: '已读',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
ifShow: !row.readStatus,
|
ifShow: !row.readStatus,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.ADD,
|
||||||
onClick: handleRead.bind(null, row),
|
onClick: handleRead.bind(null, row),
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
|
||||||
import type { DescriptionItemSchema } from '#/components/description';
|
import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
|
|
@ -38,9 +37,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = SystemNotifyMessageApi.NotifyMessage>(
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
|
|
@ -88,31 +85,10 @@ export function useGridColumns<T = SystemNotifyMessageApi.NotifyMessage>(
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 180,
|
width: 130,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'id',
|
|
||||||
nameTitle: '站内信',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'detail',
|
|
||||||
text: '查看',
|
|
||||||
show: (row: any) => row.readStatus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'read',
|
|
||||||
text: '已读',
|
|
||||||
show: (row: any) => !row.readStatus,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { MdiCheckboxMarkedCircleOutline } from '@vben/icons';
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { ElButton, ElMessage } from 'element-plus';
|
import { ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
getMyNotifyMessagePage,
|
getMyNotifyMessagePage,
|
||||||
updateAllNotifyMessageRead,
|
updateAllNotifyMessageRead,
|
||||||
|
|
@ -26,35 +25,33 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查看站内信详情 */
|
/** 查看站内信详情 */
|
||||||
function onDetail(row: SystemNotifyMessageApi.NotifyMessage) {
|
function handleDetail(row: SystemNotifyMessageApi.NotifyMessage) {
|
||||||
detailModalApi.setData(row).open();
|
detailModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记一条站内信已读 */
|
/** 标记一条站内信已读 */
|
||||||
async function onRead(row: SystemNotifyMessageApi.NotifyMessage) {
|
async function handleRead(row: SystemNotifyMessageApi.NotifyMessage) {
|
||||||
const loadingInstance = ElMessage({
|
const loadingInstance = ElLoading.service({
|
||||||
message: '正在标记已读...',
|
text: '正在标记已读...',
|
||||||
type: 'info',
|
|
||||||
duration: 0,
|
|
||||||
});
|
});
|
||||||
// 执行标记已读操作
|
try {
|
||||||
await updateNotifyMessageRead([row.id]);
|
await updateNotifyMessageRead([row.id]);
|
||||||
// 提示成功
|
|
||||||
loadingInstance.close();
|
|
||||||
ElMessage.success('标记已读成功');
|
ElMessage.success('标记已读成功');
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
|
|
||||||
// 打开详情
|
// 打开详情
|
||||||
onDetail(row);
|
handleDetail(row);
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记选中的站内信为已读 */
|
/** 标记选中的站内信为已读 */
|
||||||
async function onMarkRead() {
|
async function handleMarkRead() {
|
||||||
const rows = gridApi.grid.getCheckboxRecords();
|
const rows = gridApi.grid.getCheckboxRecords();
|
||||||
if (!rows || rows.length === 0) {
|
if (!rows || rows.length === 0) {
|
||||||
ElMessage.warning('请选择需要标记的站内信');
|
ElMessage.warning('请选择需要标记的站内信');
|
||||||
|
|
@ -62,50 +59,42 @@ async function onMarkRead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id);
|
const ids = rows.map((row: SystemNotifyMessageApi.NotifyMessage) => row.id);
|
||||||
const loadingInstance = ElMessage({
|
const loadingInstance = ElLoading.service({
|
||||||
message: '正在标记已读...',
|
text: '正在标记已读...',
|
||||||
type: 'info',
|
|
||||||
duration: 0,
|
|
||||||
});
|
});
|
||||||
// 执行标记已读操作
|
try {
|
||||||
await updateNotifyMessageRead(ids);
|
await updateNotifyMessageRead(ids);
|
||||||
// 提示成功
|
checkedIds.value = [];
|
||||||
loadingInstance.close();
|
|
||||||
ElMessage.success('标记已读成功');
|
ElMessage.success('标记已读成功');
|
||||||
await gridApi.grid.setAllCheckboxRow(false);
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: SystemNotifyMessageApi.NotifyMessage[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 标记所有站内信为已读 */
|
/** 标记所有站内信为已读 */
|
||||||
async function onMarkAllRead() {
|
async function handleMarkAllRead() {
|
||||||
const loadingInstance = ElMessage({
|
const loadingInstance = ElLoading.service({
|
||||||
message: '正在标记全部已读...',
|
text: '正在标记全部已读...',
|
||||||
type: 'info',
|
|
||||||
duration: 0,
|
|
||||||
});
|
});
|
||||||
// 执行标记已读操作
|
try {
|
||||||
await updateAllNotifyMessageRead();
|
await updateAllNotifyMessageRead();
|
||||||
// 提示成功
|
|
||||||
loadingInstance.close();
|
|
||||||
ElMessage.success('全部标记已读成功');
|
ElMessage.success('全部标记已读成功');
|
||||||
|
checkedIds.value = [];
|
||||||
await gridApi.grid.setAllCheckboxRow(false);
|
await gridApi.grid.setAllCheckboxRow(false);
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
}
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<SystemNotifyMessageApi.NotifyMessage>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'detail': {
|
|
||||||
onDetail(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'read': {
|
|
||||||
onRead(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +103,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
|
|
@ -130,6 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
|
@ -141,6 +131,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
highlight: true,
|
highlight: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<SystemNotifyMessageApi.NotifyMessage>,
|
} as VxeTableGridOptions<SystemNotifyMessageApi.NotifyMessage>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -149,17 +143,48 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
<DocAlert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="我的站内信">
|
<Grid table-title="我的站内信">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<ElButton type="primary" @click="onMarkRead">
|
<TableAction
|
||||||
<MdiCheckboxMarkedCircleOutline />
|
:actions="[
|
||||||
标记已读
|
{
|
||||||
</ElButton>
|
label: '标记已读',
|
||||||
<ElButton type="primary" class="ml-2" @click="onMarkAllRead">
|
type: 'primary',
|
||||||
<MdiCheckboxMarkedCircleOutline />
|
icon: ACTION_ICON.ADD,
|
||||||
全部已读
|
disabled: isEmpty(checkedIds),
|
||||||
</ElButton>
|
onClick: handleMarkRead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '全部已读',
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleMarkAllRead,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '查看',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
ifShow: row.readStatus,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '已读',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
ifShow: !row.readStatus,
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleRead.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,22 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
|
||||||
// TODO puhui999: 下次提交
|
import { ElDescriptions, ElDescriptionsItem } from 'element-plus';
|
||||||
// import { useDescription } from '#/components/description';
|
|
||||||
|
|
||||||
// import { useDetailSchema } from '../data';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
//
|
|
||||||
// const [Description, descApi] = useDescription({
|
const formData = ref<SystemNotifyMessageApi.NotifyMessage>();
|
||||||
// componentProps: {
|
|
||||||
// bordered: true,
|
|
||||||
// column: 1,
|
|
||||||
// size: 'middle',
|
|
||||||
// class: 'mx-4',
|
|
||||||
// },
|
|
||||||
// schema: useDetailSchema(),
|
|
||||||
// });
|
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
// 加载数据
|
||||||
|
|
@ -30,7 +26,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
}
|
}
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
// descApi.setState({ data });
|
formData.value = data;
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
|
|
@ -40,10 +36,36 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal
|
<Modal
|
||||||
title="消息详情"
|
title="站内信详情"
|
||||||
|
class="w-1/3"
|
||||||
:show-cancel-button="false"
|
:show-cancel-button="false"
|
||||||
:show-confirm-button="false"
|
:show-confirm-button="false"
|
||||||
>
|
>
|
||||||
<!-- <Description />-->
|
<ElDescriptions border :column="1" size="default" class="mx-4">
|
||||||
|
<ElDescriptionsItem label="发送人">
|
||||||
|
{{ formData?.templateNickname }}
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="发送时间">
|
||||||
|
{{ formatDateTime(formData?.createTime || '') }}
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="消息类型">
|
||||||
|
<DictTag
|
||||||
|
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||||
|
:value="formData?.templateType"
|
||||||
|
/>
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="是否已读">
|
||||||
|
<DictTag
|
||||||
|
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||||
|
:value="formData?.readStatus"
|
||||||
|
/>
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="阅读时间">
|
||||||
|
{{ formatDateTime(formData?.readTime || '') }}
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
<ElDescriptionsItem label="消息内容">
|
||||||
|
{{ formData?.templateContent }}
|
||||||
|
</ElDescriptionsItem>
|
||||||
|
</ElDescriptions>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { ref } from 'vue';
|
||||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { ElMessage } from 'element-plus';
|
import {ElLoading, ElMessage} from 'element-plus';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
|
|
@ -60,8 +60,8 @@ function handleSend(row: SystemNotifyTemplateApi.NotifyTemplate) {
|
||||||
|
|
||||||
/** 删除站内信模板 */
|
/** 删除站内信模板 */
|
||||||
async function handleDelete(row: SystemNotifyTemplateApi.NotifyTemplate) {
|
async function handleDelete(row: SystemNotifyTemplateApi.NotifyTemplate) {
|
||||||
const loadingInstance = ElMessage({
|
const loadingInstance = ElLoading.service({
|
||||||
message: $t('ui.actionMessage.deleting', [row.name]),
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteNotifyTemplate(row.id as number);
|
await deleteNotifyTemplate(row.id as number);
|
||||||
|
|
@ -75,8 +75,8 @@ async function handleDelete(row: SystemNotifyTemplateApi.NotifyTemplate) {
|
||||||
/** 批量删除站内信模板 */
|
/** 批量删除站内信模板 */
|
||||||
async function handleDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
const loadingInstance = ElMessage({
|
const loadingInstance = ElLoading.service({
|
||||||
message: $t('ui.actionMessage.deletingBatch'),
|
text: $t('ui.actionMessage.deletingBatch'),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteNotifyTemplateList(checkedIds.value);
|
await deleteNotifyTemplateList(checkedIds.value);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue