|
|
@@ -91,7 +91,7 @@
|
|
|
<el-button type="primary" :disabled="multiple" @click="handleBatchApplyBed()"> 批量申请床位 </el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="danger" :disabled="multiple" @click="handleBatchCancelBed()"> 批量取消床位 </el-button>
|
|
|
+ <el-button type="danger" :disabled="multiple" @click="handleBatchCancelBed()"> 批量取消床位申请 </el-button>
|
|
|
</el-col>
|
|
|
<!-- <el-col :span="1.5">
|
|
|
<el-button :disabled="multiple" icon="Delete" @click="handleDelete()"> 删除 </el-button>
|
|
|
@@ -2285,7 +2285,7 @@ const resetQuery = () => {
|
|
|
/** 删除按钮操作 */
|
|
|
const handleDelete = async (row?: StudentVO) => {
|
|
|
const studentIds = row?.id || ids.value;
|
|
|
- const [err] = await to(ElMessageBox.confirm('是否确认删除学生编号为"' + row?.name + '"的数据项?', '提示'));
|
|
|
+ const [err] = await to(ElMessageBox.confirm('是否确认删除学生姓名为"' + row?.name + '"的数据项?', '提示'));
|
|
|
if (!err) {
|
|
|
try {
|
|
|
const res = await service.delete(`/studentMsg/studentMsg/${studentIds}`);
|
|
|
@@ -2342,23 +2342,93 @@ const handleBatchCancelBed = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 获取选中学生的详细信息
|
|
|
+ const selectedStudents = studentList.value.filter((student) => ids.value.includes(student.id));
|
|
|
+
|
|
|
+ // 分类学生:可以取消和不可以取消的
|
|
|
+ const canCancelStudents: any[] = [];
|
|
|
+ const cannotCancelStudents: any[] = [];
|
|
|
+
|
|
|
+ selectedStudents.forEach((student) => {
|
|
|
+ // 检查学生是否已分配宿舍(宿舍楼栋、房间号、床位号任一不为空)
|
|
|
+ const studentAny = student as any;
|
|
|
+ const hasAssignedBed = studentAny.dormitoryBuilding || studentAny.dormitoryRoom || studentAny.extField1; // 床位号字段
|
|
|
+
|
|
|
+ if (hasAssignedBed) {
|
|
|
+ cannotCancelStudents.push(student);
|
|
|
+ } else {
|
|
|
+ canCancelStudents.push(student);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 构建确认消息
|
|
|
+ let confirmMessage = '';
|
|
|
+
|
|
|
+ if (canCancelStudents.length > 0) {
|
|
|
+ confirmMessage += `<div style="margin-bottom: 15px;">
|
|
|
+ <strong style="color: #67c23a;">✅ 可以取消床位申请的学生 (${canCancelStudents.length}人):</strong><br/>
|
|
|
+ ${canCancelStudents.map((student) => `• ${student.name} (${student.studentNo})`).join('<br/>')}
|
|
|
+ </div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cannotCancelStudents.length > 0) {
|
|
|
+ confirmMessage += `<div style="margin-bottom: 15px;">
|
|
|
+ <strong style="color: #f56c6c;">❌ 无法取消床位申请的学生 (${cannotCancelStudents.length}人):</strong><br/>
|
|
|
+ ${cannotCancelStudents.map((student) => `• ${student.name} (${student.studentNo}) - 已分配宿舍`).join('<br/>')}
|
|
|
+ </div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有学生可以取消,直接提示
|
|
|
+ if (canCancelStudents.length === 0) {
|
|
|
+ ElMessage.warning('选中的学生都已分配宿舍,无法取消床位申请');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示确认对话框
|
|
|
const [err] = await to(
|
|
|
- ElMessageBox.confirm('请确认是否取消,会将学生已有宿舍清除!!!', '批量取消床位', {
|
|
|
- confirmButtonText: '确认取消',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- dangerouslyUseHTMLString: true
|
|
|
- })
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ `<div style="text-align: left; max-height: 400px; overflow-y: auto;">
|
|
|
+ <div style="margin-bottom: 15px; font-size: 14px;">
|
|
|
+ <strong>批量取消床位申请确认</strong><br/>
|
|
|
+ 系统将只对未分配宿舍的学生执行取消床位申请操作。
|
|
|
+ </div>
|
|
|
+ ${confirmMessage}
|
|
|
+ <div style="margin-top: 15px; padding: 10px; background-color: #f0f9ff; border-left: 4px solid #409eff; border-radius: 4px;">
|
|
|
+ <strong>操作说明:</strong><br/>
|
|
|
+ • 已分配宿舍的学生将被跳过<br/>
|
|
|
+ • 仅对未分配宿舍的学生执行取消操作<br/>
|
|
|
+ • 确认后将无法撤销此操作
|
|
|
+ </div>
|
|
|
+ </div>`,
|
|
|
+ '批量取消床位申请',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确认取消',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ customClass: 'batch-cancel-bed-dialog'
|
|
|
+ }
|
|
|
+ )
|
|
|
);
|
|
|
|
|
|
if (!err) {
|
|
|
try {
|
|
|
+ // 只对可以取消的学生执行操作
|
|
|
+ const allowedStudentIds = canCancelStudents.map((student) => student.id);
|
|
|
+
|
|
|
const res = await service.post('/studentMsg/studentMsg/batchCancelBed', {
|
|
|
- studentIds: ids.value
|
|
|
+ studentIds: allowedStudentIds
|
|
|
});
|
|
|
+
|
|
|
if (res && res.code === 200) {
|
|
|
await getList();
|
|
|
- ElMessage.success('批量取消床位成功');
|
|
|
+
|
|
|
+ // 根据操作结果给出不同的提示
|
|
|
+ if (cannotCancelStudents.length > 0) {
|
|
|
+ ElMessage.success(`批量取消床位成功!成功取消 ${canCancelStudents.length} 名学生,跳过 ${cannotCancelStudents.length} 名已分配宿舍的学生`);
|
|
|
+ } else {
|
|
|
+ ElMessage.success('批量取消床位成功');
|
|
|
+ }
|
|
|
} else {
|
|
|
ElMessage.error(res?.msg || '批量取消床位失败');
|
|
|
}
|
|
|
@@ -3154,4 +3224,26 @@ onMounted(() => {
|
|
|
:deep(.el-message) {
|
|
|
z-index: 4000 !important;
|
|
|
}
|
|
|
+
|
|
|
+/* 批量取消床位申请确认对话框样式 */
|
|
|
+:deep(.batch-cancel-bed-dialog) {
|
|
|
+ max-width: 600px !important;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.batch-cancel-bed-dialog .el-message-box__content) {
|
|
|
+ max-height: 500px;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.batch-cancel-bed-dialog .el-message-box__message) {
|
|
|
+ line-height: 1.6;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.batch-cancel-bed-dialog .el-message-box__message div) {
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.batch-cancel-bed-dialog .el-message-box__message strong) {
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
</style>
|