From 5f178556ed63ecd4da2a1eaad731157a4949428f Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Thu, 24 Oct 2024 23:19:35 +0800 Subject: [PATCH] =?UTF-8?q?fixbug:=20=F0=9F=90=9B=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E5=BE=88=E5=A4=9Abug=E5=92=8C=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/data.js | 6 +- src/api/v1/files.ts | 2 +- src/components/Table/DeleteBatchDialog.vue | 35 ++++++++++++ src/store/system/power.ts | 2 +- .../utils/{hooks.ts => hooks.tsx} | 41 ++++++++----- .../emailUsers/utils/{hooks.ts => hooks.tsx} | 41 ++++++++----- .../menuIcon/menu-icon-dialog.vue | 1 + .../menuIcon/utils/{hooks.ts => hooks.tsx} | 55 +++++++++--------- .../files/utils/{hooks.ts => hooks.tsx} | 51 ++++++++++------- src/views/monitor/userLoginLog/utils/hooks.ts | 49 +++++++++------- src/views/scheduler/schedulers/utils/hooks.ts | 8 +-- .../scheduler/schedulersGroup/utils/hooks.ts | 53 +++++++++-------- src/views/system/adminUser/utils/hooks.tsx | 48 +++++++++------- src/views/system/dept/utils/hooks.ts | 53 +++++++++-------- src/views/system/menu/index.vue | 2 +- src/views/system/menu/utils/hooks.tsx | 8 +-- src/views/system/power/utils/hooks.tsx | 57 ++++++++++--------- .../system/role/assign-powers-to-role.vue | 8 +-- src/views/system/role/index.vue | 2 +- src/views/system/role/utils/columns.ts | 2 +- 20 files changed, 307 insertions(+), 217 deletions(-) create mode 100644 src/components/Table/DeleteBatchDialog.vue rename src/views/configuration/emailTemplate/utils/{hooks.ts => hooks.tsx} (75%) rename src/views/configuration/emailUsers/utils/{hooks.ts => hooks.tsx} (81%) rename src/views/configuration/menuIcon/utils/{hooks.ts => hooks.tsx} (71%) rename src/views/monitor/files/utils/{hooks.ts => hooks.tsx} (76%) diff --git a/build/data.js b/build/data.js index 3a172d5..5a1f805 100644 --- a/build/data.js +++ b/build/data.js @@ -32,12 +32,12 @@ }; // 整理子级内容信息 - const powerCode = key.replace('/admin', '').replace('/{page}/{limit}', '').replace('/{id}', '').replace('/', ''); + const powerCode = key.replace('/admin/', '').replace(/\/\{.*?\}/g, ''); const item = { parentId: info.id, powerCode: powerCode.replaceAll('/', '::'), powerName: description, - requestUrl: key.replace('{page}', '\\d+').replace('{limit}', '\\d+').replace('/{id}', '\\d+'), + requestUrl: key.replace(/\/{.*/, '/.*'), }; // 向父级内容添加子级Children内容 @@ -76,7 +76,7 @@ async function add(data) { headers: { 'Content-Type': 'application/json', token: - 'eyJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_yWLQQqDMBBF7zJrUzJ24iSuirtuvINxJtCCtlYDLdK7G3D3ee_9HdYcoYUuz_MPKtDvG1rkOjiPTU0V5FU_dynsnP0wacnxiiFYi45uy3IZX1O5PrdHMWNiFK9kUiQxpMwmKDrjZUiaohA3Fv4HKp13G3cAAAA.qDzOIts0Wckglwm3L-BcprzRiW06ARC6Q8jN9qbVjQ0', + 'eyJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_yWLywrCMBAA_2XPjeSxZEtP4s2L_7DpbqBCorUGLMV_N-BtGGYO2FqCCS6t1h0G0M8TJkfBhtFbHwdom76u0t0fb1y05yxlqed1Pc2P0q_7e-lS3JwUkQxhDgZzFMPZkUmWhTX6EYnh-wMBQi1DcgAAAA.II3lcc1R1pX8G6eaEVkCxxDXkscN4c6p89zn7FzFhaU', }, body: JSON.stringify(data), }); diff --git a/src/api/v1/files.ts b/src/api/v1/files.ts index 156a487..8ddd743 100644 --- a/src/api/v1/files.ts +++ b/src/api/v1/files.ts @@ -23,7 +23,7 @@ export const fetchGetAllMediaTypes = () => { /** 系统文件管理---获取所有文件存储基础路径 */ export const fetchGetAllFilesStoragePath = () => { - return http.request>('get', `files/getAllFilesStoragePath`); + return http.request>('get', `files/noManage/getAllFilesStoragePath`); }; /** 系统文件管理---添加系统文件管理 */ diff --git a/src/components/Table/DeleteBatchDialog.vue b/src/components/Table/DeleteBatchDialog.vue new file mode 100644 index 0000000..71827bc --- /dev/null +++ b/src/components/Table/DeleteBatchDialog.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/store/system/power.ts b/src/store/system/power.ts index 12891c4..0983c75 100644 --- a/src/store/system/power.ts +++ b/src/store/system/power.ts @@ -26,7 +26,7 @@ export const usePowerStore = defineStore('powerStore', { // 分页查询结果 pagination: { currentPage: 1, - pageSize: 30, + pageSize: 150, total: 1, pageSizes, }, diff --git a/src/views/configuration/emailTemplate/utils/hooks.ts b/src/views/configuration/emailTemplate/utils/hooks.tsx similarity index 75% rename from src/views/configuration/emailTemplate/utils/hooks.ts rename to src/views/configuration/emailTemplate/utils/hooks.tsx index 2f63a92..0517de3 100644 --- a/src/views/configuration/emailTemplate/utils/hooks.ts +++ b/src/views/configuration/emailTemplate/utils/hooks.tsx @@ -2,9 +2,10 @@ import { addDialog } from '@/components/BaseDialog/index'; import EmailTemplateDialog from '@/views/configuration/emailTemplate/email-template-dialog.vue'; import { useEmailTemplateStore } from '@/store/configuration/emailTemplate'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/configuration/emailTemplate/utils/types'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; // 选择的row列表 export const selectRows = ref([]); @@ -89,9 +90,7 @@ export function onUpdate(row: any) { }); } -/** - * * 删除邮件模板表 - */ +/** 删除邮件模板表 */ export const onDelete = async (row: any) => { const id = row.id; @@ -112,17 +111,29 @@ export const onDelete = async (row: any) => { /** 批量删除 */ export const onDeleteBatch = async () => { const ids = selectRows.value.map((row: any) => row.id); + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await emailTemplateStore.deleteEmailTemplate(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await emailTemplateStore.deleteEmailTemplate(ids); - await onSearch(); }; diff --git a/src/views/configuration/emailUsers/utils/hooks.ts b/src/views/configuration/emailUsers/utils/hooks.tsx similarity index 81% rename from src/views/configuration/emailUsers/utils/hooks.ts rename to src/views/configuration/emailUsers/utils/hooks.tsx index 02bcd52..2d242ea 100644 --- a/src/views/configuration/emailUsers/utils/hooks.ts +++ b/src/views/configuration/emailUsers/utils/hooks.tsx @@ -2,9 +2,10 @@ import { addDialog } from '@/components/BaseDialog/index'; import EmailUsersDialog from '@/views/configuration/emailUsers/email-users-dialog.vue'; import { useEmailUsersStore } from '@/store/configuration/emailUsers'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/configuration/emailUsers/utils/types'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; export const formRef = ref(); // 用户是否停用加载集合 @@ -113,24 +114,34 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await emailUsersStore.deleteEmailUsers(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await emailUsersStore.deleteEmailUsers(ids); - await onSearch(); }; /** diff --git a/src/views/configuration/menuIcon/menu-icon-dialog.vue b/src/views/configuration/menuIcon/menu-icon-dialog.vue index 2cfa899..0944bda 100644 --- a/src/views/configuration/menuIcon/menu-icon-dialog.vue +++ b/src/views/configuration/menuIcon/menu-icon-dialog.vue @@ -27,6 +27,7 @@ defineExpose({ formRef }); + diff --git a/src/views/configuration/menuIcon/utils/hooks.ts b/src/views/configuration/menuIcon/utils/hooks.tsx similarity index 71% rename from src/views/configuration/menuIcon/utils/hooks.ts rename to src/views/configuration/menuIcon/utils/hooks.tsx index b1a390c..547df6d 100644 --- a/src/views/configuration/menuIcon/utils/hooks.ts +++ b/src/views/configuration/menuIcon/utils/hooks.tsx @@ -2,28 +2,23 @@ import { addDialog } from '@/components/BaseDialog/index'; import MenuIconDialog from '@/views/configuration/menuIcon/menu-icon-dialog.vue'; import { useMenuIconStore } from '@/store/configuration/menuIcon'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/configuration/menuIcon/utils/types'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; export const formRef = ref(); const menuIconStore = useMenuIconStore(); export const deleteIds = ref([]); -/** - * * 搜索初始化系统菜单图标 - */ +/** 搜索初始化系统菜单图标 */ export async function onSearch() { menuIconStore.loading = true; - await menuIconStore.getMenuIconList(); - menuIconStore.loading = false; } -/** - * * 添加系统菜单图标 - */ +/** 添加系统菜单图标 */ export function onAdd() { addDialog({ title: `${$t('addNew')} ${$t('menuIcon')}`, @@ -84,9 +79,7 @@ export function onUpdate(row: any) { }); } -/** - * * 删除系统菜单图标 - */ +/** 删除系统菜单图标 */ export const onDelete = async (row: any) => { const id = row.id; @@ -104,22 +97,32 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await menuIconStore.deleteMenuIcon(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await menuIconStore.deleteMenuIcon(ids); - await onSearch(); }; diff --git a/src/views/monitor/files/utils/hooks.ts b/src/views/monitor/files/utils/hooks.tsx similarity index 76% rename from src/views/monitor/files/utils/hooks.ts rename to src/views/monitor/files/utils/hooks.tsx index ce80ace..a800fec 100644 --- a/src/views/monitor/files/utils/hooks.ts +++ b/src/views/monitor/files/utils/hooks.tsx @@ -2,30 +2,27 @@ import { addDialog } from '@/components/BaseDialog/index'; import FilesDialog from '@/views/monitor/files/files-dialog.vue'; import { useFilesStore } from '@/store/monitor/files'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/monitor/files/utils/types'; import { $t } from '@/plugins/i18n'; import { downloadFilesByFileId, downloadFilesByFilepath } from '@/api/v1/files'; import { download } from '@/utils/sso'; import type { UploadFiles } from 'element-plus'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; // 选择的row列表 export const selectRows = ref([]); export const formRef = ref(); const filesStore = useFilesStore(); -/** - * * 搜索初始化系统文件表 - */ +/** 搜索初始化系统文件表 */ export async function onSearch() { filesStore.loading = true; await filesStore.getFilesList(); filesStore.loading = false; } -/** - * * 添加系统文件表 - */ +/** 添加系统文件表 */ export function onAdd() { addDialog({ title: `${$t('addNew')}${$t('files')}`, @@ -87,8 +84,12 @@ export function onUpdate(row: any) { formRef.value.formRef.validate(async (valid: any) => { if (!valid) return; + // 判断是否更新了文件 + if (form.files) { + form.files = (form.files as UploadFiles).map(file => file.raw); + } + // 更新文件 - form.files = (form.files as UploadFiles).map(file => file.raw); const result = await filesStore.updateFiles({ ...form, id: row.id }); // 更新完成 @@ -121,19 +122,31 @@ export const onDelete = async (row: any) => { /** 批量删除 */ export const onDeleteBatch = async () => { const ids = selectRows.value.map(row => row.id); + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await filesStore.deleteFiles(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await filesStore.deleteFiles(ids); - await onSearch(); }; /** diff --git a/src/views/monitor/userLoginLog/utils/hooks.ts b/src/views/monitor/userLoginLog/utils/hooks.ts index 23e2098..2f937fa 100644 --- a/src/views/monitor/userLoginLog/utils/hooks.ts +++ b/src/views/monitor/userLoginLog/utils/hooks.ts @@ -2,17 +2,16 @@ import { addDialog } from '@/components/BaseDialog/index'; import UserLoginLogDialog from '@/views/monitor/userLoginLog/user-login-log-dialog.vue'; import { useUserLoginLogStore } from '@/store/monitor/userLoginLog'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; export const formRef = ref(); // 删除ids export const deleteIds = ref([]); const userLoginLogStore = useUserLoginLogStore(); -/** - * * 搜索初始化用户登录日志 - */ +/** 搜索初始化用户登录日志 */ export async function onSearch() { userLoginLogStore.loading = true; await userLoginLogStore.getUserLoginLogList(); @@ -50,9 +49,7 @@ export function onView(row: any) { }); } -/** - * * 删除用户登录日志 - */ +/** 删除用户登录日志 */ export const onDelete = async (row: any) => { const id = row.id; @@ -70,22 +67,32 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await userLoginLogStore.deleteUserLoginLog(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await userLoginLogStore.deleteUserLoginLog(ids); - await onSearch(); }; diff --git a/src/views/scheduler/schedulers/utils/hooks.ts b/src/views/scheduler/schedulers/utils/hooks.ts index 2b41506..a957c45 100644 --- a/src/views/scheduler/schedulers/utils/hooks.ts +++ b/src/views/scheduler/schedulers/utils/hooks.ts @@ -9,18 +9,14 @@ import { $t } from '@/plugins/i18n'; export const formRef = ref(); const schedulersStore = useSchedulersStore(); -/** - * * 搜索初始化Schedulers视图 - */ +/** 搜索初始化Schedulers视图 */ export async function onSearch() { schedulersStore.loading = true; await schedulersStore.getSchedulersList(); schedulersStore.loading = false; } -/** - * * 添加Schedulers视图 - */ +/** 添加Schedulers视图 */ export function onAdd() { addDialog({ title: `${$t('addNew')}${$t('schedulers')}`, diff --git a/src/views/scheduler/schedulersGroup/utils/hooks.ts b/src/views/scheduler/schedulersGroup/utils/hooks.ts index 7727121..24000d0 100644 --- a/src/views/scheduler/schedulersGroup/utils/hooks.ts +++ b/src/views/scheduler/schedulersGroup/utils/hooks.ts @@ -2,27 +2,24 @@ import { addDialog } from '@/components/BaseDialog/index'; import SchedulersGroupDialog from '@/views/scheduler/schedulersGroup/schedulers-group-dialog.vue'; import { useSchedulersGroupStore } from '@/store/scheduler/schedulersGroup'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/scheduler/schedulersGroup/utils/types'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; export const formRef = ref(); // 删除ids export const deleteIds = ref([]); const schedulersGroupStore = useSchedulersGroupStore(); -/** - * * 搜索初始化任务调度分组 - */ +/** 搜索初始化任务调度分组 */ export async function onSearch() { schedulersGroupStore.loading = true; await schedulersGroupStore.getSchedulersGroupList(); schedulersGroupStore.loading = false; } -/** - * * 添加任务调度分组 - */ +/** 添加任务调度分组 */ export function onAdd() { addDialog({ title: `${$t('addNew')}${$t('schedulersGroup')}`, @@ -83,9 +80,7 @@ export function onUpdate(row: any) { }); } -/** - * * 删除任务调度分组 - */ +/** 删除任务调度分组 */ export const onDelete = async (row: any) => { const id = row.id; @@ -103,22 +98,32 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await schedulersGroupStore.deleteSchedulersGroup(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await schedulersGroupStore.deleteSchedulersGroup(ids); - await onSearch(); }; diff --git a/src/views/system/adminUser/utils/hooks.tsx b/src/views/system/adminUser/utils/hooks.tsx index bc090ca..00a6766 100644 --- a/src/views/system/adminUser/utils/hooks.tsx +++ b/src/views/system/adminUser/utils/hooks.tsx @@ -14,6 +14,7 @@ import userAvatar from '@/assets/user.jpg'; import { fetchForcedOffline, fetchUploadAvatarByAdmin } from '@/api/v1/adminUser'; import { useUserStore } from '@/store/system/user'; import { useDeptStore } from '@/store/system/dept'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; const adminUserStore = useAdminUserStore(); const userStore = useUserStore(); @@ -49,9 +50,7 @@ export async function onSearch() { adminUserStore.loading = false; } -/** - * * 添加用户信息 - */ +/** 添加用户信息 */ export function onAdd() { isAddUserinfo.value = true; addDialog({ @@ -130,9 +129,7 @@ export function onUpdate(row: any) { }); } -/** - * * 删除用户信息 - */ +/** 删除用户信息 */ export const onDelete = async (row: any) => { const id = row.id; @@ -150,22 +147,33 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * * 批量删除用户 - */ +/** 批量删除用户 */ export const onDeleteBatch = async () => { - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), - }); - if (!result) return; + const formDeletedBatchRef = ref(); - // 删除数据 - await adminUserStore.deleteAdminUser(deleteIds.value); - await onSearch(); + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await adminUserStore.deleteAdminUser(deleteIds.value); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, + }); }; /** diff --git a/src/views/system/dept/utils/hooks.ts b/src/views/system/dept/utils/hooks.ts index d0142e9..a9a414a 100644 --- a/src/views/system/dept/utils/hooks.ts +++ b/src/views/system/dept/utils/hooks.ts @@ -2,26 +2,23 @@ import { addDialog } from '@/components/BaseDialog/index'; import DeptDialog from '@/views/system/dept/dept-dialog.vue'; import { useDeptStore } from '@/store/system/dept'; import { h, ref } from 'vue'; -import { messageBox } from '@/utils/message'; +import { message, messageBox } from '@/utils/message'; import type { FormItemProps } from '@/views/system/dept/utils/types'; import { $t } from '@/plugins/i18n'; +import DeleteBatchDialog from '@/components/Table/DeleteBatchDialog.vue'; export const formRef = ref(); export const deleteIds = ref([]); const deptStore = useDeptStore(); -/** - * * 搜索初始化部门 - */ +/** 搜索初始化部门 */ export async function onSearch() { deptStore.loading = true; await deptStore.getDeptList(); deptStore.loading = false; } -/** - * * 添加部门 - */ +/** 添加部门 */ export function onAdd(parentId: number = 0) { addDialog({ title: `${$t('addNew')}${$t('dept')}`, @@ -86,9 +83,7 @@ export function onUpdate(row: any) { }); } -/** - * * 删除部门 - */ +/** 删除部门 */ export const onDelete = async (row: any) => { const id = row.id; @@ -106,22 +101,32 @@ export const onDelete = async (row: any) => { await onSearch(); }; -/** - * 批量删除 - */ +/** 批量删除 */ export const onDeleteBatch = async () => { const ids = deleteIds.value; + const formDeletedBatchRef = ref(); - // 是否确认删除 - const result = await messageBox({ - title: $t('confirmDelete'), - showMessage: false, - confirmMessage: undefined, - cancelMessage: $t('confirmDelete'), + addDialog({ + title: $t('deleteBatchTip'), + width: '30%', + props: { formInline: { confirmText: '' } }, + draggable: true, + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }), + beforeSure: (done, { options }) => { + formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => { + if (!valid) return; + + const text = options.props.formInline.confirmText.toLowerCase(); + if (text === 'yes' || text === 'y') { + // 删除数据 + await deptStore.deleteDept(ids); + await onSearch(); + + done(); + } else message($t('deleteBatchTip'), { type: 'warning' }); + }); + }, }); - if (!result) return; - - // 删除数据 - await deptStore.deleteDept(ids); - await onSearch(); }; diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index c0efc28..4c91233 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -104,7 +104,7 @@ onMounted(() => { diff --git a/src/views/system/role/utils/columns.ts b/src/views/system/role/utils/columns.ts index 89e121a..60cb3fc 100644 --- a/src/views/system/role/utils/columns.ts +++ b/src/views/system/role/utils/columns.ts @@ -13,7 +13,7 @@ export const columns: TableColumnList = [ { label: $t('table.createTime'), prop: 'createTime', sortable: true }, { label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 90 }, { label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 90 }, - { label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' }, + { label: $t('table.operation'), fixed: 'right', width: 240, slot: 'operation' }, ]; // 添加规则