src/views/mdc/base/WorkshopSignage.vue
@@ -5,7 +5,7 @@
      <div class="left-col">
        <div class="col-content">
          <div class="content-title">{{workshopDetails.workshopName}}#设备情况</div>
          <workshop-device-overview :currentProductionId="currentProductionId"
          <workshop-device-overview ref="workshopDeviceOverviewRef" :currentProductionId="currentProductionId"
                                    :equipmentStatusList="equipmentStatusList" :toDecimal2NoZero="toDecimal2NoZero"/>
        </div>
        <div class="col-content">
@@ -15,22 +15,25 @@
        </div>
        <div class="col-content">
          <div class="content-title">设备周利用率趋势</div>
          <week-utilization-rate-trend :currentProductionId="currentProductionId" :toDecimal2NoZero="toDecimal2NoZero"/>
          <week-utilization-rate-trend ref="weekRateTrendRef" :currentProductionId="currentProductionId"
                                       :toDecimal2NoZero="toDecimal2NoZero"/>
        </div>
        <div class="col-content">
          <div class="content-title">设备日利用率趋势</div>
          <day-utilization-rate-trend :currentProductionId="currentProductionId" :toDecimal2NoZero="toDecimal2NoZero"/>
          <day-utilization-rate-trend ref="dayRateTrendRef" :currentProductionId="currentProductionId"
                                      :toDecimal2NoZero="toDecimal2NoZero"/>
        </div>
        <div class="col-content">
          <div class="content-title">设备报警信息</div>
          <device-alarm-info/>
          <device-alarm-info ref="deviceAlarmInfoRef" :currentProductionId="currentProductionId"/>
        </div>
      </div>
      <!--右侧拖拽区域-->
      <div class="right-col">
        <device-drag-layout :currentProductionId="currentProductionId" :equipmentStatusList="equipmentStatusList"
                            :getImgView="getImgView"/>
        <device-drag-layout ref="deviceDragLayoutRef" :currentProductionId="currentProductionId"
                            :equipmentStatusList="equipmentStatusList"
                            :getImgView="getImgView" @handleTimeIntervalForShortOpen="handleTimeIntervalForShortOpen"/>
      </div>
    </div>
  </div>
@@ -54,7 +57,7 @@
      MonthUtilizationRateTrend,
      DayUtilizationRateTrend,
      WeekUtilizationRateTrend,
      WorkshopDeviceOverview,
      WorkshopDeviceOverview
    },
    data() {
      return {
@@ -82,20 +85,37 @@
            statusImage: require('@/assets/WorskhopSignage/stateImg_gray.gif')
          }
        ],
        deviceList: [],
        isShowGuideline: false,
        guidelineXTop: 0,
        guidelineYLeft: 0,
        isSwitchChecked: false,
        isHasResizeOrDragDevice: false
        timeIntervalForShortTime: null,
        timeIntervalForLongTime: null
      }
    },
    created() {
      if (!this.$route.params.productionId) return
      // 在此处获取路由参数是为了传递参数给子组件,若放在mounted中则无法传递给子组件
      this.currentProductionId = this.$route.params.productionId
    },
    mounted() {
      if (!this.$route.params.productionId) return
      // 在mounted中该调用此方法是为了获取dom元素
      this.getWorkshopDetailsByApi()
      this.timeIntervalForShortTime = setInterval(() => {
        this.$refs.workshopDeviceOverviewRef.getDeviceStatusCountByApi()
        this.$refs.deviceAlarmInfoRef.getDeviceAlarmInfoByApi()
        this.$refs.deviceDragLayoutRef.getDeviceListByApi()
      }, 1000 * 60)
      this.timeIntervalForLongTime = setInterval(() => {
        this.$refs.weekRateTrendRef.getChartDataByApi()
        this.$refs.dayRateTrendRef.getChartDataByApi()
      }, 1000 * 60 * 60)
    },
    beforeDestroy() {
      if (this.timeIntervalForShortTime || this.timeIntervalForLongTime) {
        clearInterval(this.timeIntervalForShortTime)
        clearInterval(this.timeIntervalForLongTime)
        this.timeIntervalForShortTime = this.timeIntervalForLongTime = null
      }
    },
    methods: {
      // 通过车间Id调用接口获取车间详细信息
@@ -109,6 +129,24 @@
        })
      },
      /**
       * 控制短期定时任务开启与关闭
       * @param checked 右下角功能switch开关状态
       */
      handleTimeIntervalForShortOpen(checked) {
        if (checked) {
          clearInterval(this.timeIntervalForShortTime)
          this.timeIntervalForShortTime = null
          console.log('暂停计时器', this.timeIntervalForShortTime)
        } else {
          this.timeIntervalForShortTime = setInterval(() => {
            this.$refs.workshopDeviceOverviewRef.getDeviceStatusCountByApi()
            this.$refs.deviceAlarmInfoRef.getDeviceAlarmInfoByApi()
            this.$refs.deviceDragLayoutRef.getDeviceListByApi()
          }, 1000 * 60)
        }
      },
      // 保留两位小数
      toDecimal2NoZero(x) {
        const f = Math.round(x * 100) / 100