mod 巡检日期检查逻辑,确保只能填报当前日期及之前的巡检记录
parent
834bb4f53b
commit
a44b8e3243
|
|
@ -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('该巡检记录没有配置巡检类型')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue