feat: 【ele】邮箱管理新增批量删除
							parent
							
								
									79c451d256
								
							
						
					
					
						commit
						3bae7aa442
					
				|  | @ -49,6 +49,13 @@ export function deleteMailAccount(id: number) { | |||
|   return requestClient.delete(`/system/mail-account/delete?id=${id}`); | ||||
| } | ||||
| 
 | ||||
| /** 批量删除邮箱账号 */ | ||||
| export function deleteMailAccountList(ids: number[]) { | ||||
|   return requestClient.delete( | ||||
|     `/system/mail-account/delete-list?ids=${ids.join(',')}`, | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| /** 获得邮箱账号精简列表 */ | ||||
| export function getSimpleMailAccountList() { | ||||
|   return requestClient.get<SystemMailAccountApi.MailAccount[]>( | ||||
|  |  | |||
|  | @ -56,6 +56,13 @@ export function deleteMailTemplate(id: number) { | |||
|   return requestClient.delete(`/system/mail-template/delete?id=${id}`); | ||||
| } | ||||
| 
 | ||||
| /** 批量删除邮件模版 */ | ||||
| export function deleteMailTemplateList(ids: number[]) { | ||||
|   return requestClient.delete( | ||||
|     `/system/mail-template/delete-list?ids=${ids.join(',')}`, | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| /** 发送邮件 */ | ||||
| export function sendMail(data: SystemMailTemplateApi.MailSendReqVO) { | ||||
|   return requestClient.post('/system/mail-template/send-mail', data); | ||||
|  |  | |||
|  | @ -129,6 +129,10 @@ export function useGridColumns<T = SystemMailAccountApi.MailAccount>( | |||
|   onActionClick: OnActionClickFn<T>, | ||||
| ): VxeTableGridOptions['columns'] { | ||||
|   return [ | ||||
|     { | ||||
|       type: 'checkbox', | ||||
|       width: 40, | ||||
|     }, | ||||
|     { | ||||
|       field: 'id', | ||||
|       title: '编号', | ||||
|  |  | |||
|  | @ -5,14 +5,17 @@ import type { | |||
| } from '#/adapter/vxe-table'; | ||||
| import type { SystemMailAccountApi } from '#/api/system/mail/account'; | ||||
| 
 | ||||
| import { ref } from 'vue'; | ||||
| 
 | ||||
| import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; | ||||
| import { Plus } from '@vben/icons'; | ||||
| import { 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 { | ||||
|   deleteMailAccount, | ||||
|   deleteMailAccountList, | ||||
|   getMailAccountPage, | ||||
| } from '#/api/system/mail/account'; | ||||
| import { $t } from '#/locales'; | ||||
|  | @ -50,13 +53,35 @@ async function onDelete(row: SystemMailAccountApi.MailAccount) { | |||
|     await deleteMailAccount(row.id as number); | ||||
|     ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.mail])); | ||||
|     onRefresh(); | ||||
|   } catch { | ||||
|     // 异常处理 | ||||
|   } finally { | ||||
|     loadingInstance.close(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** 批量删除邮箱账号 */ | ||||
| async function onDeleteBatch() { | ||||
|   const loadingInstance = ElLoading.service({ | ||||
|     text: $t('ui.actionMessage.deleting'), | ||||
|     fullscreen: true, | ||||
|   }); | ||||
|   try { | ||||
|     await deleteMailAccountList(checkedIds.value); | ||||
|     ElMessage.success($t('ui.actionMessage.deleteSuccess')); | ||||
|     onRefresh(); | ||||
|   } finally { | ||||
|     loadingInstance.close(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const checkedIds = ref<number[]>([]); | ||||
| function handleRowCheckboxChange({ | ||||
|   records, | ||||
| }: { | ||||
|   records: SystemMailAccountApi.MailAccount[]; | ||||
| }) { | ||||
|   checkedIds.value = records.map((item) => item.id as number); | ||||
| } | ||||
| 
 | ||||
| /** 表格操作按钮的回调函数 */ | ||||
| function onActionClick({ | ||||
|   code, | ||||
|  | @ -101,6 +126,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ | |||
|       search: true, | ||||
|     }, | ||||
|   } as VxeTableGridOptions<SystemMailAccountApi.MailAccount>, | ||||
|   gridEvents: { | ||||
|     checkboxAll: handleRowCheckboxChange, | ||||
|     checkboxChange: handleRowCheckboxChange, | ||||
|   }, | ||||
| }); | ||||
| </script> | ||||
| <template> | ||||
|  | @ -112,14 +141,25 @@ const [Grid, gridApi] = useVbenVxeGrid({ | |||
|     <FormModal @success="onRefresh" /> | ||||
|     <Grid table-title="邮箱账号列表"> | ||||
|       <template #toolbar-tools> | ||||
|         <ElButton | ||||
|           type="primary" | ||||
|           @click="onCreate" | ||||
|           v-access:code="['system:mail-account:create']" | ||||
|         > | ||||
|           <Plus class="mr-2 size-5" /> | ||||
|           {{ $t('ui.actionTitle.create', ['邮箱账号']) }} | ||||
|         </ElButton> | ||||
|         <TableAction | ||||
|           :actions="[ | ||||
|             { | ||||
|               label: $t('ui.actionTitle.create', ['邮箱账号']), | ||||
|               type: 'primary', | ||||
|               icon: ACTION_ICON.ADD, | ||||
|               auth: ['system:mail-account:create'], | ||||
|               onClick: onCreate, | ||||
|             }, | ||||
|             { | ||||
|               label: $t('ui.actionTitle.deleteBatch'), | ||||
|               type: 'danger', | ||||
|               icon: ACTION_ICON.DELETE, | ||||
|               disabled: isEmpty(checkedIds), | ||||
|               auth: ['system:mail-account:delete'], | ||||
|               onClick: onDeleteBatch, | ||||
|             }, | ||||
|           ]" | ||||
|         /> | ||||
|       </template> | ||||
|     </Grid> | ||||
|   </Page> | ||||
|  |  | |||
|  | @ -198,6 +198,10 @@ export function useGridColumns<T = SystemMailTemplateApi.MailTemplate>( | |||
|   getAccountMail?: (accountId: number) => string | undefined, | ||||
| ): VxeTableGridOptions['columns'] { | ||||
|   return [ | ||||
|     { | ||||
|       type: 'checkbox', | ||||
|       width: 40, | ||||
|     }, | ||||
|     { | ||||
|       field: 'id', | ||||
|       title: '编号', | ||||
|  |  | |||
|  | @ -9,14 +9,15 @@ import type { SystemMailTemplateApi } from '#/api/system/mail/template'; | |||
| import { onMounted, ref } from 'vue'; | ||||
| 
 | ||||
| import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; | ||||
| import { Plus } from '@vben/icons'; | ||||
| import { 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 { getSimpleMailAccountList } from '#/api/system/mail/account'; | ||||
| import { | ||||
|   deleteMailTemplate, | ||||
|   deleteMailTemplateList, | ||||
|   getMailTemplatePage, | ||||
| } from '#/api/system/mail/template'; | ||||
| import { $t } from '#/locales'; | ||||
|  | @ -77,6 +78,30 @@ async function onDelete(row: SystemMailTemplateApi.MailTemplate) { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| /** 批量删除邮件模板 */ | ||||
| async function onDeleteBatch() { | ||||
|   const loadingInstance = ElLoading.service({ | ||||
|     text: $t('ui.actionMessage.deleting'), | ||||
|     fullscreen: true, | ||||
|   }); | ||||
|   try { | ||||
|     await deleteMailTemplateList(checkedIds.value); | ||||
|     ElMessage.success($t('ui.actionMessage.deleteSuccess')); | ||||
|     onRefresh(); | ||||
|   } finally { | ||||
|     loadingInstance.close(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const checkedIds = ref<number[]>([]); | ||||
| function handleRowCheckboxChange({ | ||||
|   records, | ||||
| }: { | ||||
|   records: SystemMailTemplateApi.MailTemplate[]; | ||||
| }) { | ||||
|   checkedIds.value = records.map((item) => item.id as number); | ||||
| } | ||||
| 
 | ||||
| /** 表格操作按钮的回调函数 */ | ||||
| function onActionClick({ | ||||
|   code, | ||||
|  | @ -125,6 +150,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ | |||
|       search: true, | ||||
|     }, | ||||
|   } as VxeTableGridOptions<SystemMailTemplateApi.MailTemplate>, | ||||
|   gridEvents: { | ||||
|     checkboxAll: handleRowCheckboxChange, | ||||
|     checkboxChange: handleRowCheckboxChange, | ||||
|   }, | ||||
| }); | ||||
| 
 | ||||
| /** 初始化 */ | ||||
|  | @ -142,14 +171,25 @@ onMounted(async () => { | |||
|     <SendModal /> | ||||
|     <Grid table-title="邮件模板列表"> | ||||
|       <template #toolbar-tools> | ||||
|         <ElButton | ||||
|           type="primary" | ||||
|           @click="onCreate" | ||||
|           v-access:code="['system:mail-template:create']" | ||||
|         > | ||||
|           <Plus class="mr-2 size-5" /> | ||||
|           {{ $t('ui.actionTitle.create', ['邮件模板']) }} | ||||
|         </ElButton> | ||||
|         <TableAction | ||||
|           :actions="[ | ||||
|             { | ||||
|               label: $t('ui.actionTitle.create', ['邮件模板']), | ||||
|               type: 'primary', | ||||
|               icon: ACTION_ICON.ADD, | ||||
|               auth: ['system:mail-template:create'], | ||||
|               onClick: onCreate, | ||||
|             }, | ||||
|             { | ||||
|               label: $t('ui.actionTitle.deleteBatch'), | ||||
|               type: 'danger', | ||||
|               icon: ACTION_ICON.DELETE, | ||||
|               disabled: isEmpty(checkedIds), | ||||
|               auth: ['system:mail-template:delete'], | ||||
|               onClick: onDeleteBatch, | ||||
|             }, | ||||
|           ]" | ||||
|         /> | ||||
|       </template> | ||||
|     </Grid> | ||||
|   </Page> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 puhui999
						puhui999