|
@@ -187,6 +187,16 @@
|
|
|
@submit="handleSingleCheckSubmit"
|
|
@submit="handleSingleCheckSubmit"
|
|
|
@close="handleSingleCheckClose"
|
|
@close="handleSingleCheckClose"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 编辑房间检查弹窗 -->
|
|
|
|
|
+ <DormHygieneCheckEditDialog
|
|
|
|
|
+ :visible="editCheckVisible"
|
|
|
|
|
+ :form-data="currentEditData"
|
|
|
|
|
+ :title="editCheckTitle"
|
|
|
|
|
+ @update:visible="(value) => (editCheckVisible = value)"
|
|
|
|
|
+ @submit="handleEditCheckSubmit"
|
|
|
|
|
+ @close="handleEditCheckClose"
|
|
|
|
|
+ />
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -195,6 +205,7 @@ import { ref, reactive, computed, watch, getCurrentInstance, ComponentInternalIn
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
import { Check, Calendar } from '@element-plus/icons-vue';
|
|
import { Check, Calendar } from '@element-plus/icons-vue';
|
|
|
import DormHygieneCheckSingleDialog from './DormHygieneCheckSingleDialog.vue';
|
|
import DormHygieneCheckSingleDialog from './DormHygieneCheckSingleDialog.vue';
|
|
|
|
|
+import DormHygieneCheckEditDialog from './DormHygieneCheckEditDialog.vue';
|
|
|
import request from '@/utils/request';
|
|
import request from '@/utils/request';
|
|
|
|
|
|
|
|
// 组件实例
|
|
// 组件实例
|
|
@@ -256,11 +267,16 @@ const checkerOptions = ref<any[]>([]);
|
|
|
const floorRooms = ref<any[]>([]);
|
|
const floorRooms = ref<any[]>([]);
|
|
|
const completedRooms = ref<Set<string | number>>(new Set());
|
|
const completedRooms = ref<Set<string | number>>(new Set());
|
|
|
const allRooms = ref<any[]>([]);
|
|
const allRooms = ref<any[]>([]);
|
|
|
|
|
+const roomCheckIds = ref<Map<string | number, string | number>>(new Map()); // 存储房间对应的检查记录ID
|
|
|
|
|
|
|
|
// 单个房间检查弹窗相关
|
|
// 单个房间检查弹窗相关
|
|
|
const singleCheckVisible = ref(false);
|
|
const singleCheckVisible = ref(false);
|
|
|
const currentRoom = ref<any>(null);
|
|
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_level = ref<any[]>([]);
|
|
|
const xg_dorm_hygiene_check_type = ref<any[]>([]);
|
|
const xg_dorm_hygiene_check_type = ref<any[]>([]);
|
|
@@ -288,6 +304,10 @@ const singleCheckTitle = computed(() => {
|
|
|
return currentRoom.value ? `${currentRoom.value.roomName} - 卫生检查` : '房间卫生检查';
|
|
return currentRoom.value ? `${currentRoom.value.roomName} - 卫生检查` : '房间卫生检查';
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+const editCheckTitle = computed(() => {
|
|
|
|
|
+ return currentRoom.value ? `${currentRoom.value.roomName} - 编辑检查记录` : '编辑检查记录';
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
// 生成默认检查标题
|
|
// 生成默认检查标题
|
|
|
const generateDefaultCheckTitle = () => {
|
|
const generateDefaultCheckTitle = () => {
|
|
|
const now = new Date();
|
|
const now = new Date();
|
|
@@ -315,6 +335,7 @@ const initForm = () => {
|
|
|
completedRooms.value.clear();
|
|
completedRooms.value.clear();
|
|
|
floorRooms.value = [];
|
|
floorRooms.value = [];
|
|
|
allRooms.value = [];
|
|
allRooms.value = [];
|
|
|
|
|
+ roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
|
|
|
|
|
|
|
// 获取当前用户信息
|
|
// 获取当前用户信息
|
|
|
fetchCurrentUserInfo();
|
|
fetchCurrentUserInfo();
|
|
@@ -364,6 +385,7 @@ const handleCampusChange = async (campusId: string | number) => {
|
|
|
floorRooms.value = [];
|
|
floorRooms.value = [];
|
|
|
allRooms.value = [];
|
|
allRooms.value = [];
|
|
|
completedRooms.value.clear();
|
|
completedRooms.value.clear();
|
|
|
|
|
+ roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
|
|
|
|
|
|
|
if (campusId) {
|
|
if (campusId) {
|
|
|
const selectedCampus = campusOptions.value.find((campus) => campus.id === campusId);
|
|
const selectedCampus = campusOptions.value.find((campus) => campus.id === campusId);
|
|
@@ -401,6 +423,7 @@ const handleBuildingChange = async (buildingId: string | number) => {
|
|
|
floorRooms.value = [];
|
|
floorRooms.value = [];
|
|
|
allRooms.value = [];
|
|
allRooms.value = [];
|
|
|
completedRooms.value.clear();
|
|
completedRooms.value.clear();
|
|
|
|
|
+ roomCheckIds.value.clear(); // 清空房间检查记录ID映射
|
|
|
|
|
|
|
|
if (buildingId) {
|
|
if (buildingId) {
|
|
|
const selectedBuilding = buildingOptions.value.find((building) => building.id === 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) {
|
|
if (!form.checkTitle || !form.checkDate || !form.checkerName || !form.checkType || !form.checkLevel) {
|
|
|
ElMessage.warning('请先完善检查基础信息');
|
|
ElMessage.warning('请先完善检查基础信息');
|
|
|
return;
|
|
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);
|
|
completedRooms.value.add(currentRoom.value.id);
|
|
|
|
|
|
|
|
|
|
+ // 保存检查记录ID(如果有返回)
|
|
|
|
|
+ if (data.id) {
|
|
|
|
|
+ roomCheckIds.value.set(currentRoom.value.id, data.id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ElMessage.success(`${currentRoom.value.roomName} 检查完成`);
|
|
ElMessage.success(`${currentRoom.value.roomName} 检查完成`);
|
|
|
singleCheckVisible.value = false;
|
|
singleCheckVisible.value = false;
|
|
|
};
|
|
};
|
|
@@ -545,6 +582,38 @@ const handleSingleCheckClose = () => {
|
|
|
singleCheckVisible.value = false;
|
|
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 getFloorCompletedCount = (floor: string) => {
|
|
|
const floorData = floorRooms.value.find((f) => f.floor === floor);
|
|
const floorData = floorRooms.value.find((f) => f.floor === floor);
|