批量删除、删除、批量分组分配权限

This commit is contained in:
Xubx 2025-05-19 17:29:48 +08:00
parent 48b47dfb99
commit 4179a5f731
6 changed files with 124 additions and 87 deletions

View File

@ -7,21 +7,11 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-button type="primary" @click="batchHandleDelete" v-if="hasPermission('adminInfo:batchDelete')"
<template #overlay> >批量删除
<a-menu> </a-button>
<a-menu-item key="1" @click="batchHandleDelete"> <!-- 高级查询 -->
<Icon icon="ant-design:delete-outlined"></Icon> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
@ -46,6 +36,9 @@
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CeesAdminInfo.api'; import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CeesAdminInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { usePermission } from '/@/hooks/web/usePermission';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
@ -140,8 +133,12 @@
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); if (selectedRowKeys.value.length < 1) {
} message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
}
/** /**
* 成功回调 * 成功回调
*/ */
@ -152,18 +149,19 @@
* 操作栏 * 操作栏
*/ */
function getTableAction(record){ function getTableAction(record){
return [ const actions = [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} }
] ]
return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record){ function getDropDownAction(record){
return [ const actions = [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
@ -173,9 +171,13 @@
title: '是否确认删除', title: '是否确认删除',
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
} },
ifShow: () => {
return hasPermission('adminInfo:delete');
},
} }
] ]
return actions;
} }

View File

@ -7,20 +7,9 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-button type="primary" @click="batchHandleDelete" v-if="hasPermission('dormitory:batchDelete')"
<template #overlay> >批量删除
<a-menu> </a-button>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button
>批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
@ -58,6 +47,9 @@
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesDormitoryInfo.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesDormitoryInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { usePermission } from '/@/hooks/web/usePermission';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
@ -150,6 +142,10 @@
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
if (selectedRowKeys.value.length < 1) {
message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
@ -162,12 +158,14 @@
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ const actions = [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
]; ];
return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
@ -185,6 +183,9 @@
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
}, },
ifShow: () => {
return hasPermission('dormitory:delete');
},
}, },
]; ];
} }

View File

@ -7,19 +7,8 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-button type="primary" @click="batchHandleDelete" v-if="hasPermission('group:batchDelete')">批量删除
<template #overlay> </a-button>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
@ -54,7 +43,10 @@ import { columns, searchFormSchema, superQuerySchema } from './CeesGroup.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getRowUser, addGroupMembers, removeGroupMembers } from './CeesGroup.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getRowUser, addGroupMembers, removeGroupMembers } from './CeesGroup.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { usePermission } from '/@/hooks/web/usePermission';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
@ -151,6 +143,10 @@ async function handleDelete(record) {
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
if (selectedRowKeys.value.length < 1) {
message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
@ -163,12 +159,14 @@ function handleSuccess() {
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ const actions = [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} },
] ];
return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
@ -178,15 +176,19 @@ function getDropDownAction(record) {
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
{
label: '删除', label: '删除',
popConfirm: { popConfirm: {
title: '是否确认删除', title: '是否确认删除',
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
} },
} ifShow: () => {
] return hasPermission('group:delete');
},
},
];
} }

View File

@ -7,17 +7,17 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
<a-menu-item key="1" @click="batchHandleGroup"> <a-menu-item key="1" @click="batchHandleGroup">
<Icon icon="ant-design:usergroup-add-outlined" /> <Icon icon="ant-design:usergroup-add-outlined" />
分组 分组
</a-menu-item> </a-menu-item>
<a-menu-item key="1" @click="batchHandleDelete" v-if="hasPermission('localTeacher:batchDelete')">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button
@ -60,6 +60,9 @@
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup, batchGroup } from './CeesLocalTeacher.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup, batchGroup } from './CeesLocalTeacher.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { usePermission } from '/@/hooks/web/usePermission';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
@ -173,15 +176,20 @@
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
if (selectedRowKeys.value.length < 1) {
message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 批量分组事件 * 批量分组事件
*/ */
async function batchHandleGroup() { async function batchHandleGroup() {
//if (selectedRowKeys.value.length === 0) { if (selectedRowKeys.value.length < 1) {
// return; message.warning('请至少选择一个用户!');
//} return;
}
groupModalRef.value?.setGroupOptions(groupOptions.value); groupModalRef.value?.setGroupOptions(groupOptions.value);
openGroupModal(true); openGroupModal(true);
} }
@ -189,9 +197,7 @@
* 分组选好后的确认事件 * 分组选好后的确认事件
*/ */
async function handleGroupSuccess(groupId) { async function handleGroupSuccess(groupId) {
console.log('asdfasd');
try { try {
console.log('111');
await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess); await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess);
} catch (error) { } catch (error) {
console.error('批量分组失败:', error); console.error('批量分组失败:', error);
@ -207,12 +213,14 @@
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ const actions = [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
]; ];
return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
@ -230,6 +238,9 @@
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
}, },
ifShow: () => {
return hasPermission('localTeacher:delete');
},
}, },
]; ];
} }

View File

@ -7,17 +7,17 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
<a-menu-item key="1" @click="batchHandleGroup"> <a-menu-item key="1" @click="batchHandleGroup">
<Icon icon="ant-design:usergroup-add-outlined" /> <Icon icon="ant-design:usergroup-add-outlined" />
分组 分组
</a-menu-item> </a-menu-item>
<a-menu-item key="1" @click="batchHandleDelete" v-if="hasPermission('student:batchDelete')">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button
@ -65,6 +65,10 @@
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { usePermission } from '/@/hooks/web/usePermission';
import { message } from 'ant-design-vue';
const { hasPermission } = usePermission();
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
@ -174,6 +178,10 @@
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
if (selectedRowKeys.value.length < 1) {
message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
@ -181,9 +189,10 @@
* 批量分组事件 * 批量分组事件
*/ */
async function batchHandleGroup() { async function batchHandleGroup() {
//if (selectedRowKeys.value.length === 0) { if (selectedRowKeys.value.length < 1) {
// return; message.warning('请至少选择一个用户!');
//} return;
}
groupModalRef.value?.setGroupOptions(groupOptions.value); groupModalRef.value?.setGroupOptions(groupOptions.value);
openGroupModal(true); openGroupModal(true);
} }
@ -191,9 +200,7 @@
* 分组选好后的确认事件 * 分组选好后的确认事件
*/ */
async function handleGroupSuccess(groupId) { async function handleGroupSuccess(groupId) {
console.log('asdfasd');
try { try {
console.log('111');
await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess); await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess);
} catch (error) { } catch (error) {
console.error('批量分组失败:', error); console.error('批量分组失败:', error);
@ -209,12 +216,14 @@
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ const actions = [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
]; ];
return actions;
} }
/** /**
* 下拉操作栏 * 下拉操作栏
@ -232,6 +241,9 @@
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
}, },
ifShow: () => {
return hasPermission('student:delete');
},
}, },
]; ];
} }

View File

@ -15,17 +15,17 @@
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
<a-menu-item key="1" @click="batchHandleGroup"> <a-menu-item key="1" @click="batchHandleGroup">
<Icon icon="ant-design:usergroup-add-outlined" /> <Icon icon="ant-design:usergroup-add-outlined" />
分组 分组
</a-menu-item> </a-menu-item>
<a-menu-item key="1" @click="batchHandleDelete" v-if="hasPermission('waiTeacher:batchDelete')">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button
@ -122,7 +122,8 @@
import { configStyleImportPlugin } from 'build/vite/plugin/styleImport'; import { configStyleImportPlugin } from 'build/vite/plugin/styleImport';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { registerCoordinateSystem } from 'echarts'; import { registerCoordinateSystem } from 'echarts';
import { usePermission } from '/@/hooks/web/usePermission'
const { hasPermission } = usePermission();
// //
const dormOptions = ref([]); const dormOptions = ref([]);
@ -262,16 +263,21 @@
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
if (selectedRowKeys.value.length < 1) {
message.warning('请至少选择一个用户!');
return;
}
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 批量分组事件 * 批量分组事件
*/ */
async function batchHandleGroup() { async function batchHandleGroup() {
//if (selectedRowKeys.value.length === 0) { if (selectedRowKeys.value.length < 1) {
// return; message.warning('请至少选择一个用户!');
//} return;
}
groupModalRef.value?.setGroupOptions(groupOptions.value); groupModalRef.value?.setGroupOptions(groupOptions.value);
openGroupModal(true); openGroupModal(true);
} }
@ -361,6 +367,9 @@
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
placement: 'topLeft', placement: 'topLeft',
}, },
ifShow: () => {
return hasPermission('waiTeacher:delete');
},
}, },
]; ];
} }