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