reactor:【system 系统管理】dept 部门管理的实现,对齐 ele 和 antd
This commit is contained in:
@@ -5,7 +5,7 @@ import type { SystemNoticeApi } from '#/api/system/notice';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
deleteNotice,
|
||||
deleteNoticeList,
|
||||
getNoticePage,
|
||||
pushNotice,
|
||||
} from '#/api/system/notice';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
@@ -30,31 +31,31 @@ function onRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建通知公告 */
|
||||
/** 创建公告 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑通知公告 */
|
||||
/** 编辑公告 */
|
||||
function handleEdit(row: SystemNoticeApi.Notice) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除通知公告 */
|
||||
/** 删除公告 */
|
||||
async function handleDelete(row: SystemNoticeApi.Notice) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.id]),
|
||||
text: $t('ui.actionMessage.deleting', [row.title]),
|
||||
});
|
||||
try {
|
||||
await deleteNotice(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.title]));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除通知公告 */
|
||||
/** 批量删除公告 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const loadingInstance = ElLoading.service({
|
||||
@@ -79,10 +80,17 @@ function handleRowCheckboxChange({
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportNotice(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '通知公告.xls', source: data });
|
||||
/** 推送公告 */
|
||||
async function handlePush(row: SystemNoticeApi.Notice) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: '正在推送中...',
|
||||
});
|
||||
try {
|
||||
await pushNotice(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
@@ -123,24 +131,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="通知公告列表">
|
||||
<Grid table-title="公告列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['通知公告']),
|
||||
label: $t('ui.actionTitle.create', ['公告']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:notice:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['system:notice:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
@@ -163,6 +164,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
auth: ['system:notice:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '推送',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:notice:update'],
|
||||
onClick: handlePush.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
@@ -170,7 +179,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['system:notice:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.title]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user