将批量分组功能添加到研究生管理和外校教师管理

This commit is contained in:
Qi 2025-04-27 15:44:47 +08:00
parent 1f9a5ce88c
commit f1ee6723d0
7 changed files with 678 additions and 401 deletions

View File

@ -1,22 +1,23 @@
import {defHttp} from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage"; import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage(); const { createConfirm } = useMessage();
enum Api { enum Api {
list = '/cees/student/list', list = '/cees/student/list',
save='/cees/student/add', save = '/cees/student/add',
edit='/cees/student/edit', edit = '/cees/student/edit',
deleteOne = '/cees/student/delete', deleteOne = '/cees/student/delete',
deleteBatch = '/cees/student/deleteBatch', deleteBatch = '/cees/student/deleteBatch',
importExcel = '/cees/student/importExcel', importExcel = '/cees/student/importExcel',
exportXls = '/cees/student/exportXls', exportXls = '/cees/student/exportXls',
updateGroupUser = '/cees/ceesGroup/updateGroupUser', updateGroupUser = '/cees/ceesGroup/updateGroupUser',
batchGroup = '/cees/student/batchGroup',
} }
//获取分组 //获取分组
export const getGroup = () => export const getGroup = () =>
defHttp.get({url: '/cees/ceesGroup/list'}).then((res) => { defHttp.get({ url: '/cees/ceesGroup/list' }).then((res) => {
return res.records; return res.records;
}); });
/** /**
@ -32,17 +33,16 @@ export const getImportUrl = Api.importExcel;
* *
* @param params * @param params
*/ */
export const list = (params) => export const list = (params) => defHttp.get({ url: Api.list, params });
defHttp.get({url: Api.list, params});
/** /**
* *
*/ */
export const deleteOne = (params,handleSuccess) => { export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess(); handleSuccess();
}); });
} };
/** /**
* *
* @param params * @param params
@ -55,27 +55,46 @@ export const batchDelete = (params, handleSuccess) => {
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onOk: () => { onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess(); handleSuccess();
}); });
} },
}); });
} };
/**
*
* @param params
*/
export const batchGroup = (params, handleSuccess) => {
console.log('params', params);
createConfirm({
iconType: 'warning',
title: '确认分组',
content: '是否分组选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.post({ url: Api.batchGroup, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
//更新分组中间表 //更新分组中间表
export const updateGroupUser = (params) => { export const updateGroupUser = (params) => {
return defHttp.post({url: Api.updateGroupUser, params}); return defHttp.post({ url: Api.updateGroupUser, params });
} };
/** /**
* *
* @param params * @param params
*/ */
export const saveOrUpdate = (params, isUpdate) => { export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save; const url = isUpdate ? Api.edit : Api.save;
// 更新分组中间表 // 更新分组中间表
const groupUserParams = { const groupUserParams = {
userId: params.userId, userId: params.userId,
groupId: params.groupId groupId: params.groupId,
} };
updateGroupUser(groupUserParams); updateGroupUser(groupUserParams);
return defHttp.post({url: url, params}); return defHttp.post({ url: url, params });
} };

View File

@ -14,9 +14,14 @@
<Icon icon="ant-design:delete-outlined" /> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
<a-menu-item key="1" @click="batchHandleGroup">
<Icon icon="ant-design:usergroup-add-outlined" />
分组
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
>批量操作
<Icon icon="mdi:chevron-down" /> <Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
@ -44,27 +49,31 @@
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<StudentModal @register="registerModal" @success="handleSuccess" /> <StudentModal @register="registerModal" @success="handleSuccess" />
<GroupSelectModal ref="groupModalRef" @register="registerGroupModal" @success="handleGroupSuccess" />
</div> </div>
</template> </template>
<script lang="ts" name="cees-student" setup> <script lang="ts" name="cees-student" setup>
import { ref, reactive, computed, unref, onMounted } from 'vue'; import { ref, reactive, computed, unref, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'; import GroupSelectModal from './components/GroupSelectModal.vue';
import StudentModal from './components/StudentModal.vue'; import { useListPage } from '/@/hooks/system/useListPage';
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './Student.data'; import StudentModal from './components/StudentModal.vue';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup } from './Student.api'; import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './Student.data';
import { downloadFile } from '/@/utils/common/renderUtils'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup, batchGroup } from './Student.api';
import { useUserStore } from '/@/store/modules/user'; import { downloadFile } from '/@/utils/common/renderUtils';
import { defHttp } from '/@/utils/http/axios'; import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({}); import { defHttp } from '/@/utils/http/axios';
const checkedKeys = ref<Array<string | number>>([]); const queryParam = reactive<any>({});
const userStore = useUserStore(); const checkedKeys = ref<Array<string | number>>([]);
//model const userStore = useUserStore();
const [registerModal, { openModal }] = useModal(); //model
//table const [registerModal, { openModal }] = useModal();
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ const [registerGroupModal, { openModal: openGroupModal }] = useModal();
const groupModalRef = ref<any>(null);
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: { tableProps: {
title: '研究生表', title: '研究生表',
api: list, api: list,
@ -95,14 +104,14 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
}, },
}); });
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const groupOptions = ref<{ label: string; value: number }[]>([]); const groupOptions = ref<{ label: string; value: number }[]>([]);
onMounted(async () => { onMounted(async () => {
try { try {
const res = await getGroup(); const res = await getGroup();
groupOptions.value = res.map((group) => ({ groupOptions.value = res.map((group) => ({
@ -113,81 +122,104 @@ onMounted(async () => {
} catch (error) { } catch (error) {
console.error('获取分组数据失败:', error); console.error('获取分组数据失败:', error);
} }
}); });
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
/** /**
* 高级查询事件 * 高级查询事件
*/ */
function handleSuperQuery(params) { function handleSuperQuery(params) {
Object.keys(params).map((k) => { Object.keys(params).map((k) => {
queryParam[k] = params[k]; queryParam[k] = params[k];
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/**
/**
* 批量分组事件
*/
async function batchHandleGroup() {
//if (selectedRowKeys.value.length === 0) {
// return;
//}
groupModalRef.value?.setGroupOptions(groupOptions.value);
openGroupModal(true);
}
/**
* 分组选好后的确认事件
*/
async function handleGroupSuccess(groupId) {
console.log('asdfasd');
try {
console.log('111');
await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess);
} catch (error) {
console.error('批量分组失败:', error);
}
}
/**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
]; ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
@ -202,7 +234,7 @@ function getDropDownAction(record) {
}, },
}, },
]; ];
} }
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -0,0 +1,84 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" title="所属分组" @ok="handleOk" :canFullscreen="false">
<div class="group-select-modal">
<div class="form-wrapper">
<div class="form-item">
<span class="required-label">所属分组</span>
<a-select v-model:value="formState.groupId" placeholder="请选择所属分组" class="select-width">
<a-select-option v-for="item in groupOptions" :key="item.value" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</div>
</div>
</div>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { message } from 'ant-design-vue';
const emit = defineEmits(['register', 'success']);
const formState = ref({
groupId: null,
});
const groupOptions = ref<{ label: string; value: number }[]>([]);
const [registerModal, { closeModal }] = useModalInner(async (data) => {
formState.value.groupId = null;
if (data?.options) {
groupOptions.value = data.options;
}
});
function setGroupOptions(options) {
groupOptions.value = options;
}
function handleOk() {
if (!formState.value.groupId) {
message.warning('请选择分组!');
return;
}
emit('success', formState.value.groupId);
closeModal();
}
defineExpose({
setGroupOptions,
});
</script>
<style lang="less" scoped>
.group-select-modal {
padding: 20px 24px;
.form-wrapper {
display: flex;
justify-content: center;
align-items: center;
}
.form-item {
display: flex;
align-items: center;
gap: 8px;
}
.required-label {
white-space: nowrap;
&::before {
content: '*';
color: #ff4d4f;
margin-right: 4px;
}
}
.select-width {
width: 200px;
}
}
</style>

View File

@ -16,16 +16,15 @@
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
>批量操作
<Icon icon="mdi:chevron-down" /> <Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
<!-- 新增生成账号按钮 --> <!-- 新增生成账号按钮 -->
<a-button type="primary" @click="showAutoGenerateForm = true" preIcon="ant-design:plus-outlined"> <a-button type="primary" @click="showAutoGenerateForm = true" preIcon="ant-design:plus-outlined"> 生成账号 </a-button>
生成账号
</a-button>
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
@ -50,12 +49,17 @@
<CeesUserModal @register="registerModal" @success="handleSuccess" /> <CeesUserModal @register="registerModal" @success="handleSuccess" />
<!-- 生成账号表单 --> <!-- 生成账号表单 -->
<a-modal v-model:visible="showAutoGenerateForm" title="生成账号" @ok="handleAutoGenerate" <a-modal
@cancel="showAutoGenerateForm = false" :width="600" :bodyStyle="{ padding: '24px' }"> v-model:visible="showAutoGenerateForm"
title="生成账号"
@ok="handleAutoGenerate"
@cancel="showAutoGenerateForm = false"
:width="600"
:bodyStyle="{ padding: '24px' }"
>
<a-form :model="autoGenerateForm" layout="vertical"> <a-form :model="autoGenerateForm" layout="vertical">
<a-form-item label="账号类型" class="form-item-custom"> <a-form-item label="账号类型" class="form-item-custom">
<a-select v-model="autoGenerateForm.group" placeholder="请选择账号类型" @change="handleGroupChange" <a-select v-model="autoGenerateForm.group" placeholder="请选择账号类型" @change="handleGroupChange" class="select-custom">
class="select-custom">
<a-select-option v-for="item in autoGeneratType" :key="item.id" :value="item.value"> <a-select-option v-for="item in autoGeneratType" :key="item.id" :value="item.value">
{{ item.name }} {{ item.name }}
</a-select-option> </a-select-option>
@ -63,8 +67,7 @@
</a-form-item> </a-form-item>
<a-form-item label="专业" class="form-item-custom"> <a-form-item label="专业" class="form-item-custom">
<a-select v-model="autoGenerateForm.majorId" placeholder="请选择专业" @change="handleMajorChange" <a-select v-model="autoGenerateForm.majorId" placeholder="请选择专业" @change="handleMajorChange" class="select-custom">
class="select-custom">
<a-select-option v-for="item in majors" :key="item.id" :value="item.value"> <a-select-option v-for="item in majors" :key="item.id" :value="item.value">
{{ item.name }} {{ item.name }}
</a-select-option> </a-select-option>
@ -72,8 +75,13 @@
</a-form-item> </a-form-item>
<a-form-item label="账号数量" class="form-item-custom"> <a-form-item label="账号数量" class="form-item-custom">
<a-input-number v-model="autoGenerateForm.num" :min="1" placeholder="请输入账号数量" @change="handleNumChange" <a-input-number
class="input-number-custom" /> v-model="autoGenerateForm.num"
:min="1"
placeholder="请输入账号数量"
@change="handleNumChange"
class="input-number-custom"
/>
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
@ -81,75 +89,74 @@
</template> </template>
<script lang="ts" name="org.jeecg.modules-ceesUser" setup> <script lang="ts" name="org.jeecg.modules-ceesUser" setup>
import { ref, onMounted, reactive } from 'vue'; import { ref, onMounted, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'; import { useListPage } from '/@/hooks/system/useListPage';
import CeesUserModal from './components/CeesUserModal.vue'; import CeesUserModal from './components/CeesUserModal.vue';
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesUser.data'; import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesUser.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate, getGroup, generateAccount } from './CeesUser.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate, getGroup, generateAccount } from './CeesUser.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 { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
//
const showAutoGenerateForm = ref(false); //
// const handleGroupChange = (value) => {
const showAutoGenerateForm = ref(false); //
const handleGroupChange = (value) => {
autoGenerateForm.group = value; autoGenerateForm.group = value;
}; };
const handleMajorChange = (value) => { const handleMajorChange = (value) => {
autoGenerateForm.majorId = value; autoGenerateForm.majorId = value;
}; };
const handleNumChange = (value) => { const handleNumChange = (value) => {
autoGenerateForm.num = value; autoGenerateForm.num = value;
} };
const autoGenerateForm = reactive({ const autoGenerateForm = reactive({
group: undefined, // group: undefined, //
majorId: undefined, // majorId: undefined, //
num: undefined, // num: undefined, //
}); });
// //
const autoGeneratType = ref([ const autoGeneratType = ref([
{ id: 1, name: '研究生', value: 2 }, { id: 1, name: '研究生', value: 2 },
{ id: 2, name: '本校老师', value: 3 }, { id: 2, name: '本校老师', value: 3 },
{ id: 3, name: "外校老师", value: 4 } { id: 3, name: '外校老师', value: 4 },
]); ]);
// //
const majors = ref([ const majors = ref([
{ id: 1, name: '语文', value: 1 }, { id: 1, name: '语文', value: 1 },
{ id: 2, name: '地理', value: 4 }, { id: 2, name: '地理', value: 4 },
{ id: 3, name: '历史', value: 7 }, { id: 3, name: '历史', value: 7 },
{ id: 4, name: '政治', value: 8 }, { id: 4, name: '政治', value: 8 },
]); ]);
// //
const handleAutoGenerate = () => { const handleAutoGenerate = () => {
console.log(autoGenerateForm) console.log(autoGenerateForm);
if (autoGenerateForm.group == undefined) { if (autoGenerateForm.group == undefined) {
message.warning('请选择身份', 1.5); message.warning('请选择身份', 1.5);
return return;
} }
if (autoGenerateForm.majorId == undefined) { if (autoGenerateForm.majorId == undefined) {
message.warning('请选择专业', 1.5); message.warning('请选择专业', 1.5);
return return;
} }
if (autoGenerateForm.num == undefined) { if (autoGenerateForm.num == undefined) {
message.warning('请输入账号数量', 1.5); message.warning('请输入账号数量', 1.5);
return return;
} }
// 5000 // 5000
if (autoGenerateForm.num <= 0) { if (autoGenerateForm.num <= 0) {
message.warning('账号数量必须大于0', 1.5); message.warning('账号数量必须大于0', 1.5);
return return;
} }
if (autoGenerateForm.num > 500) { if (autoGenerateForm.num > 500) {
message.warning('账号数量不能大于500', 1.5); message.warning('账号数量不能大于500', 1.5);
return return;
} }
// API // API
try { try {
@ -163,22 +170,21 @@ const handleAutoGenerate = () => {
} else { } else {
message.error('生成账号失败', 1.5); message.error('生成账号失败', 1.5);
} }
});
})
} catch (error) { } catch (error) {
// //
message.error('账号生成失败,请重试'); message.error('账号生成失败,请重试');
} finally { } finally {
showAutoGenerateForm.value = false; showAutoGenerateForm.value = false;
} }
}; };
// //
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();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: { tableProps: {
title: 'CEES用户表', title: 'CEES用户表',
api: list, api: list,
@ -208,10 +214,10 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
}, },
}); });
const groupOptions = ref<{ label: string; value: number }[]>([]); const groupOptions = ref<{ label: string; value: number }[]>([]);
onMounted(async () => { onMounted(async () => {
try { try {
const res = await getGroup(); const res = await getGroup();
groupOptions.value = res.map((group) => ({ groupOptions.value = res.map((group) => ({
@ -222,63 +228,63 @@ onMounted(async () => {
} catch (error) { } catch (error) {
console.error('获取分组数据失败:', error); console.error('获取分组数据失败:', error);
} }
}); });
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) { function handleSuperQuery(params) {
Object.keys(params).map((k) => { Object.keys(params).map((k) => {
queryParam[k] = params[k]; queryParam[k] = params[k];
}); });
reload(); reload();
} }
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
function getTableAction(record) { function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
}, },
]; ];
} }
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
@ -293,19 +299,19 @@ function getDropDownAction(record) {
}, },
}, },
]; ];
} }
</script> </script>
<style scoped> <style scoped>
.form-item-custom { .form-item-custom {
margin-bottom: 16px; margin-bottom: 16px;
} }
.select-custom { .select-custom {
width: 100%; width: 100%;
} }
.input-number-custom { .input-number-custom {
width: 100%; width: 100%;
} }
</style> </style>

View File

@ -14,15 +14,16 @@ enum Api {
updateGroupUser = '/cees/ceesGroup/updateGroupUser', updateGroupUser = '/cees/ceesGroup/updateGroupUser',
updateDormitory = 'cees/ceesWaiTeacher/updateDormitory', updateDormitory = 'cees/ceesWaiTeacher/updateDormitory',
cancelCheckIn = 'cees/ceesWaiTeacher/cancelCheckIn', cancelCheckIn = 'cees/ceesWaiTeacher/cancelCheckIn',
confirmCheckIn = 'cees/ceesWaiTeacher/confirmCheckIn' confirmCheckIn = 'cees/ceesWaiTeacher/confirmCheckIn',
batchGroup = '/cees/ceesWaiTeacher/batchGroup',
} }
export const updateDormitory = (id, dormitory) => defHttp.get({ url: Api.updateDormitory, params: { id, dormitory } }); // ✅ 将参数包装为独立的对象 }); export const updateDormitory = (id, dormitory) => defHttp.get({ url: Api.updateDormitory, params: { id, dormitory } }); // ✅ 将参数包装为独立的对象 });
//取消确认报到 //取消确认报到
export const cancelCheckIn = (params) => defHttp.get({url: Api.cancelCheckIn, params}); export const cancelCheckIn = (params) => defHttp.get({ url: Api.cancelCheckIn, params });
//确认报到 //确认报到
export const confirmCheckIn = (params) => defHttp.get({url: Api.confirmCheckIn, params}); export const confirmCheckIn = (params) => defHttp.get({ url: Api.confirmCheckIn, params });
//获取分组 //获取分组
export const getGroup = () => export const getGroup = () =>
defHttp.get({ url: '/cees/ceesGroup/list' }).then((res) => { defHttp.get({ url: '/cees/ceesGroup/list' }).then((res) => {
@ -69,6 +70,25 @@ export const batchDelete = (params, handleSuccess) => {
}, },
}); });
}; };
/**
*
* @param params
*/
export const batchGroup = (params, handleSuccess) => {
console.log('params', params);
createConfirm({
iconType: 'warning',
title: '确认分组',
content: '是否分组选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.post({ url: Api.batchGroup, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
//更新分组中间表 //更新分组中间表
export const updateGroupUser = (params) => { export const updateGroupUser = (params) => {

View File

@ -22,6 +22,10 @@
<Icon icon="ant-design:delete-outlined" /> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
<a-menu-item key="1" @click="batchHandleGroup">
<Icon icon="ant-design:usergroup-add-outlined" />
分组
</a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button
@ -85,6 +89,7 @@
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<CeesWaiTeacherModal @register="registerModal" @success="handleSuccess" /> <CeesWaiTeacherModal @register="registerModal" @success="handleSuccess" />
<GroupSelectModal ref="groupModalRef" @register="registerGroupModal" @success="handleGroupSuccess" />
</div> </div>
</template> </template>
@ -92,6 +97,7 @@
import { ref, reactive, computed, unref, onMounted } from 'vue'; import { ref, reactive, computed, unref, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import GroupSelectModal from './components/GroupSelectModal.vue';
import { useListPage } from '/@/hooks/system/useListPage'; import { useListPage } from '/@/hooks/system/useListPage';
import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue'; import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue';
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesWaiTeacher.data'; import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesWaiTeacher.data';
@ -105,6 +111,7 @@
updateDormitory, updateDormitory,
cancelCheckIn, cancelCheckIn,
confirmCheckIn, confirmCheckIn,
batchGroup,
} from './CeesWaiTeacher.api'; } from './CeesWaiTeacher.api';
import { selectBySex } from '/@/views/cees/dormitory/CeesDormitoryInfo.api'; import { selectBySex } from '/@/views/cees/dormitory/CeesDormitoryInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
@ -121,6 +128,8 @@
//model //model
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerGroupModal, { openModal: openGroupModal }] = useModal();
const groupModalRef = ref<any>(null);
//table //table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: { tableProps: {
@ -255,6 +264,29 @@
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/**
* 批量分组事件
*/
async function batchHandleGroup() {
//if (selectedRowKeys.value.length === 0) {
// return;
//}
groupModalRef.value?.setGroupOptions(groupOptions.value);
openGroupModal(true);
}
/**
* 分组选好后的确认事件
*/
async function handleGroupSuccess(groupId) {
console.log('asdfasd');
try {
console.log('111');
await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess);
} catch (error) {
console.error('批量分组失败:', error);
}
}
/** /**
* 成功回调 * 成功回调
*/ */

View File

@ -0,0 +1,84 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" title="所属分组" @ok="handleOk" :canFullscreen="false">
<div class="group-select-modal">
<div class="form-wrapper">
<div class="form-item">
<span class="required-label">所属分组</span>
<a-select v-model:value="formState.groupId" placeholder="请选择所属分组" class="select-width">
<a-select-option v-for="item in groupOptions" :key="item.value" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</div>
</div>
</div>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { message } from 'ant-design-vue';
const emit = defineEmits(['register', 'success']);
const formState = ref({
groupId: null,
});
const groupOptions = ref<{ label: string; value: number }[]>([]);
const [registerModal, { closeModal }] = useModalInner(async (data) => {
formState.value.groupId = null;
if (data?.options) {
groupOptions.value = data.options;
}
});
function setGroupOptions(options) {
groupOptions.value = options;
}
function handleOk() {
if (!formState.value.groupId) {
message.warning('请选择分组!');
return;
}
emit('success', formState.value.groupId);
closeModal();
}
defineExpose({
setGroupOptions,
});
</script>
<style lang="less" scoped>
.group-select-modal {
padding: 20px 24px;
.form-wrapper {
display: flex;
justify-content: center;
align-items: center;
}
.form-item {
display: flex;
align-items: center;
gap: 8px;
}
.required-label {
white-space: nowrap;
&::before {
content: '*';
color: #ff4d4f;
margin-right: 4px;
}
}
.select-width {
width: 200px;
}
}
</style>