快乐的昕的电脑
2025-11-14 35c857b1471760fd1723d1fe04458ba97c49cb0f
components/EquipmentInspection.vue
@@ -12,8 +12,8 @@
            </view>
            <view class="info-item">
               <text class="info-label">日期:</text>
               <picker mode="date" :value="currentDate" @change="handleDateChange">
                  <view class="date-picker">{{ currentDate }}</view>
               <picker mode="date" fields="month" :value="currentDate" @change="handleDateChange">
                  <view class="date-picker">{{ displayDate }}</view>
               </picker>
            </view>
         </view>
@@ -117,6 +117,14 @@
         dirty: false
      }
   },
   computed: {
      displayDate() {
         // 格式化显示为 "2025年11月"
         if (!this.currentDate) return ''
         const [year, month] = this.currentDate.split('-')
         return `${year}年${month}月`
      }
   },
   created() {
      this.initChecks()
   },
@@ -152,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
@@ -178,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
@@ -255,9 +295,9 @@
.info-row {
   display: flex;
   justify-content: space-between;
   justify-content: flex-start;
   align-items: center;
   gap: 20px;
   gap: 60px;
}
.info-item {