diff --git a/src/views/crm/project/inspection/record/ProjectInspectionRecordUploadForm.vue b/src/views/crm/project/inspection/record/ProjectInspectionRecordUploadForm.vue index 07f061ee4..b53cf5547 100644 --- a/src/views/crm/project/inspection/record/ProjectInspectionRecordUploadForm.vue +++ b/src/views/crm/project/inspection/record/ProjectInspectionRecordUploadForm.vue @@ -263,6 +263,21 @@ const open = async (record: ProjectInspectionRecordApi.ProjectInspectionRecordVO formLoading.value = true try { + // 检查巡检日期:只有巡检日期的年月日 <= 当前年月日才能填报 + if (record.inspectionDate) { + const inspectionDate = new Date(record.inspectionDate) + inspectionDate.setHours(0, 0, 0, 0) + const currentDate = new Date() + currentDate.setHours(0, 0, 0, 0) + + // 如果巡检日期是未来日期,不能填报 + if (inspectionDate > currentDate) { + message.warning('只有巡检日期的年月日小于等于当前年月日才能填报') + dialogVisible.value = false + return + } + } + // 检查记录中是否有 configType if (!record.configType || !Array.isArray(record.configType) || record.configType.length === 0) { message.warning('该巡检记录没有配置巡检类型') diff --git a/src/views/crm/project/inspection/record/index.vue b/src/views/crm/project/inspection/record/index.vue index a218b7e9b..4f5f466fd 100644 --- a/src/views/crm/project/inspection/record/index.vue +++ b/src/views/crm/project/inspection/record/index.vue @@ -664,7 +664,20 @@ const canShowUploadButton = (row: ProjectInspectionRecordApi.ProjectInspectionRe return false } - // 2. 只有巡检人或者管理员才能看到 + // 2. 检查巡检日期:只有巡检日期的年月日 <= 当前年月日才能填报 + if (row.inspectionDate) { + const inspectionDate = new Date(row.inspectionDate) + inspectionDate.setHours(0, 0, 0, 0) + const currentDate = new Date() + currentDate.setHours(0, 0, 0, 0) + + // 如果巡检日期是未来日期,不能填报 + if (inspectionDate > currentDate) { + return false + } + } + + // 3. 只有巡检人或者管理员才能看到 const inspectorIdNum = typeof row.inspector === 'string' ? Number(row.inspector) : row.inspector const currentUserId = userStore.user.id