loulijun2021
2024-03-05 31127ef63da3af7511a3b06eb2eaa87238f245da
src/views/kanbanManager/cj.vue
@@ -6,11 +6,11 @@
      <div class="kb_header">
        <div class="kb_headTime" style="top: 35px;left:  20px">
          <span>永康市巨立防护用品有限公司</span>
          <span>浙江米航科技有限公司</span>
        </div>
        <div class="kb_headTime kb_header_text" style="top: 35px;left:  765px">
          <span>{{ title }}数字化看板</span>
        <div class="kb_headTime kb_header_text" style="top: 35px;left:  800px">
          <span>装配车间数字化看板</span>
        </div>
        <div class="kb_headTime" style="top: 35px;right:  25px">
@@ -186,11 +186,42 @@
    }, 1000 * 60 * 120)
  },
  mounted() {
    // 监听网络是否在线
    window.addEventListener('online', this.updateOnlineStatus)
    window.addEventListener('offline', this.updateOnlineStatus)
    this.updateOnlineStatus({ type: this.onLine ? 'online' : 'offline', isFirst: true })
    this.getAllApi()
  },
  beforeDestroy() {
    window.removeEventListener('online', this.updateOnlineStatus)
    window.removeEventListener('offline', this.updateOnlineStatus)
  },
  methods: {
    // 更新网络状态
    updateOnlineStatus(e) {
      if (e.isFirst) {
        // console.log('x')
      } else {
        const loading = this.$loading({
          lock: true,
          text: '断网了,正在拼命联网中,请检查网络是否正常...',
          spinner: 'el-icon-loading',
          customClass: 'osloading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        const { type } = e
        this.onLine = type === 'online'
        if (this.onLine) {
          loading.close()
          this.$message.success('网络连接成功!')
        } else {
          this.$message.error('网络掉线,请关注网络状态!')
        }
      }
    },
    async getWorkShopProduceTopData() {
      WorkShopProduceTopData({ wkshopcode: this.wkshopcode.join(',') }).then(res => {
      WorkShopProduceTopData().then(res => {
        this.tableDataCenterTop = res.data
        const divData = this.$refs.tableDataLeftCenterRef.bodyWrapper
@@ -199,7 +230,7 @@
          divData.scrollTop += 1
          if (divData.clientHeight + divData.scrollTop === divData.scrollHeight) {
            divData.scrollTop = 0
            WorkShopProduceTopData({ wkshopcode: this.wkshopcode.join(',') }).then(res => {
            WorkShopProduceTopData().then(res => {
              this.tableDataCenterTop = res.data
              if (this.tableDataCenterTop.length > 11) {
@@ -208,57 +239,46 @@
              }
            })
          }
        }, this.tableDataCenterTop.length <= 11 ? 1000 * 15 : 200)
        }, this.tableDataCenterTop.length <= 11 ? 1000 * 30 : 200)
      })
    },
    async getAllApi() {
      const res = await PrentOrganizationNoCompany()
      this.wkshopArr = res.data
      // const res = await PrentOrganizationNoCompany()
      // this.wkshopArr = res.data
      if (window.location.hash.indexOf('?') !== -1) {
        const code = window.location.hash.split('?')[1].split('=')[1]
        this.title = this.wkshopArr.find(i => i.torg_code === code).torg_name
        this.wkshopcode = [code]
      }
      // if (window.location.hash.indexOf('?') !== -1) {
      //   const code = window.location.hash.split('?')[1].split('=')[1]
      //   this.title = this.wkshopArr.find(i => i.torg_code === code).torg_name
      //   this.wkshopcode = [code]
      // }
      //
      // this.wkshopcode.forEach(i => {
      //   const aa = this.wkshopArr.find(j => j.torg_code === i).torg_name
      //   this.legendData.push(aa)
      // })
      this.wkshopcode.forEach(i => {
        const aa = this.wkshopArr.find(j => j.torg_code === i).torg_name
        this.legendData.push(aa)
      })
      const res4 = await WorkShopProduceBottomLeftData()
      this.cjzl03_xData = res4.data.map(i => i.click_date)
      this.cjzl03_yData = res4.data.map(i => i.count)
      const res4 = await WorkShopProduceBottomLeftData({ wkshopcode: this.wkshopcode.join(',') })
      this.cjzl03_xData = res4.data[this.wkshopcode[0]].map(i => i.click_date)
      for (const res4Key in res4.data) {
        if (this.wkshopcode.includes(res4Key)) {
          const bb = res4.data[res4Key].map(i => i.count)
          this.cjzl03_yData.push(bb)
        }
      }
      loadEcharts('cjzl03', cjzl03_2(this.cjzl03_xData, this.legendData, this.cjzl03_yData, true))
      setInterval(() => {
        WorkShopProduceBottomLeftData({ wkshopcode: this.wkshopcode.join(',') }).then(res4 => {
          this.cjzl03_yData = []
          this.cjzl03_xData = res4.data[this.wkshopcode[0]].map(i => i.click_date)
          for (const res4Key in res4.data) {
            if (this.wkshopcode.includes(res4Key)) {
              const bb = res4.data[res4Key].map(i => i.count)
              this.cjzl03_yData.push(bb)
            }
          }
        WorkShopProduceBottomLeftData().then(res4 => {
          this.cjzl03_xData = res4.data.map(i => i.click_date)
          this.cjzl03_yData = res4.data.map(i => i.count)
          loadEcharts('cjzl03', cjzl03_2(this.cjzl03_xData, this.legendData, this.cjzl03_yData, true))
        })
      }, 1000 * 50)
      const res5 = await WorkShopProduceBottomRightData({ wkshopcode: 'CJ001' })
      const res5 = await WorkShopProduceBottomRightData()
      this.RightBottom = res5.data
      if (this.RightBottom.length > 0) {
        loadEcharts('cjzl04', cjzl04(this.RightBottom.map(i => i.name), this.RightBottom.map(i => i.cont)))
      }
      setInterval(() => {
        WorkShopProduceBottomRightData({ wkshopcode: 'CJ001' }).then(res5 => {
        WorkShopProduceBottomRightData().then(res5 => {
          this.RightBottom = res5.data
          if (this.RightBottom.length > 0) {
            loadEcharts('cjzl04', cjzl04(this.RightBottom.map(i => i.name), this.RightBottom.map(i => i.cont)))
@@ -266,7 +286,7 @@
        })
      }, 1000 * 60)
      this.getWorkShopProduceTopData()
      await this.getWorkShopProduceTopData()
    },
    // 获取当前时间