tjx
2025-11-05 fcf1b378012eec8a4a3debe5d9e3120f36c7a507
components/EquipmentInspection.vue
@@ -160,14 +160,34 @@
               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) {
                  // 使用 $set 确保 Vue 能够检测到嵌套数组的变化
                  this.$set(this, 'dailyChecks', record.dailyChecks.map(arr => [...arr]))
               } else {
                  console.warn('日常点检数据格式不正确,使用默认值')
                  this.$set(this, 'dailyChecks', this.dailyItems.map(() => Array(31).fill(false)))
               }
            } else {
               this.initChecks()
               this.$set(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) {
                  // 使用 $set 确保 Vue 能够检测到嵌套数组的变化
                  this.$set(this, 'monthlyChecks', record.monthlyChecks.map(arr => [...arr]))
               } else {
                  console.warn('月度点检数据格式不正确,使用默认值')
                  this.$set(this, 'monthlyChecks', this.monthlyItems.map(() => Array(31).fill(false)))
               }
            } else {
               this.$set(this, 'monthlyChecks', this.monthlyItems.map(() => Array(31).fill(false)))
            }
            this.dirty = false
@@ -186,8 +206,20 @@
         }
         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