feat: 【ele】短信管理新增批量删除
parent
3bae7aa442
commit
d1b3a98b7c
|
@ -54,6 +54,13 @@ export function deleteSmsChannel(id: number) {
|
|||
return requestClient.delete(`/system/sms-channel/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除短信渠道 */
|
||||
export function deleteSmsChannelList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/system/sms-channel/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出短信渠道 */
|
||||
export function exportSmsChannel(params: any) {
|
||||
return requestClient.download('/system/sms-channel/export', { params });
|
||||
|
|
|
@ -57,6 +57,13 @@ export function deleteSmsTemplate(id: number) {
|
|||
return requestClient.delete(`/system/sms-template/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除短信模板 */
|
||||
export function deleteSmsTemplateList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/system/sms-template/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出短信模板 */
|
||||
export function exportSmsTemplate(params: any) {
|
||||
return requestClient.download('/system/sms-template/export-excel', {
|
||||
|
|
|
@ -139,6 +139,10 @@ export function useGridColumns<T = SystemSmsChannelApi.SmsChannel>(
|
|||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
|
|
|
@ -5,15 +5,17 @@ import type {
|
|||
} from '#/adapter/vxe-table';
|
||||
import type { SystemSmsChannelApi } from '#/api/system/sms/channel';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download, Plus } from '@vben/icons';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, 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 {
|
||||
deleteSmsChannel,
|
||||
deleteSmsChannelList,
|
||||
exportSmsChannel,
|
||||
getSmsChannelPage,
|
||||
} from '#/api/system/sms/channel';
|
||||
|
@ -58,13 +60,35 @@ async function onDelete(row: SystemSmsChannelApi.SmsChannel) {
|
|||
await deleteSmsChannel(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.signature]));
|
||||
onRefresh();
|
||||
} catch {
|
||||
// 异常处理
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除短信渠道 */
|
||||
async function onDeleteBatch() {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting'),
|
||||
fullscreen: true,
|
||||
});
|
||||
try {
|
||||
await deleteSmsChannelList(checkedIds.value);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: SystemSmsChannelApi.SmsChannel[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id as number);
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
|
@ -109,6 +133,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<SystemSmsChannelApi.SmsChannel>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -121,23 +149,32 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
<FormModal @success="onRefresh" />
|
||||
<Grid table-title="短信渠道列表">
|
||||
<template #toolbar-tools>
|
||||
<ElButton
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:sms-channel:create']"
|
||||
>
|
||||
<Plus class="mr-2 size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['短信渠道']) }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['system:sms-channel:export']"
|
||||
>
|
||||
<Download class="mr-2 size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</ElButton>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['短信渠道']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:sms-channel:create'],
|
||||
onClick: onCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['system:sms-channel:export'],
|
||||
onClick: onExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
disabled: isEmpty(checkedIds),
|
||||
auth: ['system:sms-channel:delete'],
|
||||
onClick: onDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -208,6 +208,10 @@ export function useGridColumns<T = SystemSmsTemplateApi.SmsTemplate>(
|
|||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
|
|
|
@ -5,15 +5,17 @@ import type {
|
|||
} from '#/adapter/vxe-table';
|
||||
import type { SystemSmsTemplateApi } from '#/api/system/sms/template';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download, Plus } from '@vben/icons';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, 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 {
|
||||
deleteSmsTemplate,
|
||||
deleteSmsTemplateList,
|
||||
exportSmsTemplate,
|
||||
getSmsTemplatePage,
|
||||
} from '#/api/system/sms/template';
|
||||
|
@ -69,13 +71,35 @@ async function onDelete(row: SystemSmsTemplateApi.SmsTemplate) {
|
|||
await deleteSmsTemplate(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
} catch {
|
||||
// 异常处理
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除短信模板 */
|
||||
async function onDeleteBatch() {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting'),
|
||||
fullscreen: true,
|
||||
});
|
||||
try {
|
||||
await deleteSmsTemplateList(checkedIds.value);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
onRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: SystemSmsTemplateApi.SmsTemplate[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id as number);
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
|
@ -124,6 +148,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<SystemSmsTemplateApi.SmsTemplate>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -137,23 +165,32 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
<SendModal />
|
||||
<Grid table-title="短信模板列表">
|
||||
<template #toolbar-tools>
|
||||
<ElButton
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:sms-template:create']"
|
||||
>
|
||||
<Plus class="mr-2 size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['短信模板']) }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['system:sms-template:export']"
|
||||
>
|
||||
<Download class="mr-2 size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</ElButton>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['短信模板']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['system:sms-template:create'],
|
||||
onClick: onCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['system:sms-template:export'],
|
||||
onClick: onExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
disabled: isEmpty(checkedIds),
|
||||
auth: ['system:sms-template:delete'],
|
||||
onClick: onDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
Loading…
Reference in New Issue