| | |
| | | }, |
| | | }, |
| | | { |
| | | prop: "inspectionDeadlinetxt", |
| | | label: "期限", |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | prop: "inspectionStatus", |
| | | label: "巡检状态", |
| | | minWidth: 150, |
| | | dataType: "tag", |
| | | formatType: params => { |
| | | const typeMap = { |
| | | 已完成: "info", |
| | | 未巡检: "warning", |
| | | 超期: "danger", |
| | | }; |
| | | return typeMap[params] || "info"; |
| | | }, |
| | | }, |
| | | { |
| | | prop: "frequencyDetail", |
| | | label: "开始日期与时间", |
| | | minWidth: 150, |
| | | formatter: (row, column, cellValue) => { |
| | | // 先判断是否是字符串 |
| | | if (typeof cellValue !== "string") return ""; |
| | | let val = cellValue; |
| | | const replacements = { |
| | | MON: "周一", |
| | | TUE: "周二", |
| | | WED: "周三", |
| | | THU: "周四", |
| | | FRI: "周五", |
| | | SAT: "周六", |
| | | SUN: "周日", |
| | | }; |
| | | // 使用正则一次性替换所有匹配项 |
| | | return val.replace( |
| | | /MON|TUE|WED|THU|FRI|SAT|SUN/g, |
| | | match => replacements[match] |
| | | ); |
| | | }, |
| | | }, |
| | | { prop: "registrant", label: "登记人", minWidth: 100 }, |
| | | { prop: "createTime", label: "登记日期", minWidth: 100 }, |
| | | ]); |
| | | const columns1 = ref([ |
| | | { prop: "taskName", label: "巡检任务名称", minWidth: 160 }, |
| | | { prop: "remarks", label: "备注", minWidth: 150 }, |
| | | { prop: "inspector", label: "执行巡检人", minWidth: 150, slot: "inspector" }, |
| | | { |
| | | prop: "frequencyType", |
| | | label: "频次", |
| | | minWidth: 150, |
| | | // formatter: (_, __, val) => ({ |
| | | // DAILY: "每日", |
| | | // WEEKLY: "每周", |
| | | // MONTHLY: "每月", |
| | | // QUARTERLY: "季度" |
| | | // }[val] || "") |
| | | formatData: params => { |
| | | return params === "DAILY" |
| | | ? "每日" |
| | | : params === "WEEKLY" |
| | | ? "每周" |
| | | : params === "MONTHLY" |
| | | ? "每月" |
| | | : params === "QUARTERLY" |
| | | ? "季度" |
| | | : ""; |
| | | }, |
| | | }, |
| | | { |
| | | prop: "frequencyDetail", |
| | | label: "开始日期与时间", |
| | | minWidth: 150, |
| | |
| | | if (value === "taskManage") { |
| | | const operationColumn = getOperationColumn(["edit"]); |
| | | tableColumns.value = [ |
| | | ...columns.value, |
| | | ...columns1.value, |
| | | ...(operationColumn ? [operationColumn] : []), |
| | | ]; |
| | | operationsArr.value = ["edit"]; |
| | |
| | | |
| | | return processedItem; |
| | | }); |
| | | tableData.value.forEach(item => { |
| | | item.inspectionStatus = getFileStatus(item); |
| | | item.inspectionDeadlinetxt = |
| | | item.frequencyType === "DAILY" |
| | | ? item.inspectionDeadline + "小时" |
| | | : item.inspectionDeadline + "天"; |
| | | }); |
| | | total.value = res.data.total || 0; |
| | | }) |
| | | .finally(() => { |
| | |
| | | }) |
| | | .catch(() => {}); |
| | | }; |
| | | |
| | | const getFileStatus = record => { |
| | | console.log(record); |
| | | if (record.takePhone) { |
| | | if (record.commonFileListBefore && record.commonFileListBefore.length) { |
| | | return "已完成"; |
| | | } |
| | | if (record.frequencyType == "DAILY") { |
| | | if (Number(record.inspectionDeadline) && record.createTime) { |
| | | // 计算时间差(小时) |
| | | const now = new Date().getTime(); |
| | | const createTime = new Date(record.createTime).getTime(); |
| | | const hoursDiff = (now - createTime) / (1000 * 60 * 60); |
| | | if (hoursDiff > Number(record.inspectionDeadline)) { |
| | | return "超期"; |
| | | } |
| | | } |
| | | } else { |
| | | if (Number(record.inspectionDeadline) && record.createTime) { |
| | | // 计算时间差(天) |
| | | const now = new Date().getTime(); |
| | | const createTime = new Date(record.createTime).getTime(); |
| | | const daysDiff = (now - createTime) / (1000 * 60 * 60 * 24); |
| | | if (daysDiff > Number(record.inspectionDeadline)) { |
| | | return "超期"; |
| | | } |
| | | } |
| | | } |
| | | return "未巡检"; |
| | | } else if (record.inspectionSubmitted) { |
| | | return "已完成"; |
| | | } else { |
| | | if (record.frequencyType == "DAILY") { |
| | | if (Number(record.inspectionDeadline) && record.createTime) { |
| | | // 计算时间差(小时) |
| | | const now = new Date().getTime(); |
| | | const createTime = new Date(record.createTime).getTime(); |
| | | const hoursDiff = (now - createTime) / (1000 * 60 * 60); |
| | | if (hoursDiff > Number(record.inspectionDeadline)) { |
| | | return "超期"; |
| | | } |
| | | } |
| | | } else { |
| | | if (Number(record.inspectionDeadline) && record.createTime) { |
| | | // 计算时间差(天) |
| | | const now = new Date().getTime(); |
| | | const createTime = new Date(record.createTime).getTime(); |
| | | const daysDiff = (now - createTime) / (1000 * 60 * 60 * 24); |
| | | if (daysDiff > Number(record.inspectionDeadline)) { |
| | | return "超期"; |
| | | } |
| | | } |
| | | } |
| | | return "未巡检"; |
| | | } |
| | | }; |
| | | // 多选变更 |
| | | const handleSelectionChange = selection => { |
| | | selectedRows.value = selection; |