| | |
| | | date: this.currentDate |
| | | }, { mock: true, showLoading: true }) |
| | | |
| | | if (record && record.dailyChecks) { |
| | | this.dailyChecks = record.dailyChecks |
| | | // 验证并设置日常点检数据 |
| | | if (record && Array.isArray(record.dailyChecks) && record.dailyChecks.length === 6) { |
| | | // 确保每个子数组都是有效的数组 |
| | | const isValid = record.dailyChecks.every(arr => Array.isArray(arr) && arr.length === 31) |
| | | if (isValid) { |
| | | this.dailyChecks = record.dailyChecks |
| | | } else { |
| | | console.warn('日常点检数据格式不正确,使用默认值') |
| | | this.dailyChecks = this.dailyItems.map(() => Array(31).fill(false)) |
| | | } |
| | | } else { |
| | | this.initChecks() |
| | | this.dailyChecks = this.dailyItems.map(() => Array(31).fill(false)) |
| | | } |
| | | |
| | | if (record && record.monthlyChecks) { |
| | | this.monthlyChecks = record.monthlyChecks |
| | | // 验证并设置月度点检数据 |
| | | if (record && Array.isArray(record.monthlyChecks) && record.monthlyChecks.length === 2) { |
| | | // 确保每个子数组都是有效的数组 |
| | | const isValid = record.monthlyChecks.every(arr => Array.isArray(arr) && arr.length === 31) |
| | | if (isValid) { |
| | | this.monthlyChecks = record.monthlyChecks |
| | | } else { |
| | | console.warn('月度点检数据格式不正确,使用默认值') |
| | | this.monthlyChecks = this.monthlyItems.map(() => Array(31).fill(false)) |
| | | } |
| | | } else { |
| | | this.monthlyChecks = this.monthlyItems.map(() => Array(31).fill(false)) |
| | | } |
| | | |
| | | this.dirty = false |
| | |
| | | } |
| | | |
| | | if (type === 'daily') { |
| | | // 安全检查:确保数组和索引有效 |
| | | if (!Array.isArray(this.dailyChecks) || !Array.isArray(this.dailyChecks[itemIdx])) { |
| | | console.error('日常点检数据结构异常,重新初始化') |
| | | this.initChecks() |
| | | return |
| | | } |
| | | this.$set(this.dailyChecks[itemIdx], dayIdx, !this.dailyChecks[itemIdx][dayIdx]) |
| | | } else { |
| | | // 安全检查:确保数组和索引有效 |
| | | if (!Array.isArray(this.monthlyChecks) || !Array.isArray(this.monthlyChecks[itemIdx])) { |
| | | console.error('月度点检数据结构异常,重新初始化') |
| | | this.initChecks() |
| | | return |
| | | } |
| | | this.$set(this.monthlyChecks[itemIdx], dayIdx, !this.monthlyChecks[itemIdx][dayIdx]) |
| | | } |
| | | this.dirty = true |