提交代码
This commit is contained in:
1 parent
3468e1c88a
commit
bd5d4e57fc
7 files changed
+214
-5
No files matched your search
@@ -201,3 +201,17 @@ export const classTeacherRecallSelectedBeds = (bedIds: number[], classId?: strin
|
||||
params: { classId }
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 班主任退宿选中床位
|
||||
* @param bedIds 床位ID数组
|
||||
* @param classId 班级ID,可为空
|
||||
*/
|
||||
export const classTeacherStayawaySelectedBeds = (bedIds: number[], classId?: string | number) => {
|
||||
return request({
|
||||
url: '/dormBedStudent/dormBedStudent/classTeacherStayawaySelectedBeds',
|
||||
method: 'post',
|
||||
data: bedIds,
|
||||
params: { classId }
|
||||
});
|
||||
};
|
||||
@@ -99,6 +99,7 @@
|
||||
<!-- <el-button type="success" icon="UserFilled" size="small" @click="handleRandomAllocation">随机分配</el-button>
|
||||
<el-button type="info" icon="Sort" size="small" @click="handleStudentNoAllocation">按学号分配</el-button> -->
|
||||
<el-button type="warning" icon="RefreshLeft" size="small" @click="handleRecallBeds">收回选中床位</el-button>
|
||||
<el-button type="danger" icon="House" size="small" @click="handleStayawayBeds">退宿选中床位</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" style="text-align: right">
|
||||
<el-button
|
||||
@@ -304,7 +305,8 @@ import {
|
||||
getClassTeacherUnallocatedStudents,
|
||||
classTeacherRandomAllocation,
|
||||
classTeacherStudentNoAllocation,
|
||||
classTeacherRecallSelectedBeds
|
||||
classTeacherRecallSelectedBeds,
|
||||
classTeacherStayawaySelectedBeds
|
||||
} from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
// 导入API方法
|
||||
import { listDormRoomByClassId } from '@/api/xg/xgss/dormRoom/index';
|
||||
@@ -748,6 +750,42 @@ const handleRecallBeds = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 退宿床位 */
|
||||
const handleStayawayBeds = async () => {
|
||||
if (!selectedBuilding.value) {
|
||||
ElMessage.warning('请先选择宿舍楼');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取选中的床位ID数组
|
||||
const selectedBedIds = selectedRows.value
|
||||
.filter((row) => row.isBed && row.studentId) // 只退宿已分配的床位
|
||||
.map((bed) => bed.id);
|
||||
|
||||
if (selectedBedIds.length === 0) {
|
||||
ElMessage.warning('请先勾选要退宿的床位!');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const confirmMessage = `确认退宿选中的 ${selectedBedIds.length} 个床位吗?\n\n退宿后,这些床位上学生的床位信息将被清空,同时该床位归还学校。`;
|
||||
|
||||
await ElMessageBox.confirm(confirmMessage, '确认退宿选中床位', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
|
||||
await classTeacherStayawaySelectedBeds(selectedBedIds, activeClassId.value);
|
||||
ElMessage.success('退宿选中床位成功');
|
||||
handleAllocationSuccess();
|
||||
} catch (error: any) {
|
||||
if (error !== 'cancel') {
|
||||
ElMessage.error('退宿床位失败');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** 分配成功回调 */
|
||||
const handleAllocationSuccess = () => {
|
||||
// 清除缓存,确保数据刷新
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<el-col :span="12">
|
||||
<el-button type="primary" icon="check" size="small" @click="handleAddRoom">分配给班级</el-button>
|
||||
<el-button type="warning" icon="RefreshLeft" size="small" @click="handleBatchRecall">批量收回宿舍</el-button>
|
||||
<el-button type="danger" icon="UserFilled" size="small" @click="handleBatchStayaway">批量退宿床位</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" style="text-align: right">
|
||||
<el-button
|
||||
@@ -358,7 +359,7 @@
|
||||
|
||||
<script setup name="DormRoomTreeManagement" lang="ts">
|
||||
import { ref, computed, reactive, onMounted, nextTick, watch, getCurrentInstance } from 'vue';
|
||||
import { InfoFilled, House, Avatar } from '@element-plus/icons-vue';
|
||||
import { InfoFilled, House, Avatar, UserFilled } from '@element-plus/icons-vue';
|
||||
import type { DormBuildingTreeVO } from '@/api/xg/xgss/dormBedStudent/dormBedStudent/types';
|
||||
import type { DormTreeNode, BedInfo } from '@/api/xg/xgss/xsssfjgl/types';
|
||||
import type { DormRoomVO } from '@/api/xg/xgss/dormRoom/types';
|
||||
@@ -375,7 +376,7 @@ import ElMessageBox from 'element-plus/es/components/message-box/index';
|
||||
import RoomDialog from './components/RoomDialog.vue';
|
||||
import BedDialog from './components/BedDialog.vue';
|
||||
import ClassAllocationDialog from './components/ClassAllocationDialog.vue';
|
||||
import { batchRecallDormBeds, batchRecallClassAllocation } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
import { batchRecallDormBeds, batchRecallClassAllocation, classTeacherStayawaySelectedBeds } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
|
||||
// const { proxy } = getCurrentInstance();
|
||||
|
||||
@@ -712,6 +713,39 @@ const handleBatchRecall = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 批量退宿床位 */
|
||||
const handleBatchStayaway = async () => {
|
||||
if (!selectedBuilding.value) {
|
||||
ElMessage.warning('请先选择宿舍楼');
|
||||
return;
|
||||
}
|
||||
const selectedBeds = selectedRows.value.filter((row) => row.isBed).map((row) => row.id);
|
||||
if (selectedBeds.length === 0) {
|
||||
ElMessage.warning('请先选择要退宿的床位');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const content = `确认退宿选中的 ${selectedBeds.length} 个床位吗?\n\n重要提示:退宿后,这些床位上学生的床位信息将被清空,同时该床位归还学校。`;
|
||||
await ElMessageBox.confirm(content, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await classTeacherStayawaySelectedBeds(selectedBeds);
|
||||
ElMessage.success('批量退宿成功');
|
||||
// 刷新数据
|
||||
selectableRowsCache.value = [];
|
||||
loadRoomData();
|
||||
} catch (e) {
|
||||
ElMessage.error('批量退宿失败');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
/** 全部展开 */
|
||||
const expandAll = async () => {
|
||||
if (expandAllLoading.value || selectionLoading.value || !roomList.value?.length) return;
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<el-col :span="12">
|
||||
<el-button type="primary" icon="check" size="small" @click="handleAddRoom">分配给二级学院</el-button>
|
||||
<el-button type="warning" icon="RefreshLeft" size="small" @click="handleBatchRecall">批量收回宿舍</el-button>
|
||||
<el-button type="danger" icon="UserFilled" size="small" @click="handleBatchStayaway">批量退宿床位</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" style="text-align: right">
|
||||
<el-button
|
||||
@@ -356,7 +357,7 @@
|
||||
|
||||
<script setup name="DormRoomTreeManagement" lang="ts">
|
||||
import { ref, computed, reactive, onMounted, nextTick, watch, getCurrentInstance } from 'vue';
|
||||
import { InfoFilled, House, Avatar } from '@element-plus/icons-vue';
|
||||
import { InfoFilled, House, Avatar, UserFilled } from '@element-plus/icons-vue';
|
||||
import type { DormTreeNode, BedInfo } from '@/api/xg/xgss/xsssfjgl/types';
|
||||
import type { DormRoomVO } from '@/api/xg/xgss/dormRoom/types';
|
||||
import type { DormBedDetailVO } from '@/api/xg/xgss/dormBed/types';
|
||||
@@ -372,7 +373,7 @@ import ElMessageBox from 'element-plus/es/components/message-box/index';
|
||||
import RoomDialog from './components/RoomDialog.vue';
|
||||
import BedDialog from './components/BedDialog.vue';
|
||||
import CollegeAllocationDialog from './components/CollegeAllocationDialog.vue';
|
||||
import { batchRecallDormBeds } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
import { batchRecallDormBeds, classTeacherStayawaySelectedBeds } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
|
||||
// const { proxy } = getCurrentInstance();
|
||||
|
||||
@@ -713,6 +714,39 @@ const handleBatchRecall = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 批量退宿床位 */
|
||||
const handleBatchStayaway = async () => {
|
||||
if (!selectedBuilding.value) {
|
||||
ElMessage.warning('请先选择宿舍楼');
|
||||
return;
|
||||
}
|
||||
const selectedBeds = selectedRows.value.filter((row) => row.isBed).map((row) => row.id);
|
||||
if (selectedBeds.length === 0) {
|
||||
ElMessage.warning('请先选择要退宿的床位');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const content = `确认退宿选中的 ${selectedBeds.length} 个床位吗?\n\n重要提示:退宿后,这些床位上学生的床位信息将被清空,同时该床位归还学校。`;
|
||||
await ElMessageBox.confirm(content, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await classTeacherStayawaySelectedBeds(selectedBeds);
|
||||
ElMessage.success('批量退宿成功');
|
||||
// 刷新数据
|
||||
selectableRowsCache.value = [];
|
||||
loadRoomData();
|
||||
} catch (e) {
|
||||
ElMessage.error('批量退宿失败');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
/** 全部展开 */
|
||||
const expandAll = async () => {
|
||||
if (expandAllLoading.value || selectionLoading.value || !roomList.value?.length) return;
|
||||
|
||||
Reference in new issue
Block a user