提交审核
This commit is contained in:
1 parent
49a16d130e
commit
f35359a84e
5 files changed
+113
-34
No files matched your search
+7
-2
@@ -172,8 +172,13 @@ public class XgDormHygieneCheckController extends BaseController {
|
||||
@Log(title = "宿舍卫生检查", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/saveCompleteData")
|
||||
public R<Void> saveCompleteData(@Validated(AddGroup.class) @RequestBody XgDormHygieneCheckCompleteBo bo) {
|
||||
return toAjax(xgDormHygieneCheckService.saveCompleteData(bo));
|
||||
public R<Long> saveCompleteData(@Validated(AddGroup.class) @RequestBody XgDormHygieneCheckCompleteBo bo) {
|
||||
Long hygieneCheckId = xgDormHygieneCheckService.saveCompleteData(bo);
|
||||
if (hygieneCheckId != null) {
|
||||
return R.ok(hygieneCheckId);
|
||||
} else {
|
||||
return R.fail("保存宿舍卫生检查数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -116,9 +116,9 @@ public interface IXgDormHygieneCheckService {
|
||||
* 保存完整的宿舍卫生检查数据(包含学生评分和违纪记录)
|
||||
*
|
||||
* @param bo 完整的宿舍卫生检查数据
|
||||
* @return 是否保存成功
|
||||
* @return 检查记录ID,保存失败返回null
|
||||
*/
|
||||
Boolean saveCompleteData(XgDormHygieneCheckCompleteBo bo);
|
||||
Long saveCompleteData(XgDormHygieneCheckCompleteBo bo);
|
||||
|
||||
/**
|
||||
* 更新完整的宿舍卫生检查数据(包含学生评分和违纪记录)
|
||||
|
||||
+4
-4
@@ -638,11 +638,11 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
||||
* 保存完整的宿舍卫生检查数据(包含学生评分和违纪记录)
|
||||
*
|
||||
* @param bo 完整的宿舍卫生检查数据
|
||||
* @return 是否保存成功
|
||||
* @return 检查记录ID,保存失败返回null
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean saveCompleteData(XgDormHygieneCheckCompleteBo bo) {
|
||||
public Long saveCompleteData(XgDormHygieneCheckCompleteBo bo) {
|
||||
try {
|
||||
// 1. 转换并保存主表数据
|
||||
XgDormHygieneCheck add = MapstructUtils.convert(bo, XgDormHygieneCheck.class);
|
||||
@@ -652,7 +652,7 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
||||
|
||||
if (!flag) {
|
||||
log.error("保存宿舍卫生检查主表数据失败");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
Long hygieneCheckId = add.getId();
|
||||
@@ -768,7 +768,7 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
||||
}
|
||||
|
||||
log.info("完整保存宿舍卫生检查数据成功,检查ID: {}", hygieneCheckId);
|
||||
return true;
|
||||
return hygieneCheckId;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("保存宿舍卫生检查数据失败", e);
|
||||
|
||||
+84
-15
@@ -187,6 +187,16 @@
|
||||
@submit="handleSingleCheckSubmit"
|
||||
@close="handleSingleCheckClose"
|
||||
/>
|
||||
|
||||
<!-- 编辑房间检查弹窗 -->
|
||||
<DormHygieneCheckEditDialog
|
||||
:visible="editCheckVisible"
|
||||
:form-data="currentEditData"
|
||||
:title="editCheckTitle"
|
||||
@update:visible="(value) => (editCheckVisible = value)"
|
||||
@submit="handleEditCheckSubmit"
|
||||
@close="handleEditCheckClose"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
@@ -195,6 +205,7 @@ import { ref, reactive, computed, watch, getCurrentInstance, ComponentInternalIn
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Check, Calendar } from '@element-plus/icons-vue';
|
||||
import DormHygieneCheckSingleDialog from './DormHygieneCheckSingleDialog.vue';
|
||||
import DormHygieneCheckEditDialog from './DormHygieneCheckEditDialog.vue';
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 组件实例
|
||||
@@ -256,11 +267,16 @@ const checkerOptions = ref<any[]>([]);
|
||||
const floorRooms = ref<any[]>([]);
|
||||
const completedRooms = ref<Set<string | number>>(new Set());
|
||||
const allRooms = ref<any[]>([]);
|
||||
const roomCheckIds = ref<Map<string | number, string | number>>(new Map()); // 存储房间对应的检查记录ID
|
||||
|
||||
// 单个房间检查弹窗相关
|
||||
const singleCheckVisible = ref(false);
|
||||
const currentRoom = ref<any>(null);
|
||||
|
||||
// 编辑弹窗相关
|
||||
const editCheckVisible = ref(false);
|
||||
const currentEditData = ref<any>(null);
|
||||
|
||||
// 字典数据
|
||||
const xg_dorm_hygiene_check_level = ref<any[]>([]);
|
||||
const xg_dorm_hygiene_check_type = ref<any[]>([]);
|
||||
@@ -288,6 +304,10 @@ const singleCheckTitle = computed(() => {
|
||||
return currentRoom.value ? `${currentRoom.value.roomName} - 卫生检查` : '房间卫生检查';
|
||||
});
|
||||
|
||||
const editCheckTitle = computed(() => {
|
||||
return currentRoom.value ? `${currentRoom.value.roomName} - 编辑检查记录` : '编辑检查记录';
|
||||
});
|
||||
|
||||
// 生成默认检查标题
|
||||
const generateDefaultCheckTitle = () => {
|
||||
const now = new Date();
|
||||
@@ -315,6 +335,7 @@ const initForm = () => {
|
||||
completedRooms.value.clear();
|
||||
floorRooms.value = [];
|
||||
allRooms.value = [];
|
||||
roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
||||
|
||||
// 获取当前用户信息
|
||||
fetchCurrentUserInfo();
|
||||
@@ -364,6 +385,7 @@ const handleCampusChange = async (campusId: string | number) => {
|
||||
floorRooms.value = [];
|
||||
allRooms.value = [];
|
||||
completedRooms.value.clear();
|
||||
roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
||||
|
||||
if (campusId) {
|
||||
const selectedCampus = campusOptions.value.find((campus) => campus.id === campusId);
|
||||
@@ -401,6 +423,7 @@ const handleBuildingChange = async (buildingId: string | number) => {
|
||||
floorRooms.value = [];
|
||||
allRooms.value = [];
|
||||
completedRooms.value.clear();
|
||||
roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
||||
|
||||
if (buildingId) {
|
||||
const selectedBuilding = buildingOptions.value.find((building) => building.id === buildingId);
|
||||
@@ -500,29 +523,38 @@ const handleCheckerChange = (checkerName: string) => {
|
||||
};
|
||||
|
||||
// 房间双击处理
|
||||
const handleRoomDoubleClick = (room: any) => {
|
||||
const handleRoomDoubleClick = async (room: any) => {
|
||||
// 验证基础信息是否完整
|
||||
if (!form.checkTitle || !form.checkDate || !form.checkerName || !form.checkType || !form.checkLevel) {
|
||||
ElMessage.warning('请先完善检查基础信息');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果房间已经检查过,询问是否重新检查
|
||||
if (completedRooms.value.has(room.id)) {
|
||||
ElMessageBox.confirm(`${room.roomName} 已经检查过,是否重新检查?`, '提示', {
|
||||
confirmButtonText: '重新检查',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
openSingleCheckDialog(room);
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消
|
||||
// 检查是否已有记录ID(新增成功后会保存ID)
|
||||
const checkId = roomCheckIds.value.get(room.id);
|
||||
|
||||
if (checkId) {
|
||||
// 有记录ID,说明已经检查过,打开编辑弹窗
|
||||
try {
|
||||
const response = await request({
|
||||
url: `/dormHygieneCheck/dormHygieneCheck/${checkId}`,
|
||||
method: 'get'
|
||||
});
|
||||
} else {
|
||||
openSingleCheckDialog(room);
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
currentRoom.value = room;
|
||||
currentEditData.value = response.data;
|
||||
editCheckVisible.value = true;
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询检查记录详情失败:', error);
|
||||
ElMessage.error('查询检查记录失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 没有记录ID,打开新增检查弹窗
|
||||
openSingleCheckDialog(room);
|
||||
};
|
||||
|
||||
// 打开单个房间检查弹窗
|
||||
@@ -536,6 +568,11 @@ const handleSingleCheckSubmit = (data: any) => {
|
||||
// 标记房间为已完成
|
||||
completedRooms.value.add(currentRoom.value.id);
|
||||
|
||||
// 保存检查记录ID(如果有返回)
|
||||
if (data.id) {
|
||||
roomCheckIds.value.set(currentRoom.value.id, data.id);
|
||||
}
|
||||
|
||||
ElMessage.success(`${currentRoom.value.roomName} 检查完成`);
|
||||
singleCheckVisible.value = false;
|
||||
};
|
||||
@@ -545,6 +582,38 @@ const handleSingleCheckClose = () => {
|
||||
singleCheckVisible.value = false;
|
||||
};
|
||||
|
||||
// 编辑弹窗提交处理
|
||||
const handleEditCheckSubmit = async (data: any) => {
|
||||
try {
|
||||
// 调用后端API更新检查记录
|
||||
const response = await request({
|
||||
url: '/dormHygieneCheck/dormHygieneCheck/updateCompleteData',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
|
||||
if (response.code === 200) {
|
||||
// 标记房间为已完成
|
||||
completedRooms.value.add(currentRoom.value.id);
|
||||
roomCheckIds.value.set(currentRoom.value.id, data.id);
|
||||
|
||||
ElMessage.success(`${currentRoom.value.roomName} 检查记录更新完成`);
|
||||
editCheckVisible.value = false;
|
||||
} else {
|
||||
ElMessage.error(response.msg || '更新失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新检查记录失败:', error);
|
||||
ElMessage.error('更新失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
// 编辑弹窗关闭处理
|
||||
const handleEditCheckClose = () => {
|
||||
editCheckVisible.value = false;
|
||||
currentEditData.value = null;
|
||||
};
|
||||
|
||||
// 获取楼层已完成数量
|
||||
const getFloorCompletedCount = (floor: string) => {
|
||||
const floorData = floorRooms.value.find((f) => f.floor === floor);
|
||||
|
||||
+16
-11
@@ -263,6 +263,7 @@
|
||||
|
||||
<script setup name="DormHygieneCheckSingleDialog" lang="ts">
|
||||
import { ref, reactive, computed, watch, toRefs, getCurrentInstance, type ComponentInternalInstance } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Plus, InfoFilled, UploadFilled, Document, Loading, Download, Delete } from '@element-plus/icons-vue';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import ImagePreview from '@/components/ImagePreview/index.vue';
|
||||
@@ -837,23 +838,27 @@ const submitForm = async () => {
|
||||
});
|
||||
|
||||
if (response.code === 200) {
|
||||
console.log('保存成功');
|
||||
if (window.ElMessage) {
|
||||
window.ElMessage.success('保存检查结果成功');
|
||||
}
|
||||
emit('submit', submitData);
|
||||
console.log('保存成功,返回数据:', response.data);
|
||||
|
||||
// 准备返回给父组件的数据,包含检查记录ID
|
||||
const resultData = {
|
||||
...submitData,
|
||||
id: response.data?.id || response.data, // 适配不同的返回格式
|
||||
checkId: response.data?.id || response.data
|
||||
};
|
||||
|
||||
ElMessage.success('保存检查结果成功');
|
||||
|
||||
// 将包含ID的数据传递给父组件
|
||||
emit('submit', resultData);
|
||||
handleClose();
|
||||
} else {
|
||||
console.error('保存失败:', response.msg);
|
||||
if (window.ElMessage) {
|
||||
window.ElMessage.error(response.msg || '保存失败');
|
||||
}
|
||||
ElMessage.error(response.msg || '保存失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
if (window.ElMessage) {
|
||||
window.ElMessage.error('保存失败,请重试');
|
||||
}
|
||||
ElMessage.error('保存失败,请重试');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交表单失败:', error);
|
||||
|
||||
Reference in new issue
Block a user