<template>
  <div>
    <div class="header">
      <div class="headerbox">
        <h1>反欺凌信息采集及评测系统</h1>
        <div class="goto"><span @click="gotoLogin">您好，{{ userName }} 退出</span></div>
        <div class="headerMail" v-if="meuns[4].meun == true"><i class="SetIcon" @click="gotEetClick"></i></div>
        <div class="headerMail" v-if="meuns[3].meun == true"><i class="mailIcon" @click="gotMailsClick"></i><i class="yuanRed" v-if="meuns[3].staurt == 1"></i></div>
        <div class="headerTimes">{{ newtime }}</div>
        <div class="clear"></div>
      </div>
    </div>
    <!-- 管理员登录 -->
    <div id="timer"></div>
    <div class="loginMain" :class="meuns[2].meun == false?'loginMainBox':''">
      <div class="countdownTimers" v-if="typeTimer == 1 || typeTimer == 3 || typeTimer == 4">{{ timeTitle }}<span>{{ homeDay }}</span>天<span>{{ homexs }}</span>小时<span>{{ homef }}</span>分<span>{{ homem }}</span>秒</div>
      <div v-if="meuns[2].meun == true">
        <div class="firstTip" v-if="tipSHow == 1"><i class="fisrtIcon"></i>初次进入，需要先填写基础信息采集、添加用户并分配角色。才能填写常态工作采集</div>
        <div class="firstTip" v-else-if="tipSHow == 2"><i class="fisrtIcon"></i>已进入上报流程，请等待审批结果</div>
      </div>
      <div v-else>
        <div class="firstTip" v-if="tipSHow == 1"><i class="fisrtIcon"></i>初次进入，需要先填写基础信息采集，才能填写常态工作采集</div>
        <div class="firstTip" v-else-if="tipSHow == 2"><i class="fisrtIcon"></i>已进入上报流程，请等待审批结果</div>
      </div>
      <div v-if="meuns[2].meun == false">
        <!-- <div v-if="homeDetailsShow == 1"> -->
          <div class="homeW30Sig mr40" @click="gotoClick" v-if="meuns[0].meun == true">
            <div class="chupingbutn" v-if="parseInt(wcdNum) == 0">初评</div>
            <div class="homeIconOne"></div>
            <div class="homeJinDload"><span class="rf">{{parseInt(wcdNum)}}%</span>完整度</div>
            <div class="homeTitles">基础信息采集</div>
            <div class="homeTexts">填写学校、人员、设备、规章制度与反欺凌相关信息</div>
          </div>
          <div class="homeW30Sig" @click="gotoCTClick" v-if="meuns[1].meun == true" :class="meuns[2].meun == true?'mr40':''">
            <div class="homeIconTwe"></div>
            <div class="homeJinDload"><span class="rf">{{parseInt(wcdNumCt)}}%</span>完整度</div>
            <div class="homeTitles">常态工作采集</div>
            <div class="homeTexts">与反欺凌相关的常态工作记录，包括：日常、发现、事后</div>
          </div>
        <!-- </div> -->
      </div>

      <div v-if="meuns[2].meun == true">
        <!-- <div v-if="homeDetailsShow == 2"> -->
          <div v-if="homeDetailsShow == 1">
            <div class="homeW30Sig mr40" @click="gotoClick" v-if="meuns[0].meun == true">
              <div class="chupingbutn" v-if="parseInt(wcdNum) == 0">初评</div>
              <div class="homeIconOne"></div>
              <div class="homeJinDload"><span class="rf">{{parseInt(wcdNum)}}%</span>完整度</div>
              <div class="homeTitles">基础信息采集</div>
              <div class="homeTexts">填写学校、人员、设备、规章制度与反欺凌相关信息</div>
            </div>
            <div class="homeW30Sig" @click="gotoCTClick" v-if="meuns[1].meun == true" :class="meuns[2].meun == true?'mr40':''">
              <div class="homeIconTwe"></div>
              <div class="homeJinDload"><span class="rf">{{parseInt(wcdNumCt)}}%</span>完整度</div>
              <div class="homeTitles">常态工作采集</div>
              <div class="homeTexts">与反欺凌相关的常态工作记录，包括：日常、发现、事后</div>
            </div>
          </div>
          <div class="homeW840Sig mr40" v-if="homeDetailsShow == 2">
            <div class="homeTopW400">
              <div class="padd24">
                <div class="topW400">
                  <div class="leftTop60" :class="(upDownNum>0 || upDownNum<0)?'current':''">
                    <div class="avatarHome" v-if="parseInt(fenzhi) > 84">{{ fenzhi }}</div>
                    <div class="avatarHome curOne" v-if="parseInt(fenzhi) > 74 && parseInt(fenzhi) < 85">{{ fenzhi }}</div>
                    <div class="avatarHome curTwe" v-if="parseInt(fenzhi) < 75">{{ fenzhi }}</div>
                    <div class="avatarNum" v-if="upDownNum > 0"><i class="avatarIcon"></i>+{{ upDownNum }}</div>
                    <div class="avatarNum arrcur" v-if="upDownNum < 0"><i class="avatarIcon"></i>{{ upDownNum }}</div>
                  </div>
                  <div class="leftTopTil">{{ schoolName }}</div>
                  <div class="leftTopTxt">评分时间：{{schoolTime}}</div>
                  <div class="clear"></div>
                </div>
                <div class="topW400Img"><img class="img" src="../../assets/icon33.png"></div>
                <div class="tipsErrorNmu"><i class="tipsEorIcon"></i>共检查了<span>{{scalenum}}</span>项，以下<span>{{ zgNum }}</span>项有问题：</div>
                <div class="txtTopLists">基础工作采集<span>较上次
                  <strong v-if="jcUpDownNum > 0" class="ups"><i class="jcUpIcon"></i>{{ jcUpDownNum.toFixed(2) }}</strong>
                  <strong v-if="jcUpDownNum == 0">{{ jcUpDownNum }}</strong>
                  <strong class="downs" v-if="jcUpDownNum < 0"><i class="jcUpIcon1"></i>{{ jcUpDownNum.toFixed(2) }}</strong>
                </span>本次 {{ jcfenzhi }}</div>
                <p class="txtTopLists1">
                  <span v-if="jcgzcjList.length != 0">
                    <span v-for="(item, i) in jcgzcjList" :key="i"><span v-if="item.is_zhenggai == 'yes'">{{ item.table_name }}</span></span>
                  </span>
                  <span v-else> - </span>
                </p>
                <div class="txtTopLists">常态工作采集<span>较上次
                  <strong v-if="cTUpDownNum > 0" class="ups"><i class="jcUpIcon"></i>{{ cTUpDownNum.toFixed(2) }}</strong>
                  <strong v-if="cTUpDownNum == 0">{{ cTUpDownNum }}</strong>
                  <strong class="downs" v-if="cTUpDownNum < 0"><i class="jcUpIcon1"></i>{{ cTUpDownNum.toFixed(2) }}</strong>
                </span>本次 {{ ctfenzhi }}</div>
                <p class="txtTopLists1">
                  <span v-if="ctgzcjList.length != 0">
                    <span v-for="(item, i) in ctgzcjList" :key="i"><span v-if="item.is_zhenggai == 'yes'">{{ item.table_name }}</span></span>
                  </span>
                  <span v-else> - </span>
                </p>
              </div>
            </div>
            <div class="homeBomW400 mr40" @click="gotoClick" v-if="meuns[0].meun == true">
              <div class="padd24">
                <div class="tipError" v-if="jcZg > 0">需整改</div>
                <div class="iconLeft"></div>
                <div class="hw400Title">基础信息采集</div>
                <div class="hw400Test">填写学校、人员、设备、规章制度与反欺凌相关信息</div>
              </div>
              <div class="jdtBox">
                <div class="jdtMian">
                  <div class="jdtLoad" :style="{width:parseInt(wcdNumUpBao)+'%'}"></div>
                  <div class="jdtNum" :style="{left:parseInt(wcdNumUpBao)+'%'}">完整度{{parseInt(wcdNumUpBao)}}%</div>
                </div>
              </div>
            </div>
            <div class="homeBomW400" @click="gotoCTClick" v-if="meuns[1].meun == true">
              <div class="padd24">
                <div class="tipError" v-if="ctZg > 0">需整改</div>
                <div class="iconLeft"></div>
                <div class="hw400Title">常态工作采集</div>
                <div class="hw400Test">与反欺凌相关的常态工作记录，包括：日常、发现、事后</div>
              </div>
              <div class="jdtBox">
                <div class="jdtMian">
                  <div class="jdtLoad ctCur" :style="{width:parseInt(wcdNumCtUpBao)+'%'}"></div>
                  <div class="jdtNum ctCur" :style="{left:parseInt(wcdNumCtUpBao)+'%'}">完整度{{parseInt(wcdNumCtUpBao)}}%</div>
                </div>
              </div>
            </div>
            <div class="clear"></div>
          </div>
        <!-- </div> -->
      </div>
      <div class="homeW30Sig" @click="gotoUpBClick" v-if="meuns[2].meun == true">
        <div class="homeIconThr"></div>
        <span class="upDatabutn" v-if="inSave == 1">有更新</span>
        <div class="homeTitles">上报中心</div>
        <div class="homeTexts">集中接收、查看每月工作。每个自然月月底，请务必上传本月工作</div>
      </div>
      <upreport :classStyle="styleDatas" v-if="meuns[2].meun"></upreport>
    </div>
    <!-- 非管理员登录 -->
    <!-- <div class="loginMainBox" v-else>
      <div class="countdownTimers">距离下次上报<span>{{ homeDay }}</span>天<span>{{ homexs }}</span>小时<span>{{ homef }}</span>分<span>{{ homem }}</span>秒</div>
      <div class="firstTip current"><i class="fisrtIcon"></i>初次进入，需要先填写基础信息采集，才能填写常态工作采集</div>
      <div>
        <div class="homeW30Sig mr40" @click="gotoClick" v-if="meuns[0].meun == true">
          <div class="chupingbutn">初评</div>
          <div class="tipError">需整改</div>
          <div class="homeIconOne"></div>
          <div class="homeJinDload"><span class="rf">55%</span>完整度</div>
          <div class="homeTitles">基础信息采集</div>
          <div class="homeTexts">填写学校、人员、设备、规章制度与反欺凌相关信息</div>
        </div>
        <div class="homeW30Sig" @click="gotoCTClick" v-if="meuns[1].meun == true">
          <div class="tipError">需整改</div>
          <div class="homeIconTwe"></div>
          <div class="homeJinDload"><span class="rf">55%</span>完整度</div>
          <div class="homeTitles">常态工作采集</div>
          <div class="homeTexts">与反欺凌相关的常态工作记录，包括：日常、发现、事后</div>
        </div>
      </div>
    </div> -->
  </div>
</template>
<script>
import { detelLogin, adminLoginqx, permissionList, adminScalelvl, adminschoolbaseDetails, adminreport, adminreportinfo, adminscaletypeinfo, adminreportfeedbackinfo, admiadminyindao, adminoweport } from '../../axios/api'
import { adminreportcycle } from '../../axios/apiliangbiao'
import upreport from '../../components/upreport.vue'
export default {
  name: 'homes',
  components: {
    upreport
  },
  data () {
    return {
      timeTitle: '距离下次上报',
      typeTimer: '',
      jcfenzhi: '0',
      ctfenzhi: '0',
      styleDatas: {
        top: '0px',
        right: '0'
      },
      homeDetailsShow: '',
      schoolTime: '',
      newtime: '',
      homeDay: '0',
      homexs: '0',
      homef: '0',
      homem: '0',
      noUpb: false,
      jinduJcNum: 0,
      jinduCtNum: 0,
      fenzhi: 0,
      upDownNum: 0,
      schoolName: '',
      jcUpDownNum: 0,
      cTUpDownNum: 0,
      quanxian: '3',
      wcdNum: '0',
      wcdNumCt: '0',
      wcdNumUpBao: '0',
      jcZg: '0',
      wcdNumCtUpBao: '0',
      ctZg: '0',
      meuns: [
        {
          url: 'basicinfocoll',
          route: 'basicinfocoll',
          path: 'basicinfocoll',
          title: '基础信息采集',
          name: 'basicinfocoll',
          role: [],
          meun: false
        },
        {
          url: 'normalwork',
          route: 'normalwork',
          path: 'normalwork',
          title: '常态工作记录',
          name: 'normalwork',
          role: [],
          meun: false
        },
        {
          url: 'reportcter',
          route: 'reportcter',
          path: 'reportcter',
          title: '上报中心',
          name: 'reportcter',
          role: [],
          meun: false
        },
        {
          url: 'messagecent',
          route: 'messagecent',
          path: 'messagecent',
          title: '消息中心',
          name: 'messagecent',
          role: [],
          meun: false,
          staurt: 2
        },
        {
          url: 'permissionMassage',
          route: 'permissionMassage',
          path: 'permissionMassage',
          title: '权限管理',
          name: 'permissionMassage',
          role: [],
          meun: false
        }
      ],
      tipSHow: '',
      codeSchool: '',
      reportstatus: '',
      ifinsert: '',
      zgNum: 0,
      zgNumjc: 0,
      zgNumct: 0,
      jcgzcjList: '',
      ctgzcjList: '',
      scalenum: 0,
      inSave: 2,
      schoolCode: '',
      repotCode: ''
    }
  },
  created () {
    let that = this
    if (navigator.onLine) {
    } else {
      that.$messageOne({message: '网络异常，请检测网络是否链接！', type: 'error', duration: 3000})
      return
    }
    function updateDateTime () {
      const now = new Date() // 获取当前时间
      const hours = now.getHours().toString().padStart(2, '0') // 获取小时，并确保是两位数
      const minutes = now.getMinutes().toString().padStart(2, '0') // 获取分钟，并确保是两位数
      const seconds = now.getSeconds().toString().padStart(2, '0') // 获取秒数，并确保是两位数
      // 格式化时间字符串，例如 "2023-04-01 15:30:45"
      const datetimeString = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} ${hours}:${minutes}:${seconds}`
      that.newtime = datetimeString // 更新页面上的时间显示
    }
    // 页面加载完成后立即更新时间，然后每1000毫秒（1秒）更新一次时间
    updateDateTime() // 初始更新
    setInterval(updateDateTime, 1000)
    // 反向倒计时
    function startCountdown (endTime) {
      const end = new Date(endTime)
      let timer
      function updateCountdown () {
        const now = new Date()
        const diff = end - now
        if (diff <= 0) {
          clearInterval(timer)
          return
        }
        const seconds = Math.floor(diff / 1000) % 60
        const minutes = Math.floor(diff / 1000 / 60) % 60
        const hours = Math.floor(diff / (1000 * 60 * 60)) % 24
        const days = Math.floor(diff / (1000 * 60 * 60 * 24))
        that.homeDay = `${days}`
        that.homexs = `${hours}`
        that.homef = `${minutes}`
        that.homem = `${seconds}`
      }
      clearInterval(setInterval(updateCountdown, 1000))
      timer = setInterval(updateCountdown, 1000) // 每秒更新一次倒计时
      updateCountdown() // 立即更新一次，确保页面加载时显示正确的倒计时时间（如果需要的话）
    }
    // 正向倒计时
    function updateTimer (endTime) {
      function updateCountdown () {
        const now = new Date()
        const pastDate = new Date(endTime)
        const diffMs = now - pastDate
        const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24))
        const diffHours = Math.floor((diffMs / (1000 * 60 * 60)) % 24)
        const diffMinutes = Math.floor((diffMs / (1000 * 60)) % 60)
        const diffSeconds = Math.floor((diffMs / 1000) % 60)
        that.homeDay = `${diffDays}`
        that.homexs = `${diffHours}`
        that.homef = `${diffMinutes}`
        that.homem = `${diffSeconds}`
      }
      clearInterval(setInterval(updateCountdown, 1000))
      setInterval(updateCountdown, 1000)
      updateCountdown()
    }
    adminreport().then(res => {
      if (res.code == 10000) {
        if (res.data.length == 0) {
          that.tipSHow = 1
          that.fenzhi = 0
          that.homeDetailsShow = 1
          return
        }
        if (res.data.length > 0) {
          that.codeSchool = res.data[0].code
          adminreportinfo(res.data[0].code).then(res => {
            if (res.code == 10000) {
              if (res.data == null) {
                that.fenzhi = 0
                that.homeDetailsShow = 1
                return
              } else {
                that.homeDetailsShow = 2
              }
              let datasInfo = res.data
              if (datasInfo.fenzhi != null) {
                that.fenzhi = datasInfo.fenzhi
              } else {
                that.fenzhi = 0
              }
              if (datasInfo.ji_chu_fenzhi != null) {
                that.jcfenzhi = datasInfo.ji_chu_fenzhi
              } else {
                that.jcfenzhi = 0
              }
              if (datasInfo.last_chang_tai_fenzhi == null) {
                that.jcUpDownNum = datasInfo.ji_chu_fenzhi
              } else {
                that.jcUpDownNum = parseFloat(datasInfo.ji_chu_fenzhi) - parseFloat(datasInfo.last_ji_chu_fenzhi)
              }
              if (datasInfo.ji_chu_fenzhi != null) {
                that.ctfenzhi = datasInfo.chang_tai_fenzhi
              } else {
                that.ctfenzhi = 0
              }
              if (datasInfo.last_chang_tai_fenzhi == null) {
                that.cTUpDownNum = datasInfo.chang_tai_fenzhi
              } else {
                that.cTUpDownNum = parseFloat(datasInfo.chang_tai_fenzhi) - parseFloat(datasInfo.last_chang_tai_fenzhi)
              }
              that.schoolTime = that.$gshDateTime(new Date(datasInfo.updated_at))
            } else {
              // that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
          adminreportfeedbackinfo(res.data[0].code).then(res => {
            if (res.code == 10000) {
              if (res.jc.length != 0) {
                that.jcgzcjList = res.jc
              }
              if (res.jc.length != 0) {
                that.ctgzcjList = res.ct
              }
              that.scalenum = res.scale_num
            } else {
              // that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
          let obj = {}
          obj.code = res.data[0].code
          obj.id = 1
          adminscaletypeinfo(obj).then(res => {
            if (res.code == 10000) {
              let datasWzd = res.data
              that.wcdNumUpBao = datasWzd.wzd
              that.jcZg = datasWzd.zg
              that.zgNumjc = datasWzd.zg
            } else {
              // that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
          let objs = {}
          objs.code = res.data[0].code
          objs.id = 2
          adminscaletypeinfo(objs).then(res => {
            if (res.code == 10000) {
              let datasWzd = res.data
              that.wcdNumCtUpBao = datasWzd.wzd
              that.ctZg = datasWzd.zg
              that.zgNumct = datasWzd.zg
              setTimeout(() => {
                that.zgNum = that.zgNumjc + that.zgNumct
              }, 500)
              setTimeout(() => {
                if (that.zgNum == 0) {
                  that.tipSHow = 2
                } else {
                  that.tipSHow = 3
                }
              }, 500)
            } else {
              // that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
      } else if (res.code == 10002) {
        that.$router.push({name: 'Login'})
      } else {
        // that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    adminreportcycle().then(res => {
      if (res.code == 10000) {
        let timer = res.day
        let type = res.type
        that.typeTimer = type
        if (type == 1) {
          // 反向倒计时
          startCountdown(timer)
          that.timeTitle = '距离下次上报'
        }
        if (type == 3) {
          // 反向倒计时
          startCountdown(timer)
          that.timeTitle = '距离下次上报'
        }
        if (type == 4) {
          // 正向倒计时
          updateTimer(timer)
          that.timeTitle = '已逾期上报'
        }
      } else if (res.code == 10002) {
        that.$router.push({name: 'Login'})
      } else {
        // that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    adminLoginqx().then(res => {
      if (res.code == '10000') {
        that.userName = res.username
        if (res.role != null) {
          that.quanxian = res.role.id
        } else {
          that.quanxian = 0
        }
        if (res.system == 1) {
          that.userName = res.username
          let menulist = that.meuns
          for (var i = 0; i < menulist.length; i++) {
            var child = menulist[i].childNav
            menulist[i].meun = true
            if (child != undefined) {
              for (var k = 0; k < child.length; k++) {
                child[k].meun = true
              }
            }
          }
          setTimeout(() => {
            if (that.meuns[2].meun == true) {
              localStorage.setItem('quanxianS', '1')
              admiadminyindao('shou_ci_deng_lu').then(res => {
                if (res.code == 10000) {
                  if (res.status == 'deng_dai') {
                    that.$router.push({name: 'guide'})
                  }
                }
              })
              adminschoolbaseDetails().then(res => {
                if (res.code == 10000) {
                  let datas = res
                  if (datas.up_fenzhi != null) {
                    that.upDownNum = datas.fenzhi - datas.up_fenzhi
                  }
                  that.schoolName = datas.name
                  that.schoolCode = datas.school_code
                  localStorage.setItem('schoolCode', datas.school_code)
                } else {
                  that.$messageOne({message: res.message, type: 'error', duration: 3000})
                }
              }).catch(error => {
                that.$messageOne({message: error, type: 'error', duration: 3000})
              })
            }
          }, 500)
        } else {
          permissionList().then(res => {
            if (res.code == 10000) {
              let datas = res.data
              let array = []
              for (var i = 0; i < datas.length; i++) {
                let sarray = []
                let namRoles = datas[i].roles
                for (var j = 0; j < namRoles.length; j++) {
                  sarray.push(namRoles[j].id)
                }
                let obj = {}
                obj.name = datas[i].name
                obj.roles = sarray
                array.push(obj)
              }
              let meunsArray = that.meuns
              for (var i = 0; i < meunsArray.length; i++) {
                let names = meunsArray[i].name
                for (var j = 0; j < array.length; j++) {
                  let arrNames = array[j].name
                  if (names == arrNames) {
                    meunsArray[i].role = array[j].roles
                  }
                }
              }
              that.meuns = meunsArray
              setTimeout(() => {
                let menulist = that.meuns
                let qxVal = that.quanxian
                for (var i = 0; i < menulist.length; i++) {
                  var qx = menulist[i].role
                  for (var j = 0; j < qx.length; j++) {
                    if (qxVal == qx[j]) {
                      menulist[i].meun = true
                    }
                  }
                }
              }, 0)
              setTimeout(() => {
                if (that.meuns[2].meun == true) {
                  localStorage.setItem('quanxianS', '2')
                  admiadminyindao('shou_ci_deng_lu').then(res => {
                    if (res.code == 10000) {
                      if (res.status == 'deng_dai') {
                        that.$router.push({name: 'guide'})
                      }
                    }
                  })
                  adminschoolbaseDetails().then(res => {
                    if (res.code == 10000) {
                      let datas = res
                      if (datas.up_fenzhi != null) {
                        that.upDownNum = datas.fenzhi - datas.up_fenzhi
                      }
                      that.schoolName = datas.name
                      localStorage.setItem('schoolCode', datas.school_code)
                    } else {
                      that.$messageOne({message: res.message, type: 'error', duration: 3000})
                    }
                  }).catch(error => {
                    that.$messageOne({message: error, type: 'error', duration: 3000})
                  })
                } else {                  
                  localStorage.setItem('quanxianS', '3')
                  admiadminyindao('shou_ci_deng_lu').then(res => {
                    if (res.code == 10000) {
                      if (res.status == 'deng_dai') {
                        that.$router.push({name: 'guide'})
                      }
                    }
                  })
                }
              }, 500)
            } else if (res.code == '10002') {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
              that.$router.push({name: 'Login'})
            } else {
              that.$messageOne({message: res.message, type: 'error', duration: 3000})
            }
          }).catch(error => {
            that.$router.push({name: 'Login'})
            that.$messageOne({message: error, type: 'error', duration: 3000})
          })
        }
      } else if (res.code == '10002') {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
        that.$router.push({name: 'Login'})
      } else {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
  },
  mounted () {
    let that = this
    document.body.style.background = 'linear-gradient( 180deg, #CCE2FF 0%, #EFF5FD 100%)'
    document.body.style.height = '100vh'
    let arrOne = ''
    let arrTwe = ''
    adminScalelvl(1).then(res => {
      if (res.code == 10000) {
        let datas = res.data
        let len = datas.length
        let num = 0
        arrOne = datas
        for (var i = 0; i < datas.length; i++) {
          let completeness = res.data[i].completeness
          num += parseInt(completeness.toFixed(0))
        }
        that.wcdNum = num / len
        that.reportstatus = datas[0].report_status
        that.ifinsert = datas[0].if_insert
      } else {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    adminScalelvl(2).then(res => {
      if (res.code == 10000) {
        let datas = res.data
        let len = datas.length
        let num = 0
        arrTwe = datas
        for (var i = 0; i < datas.length; i++) {
          let completeness = res.data[i].completeness
          num += parseInt(completeness.toFixed(0))
        }
        that.wcdNumCt = num / len
      } else {
        that.$messageOne({message: res.message, type: 'error', duration: 3000})
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
    setTimeout(() => {
      let mergedArray = arrOne.concat(arrTwe)
      for (var i = 0; i < mergedArray.length; i++) {
        if (mergedArray[i].if_save == 1) {
          that.inSave = 1
          that.$forceUpdate()
        }
      }
    }, 2000)
  },
  methods: {
    gotoClick () {
      localStorage.setItem('navTabs', 'basicinfocoll')
      this.$router.push({name: 'index'})
    },
    gotoCTClick () {
      localStorage.setItem('navTabs', 'normalwork')
      this.$router.push({name: 'index'})
    },
    gotoUpBClick () {
      localStorage.setItem('navTabs', 'reportcter')
      this.$router.push({name: 'index'})
    },
    gotoLogin () {
      let that = this
      that.$confirm('确定退出系统?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        detelLogin().then(res => {
          that.$messageOne({message: '退出登录', type: 'success', duration: 3000})
          localStorage.removeItem('UserToken')
          that.$router.push({name: 'Login'})
          localStorage.setItem('navTabs', 'homes')
        }).catch(error => {
          that.$messageOne({message: error, type: 'error', duration: 3000})
        })
      }).catch(() => {
        that.$messageOne({message: '取消退出!', type: 'info', duration: 3000})
      })
    },
    gotMailsClick () {
      localStorage.setItem('navTabs', 'messagecent')
      this.$router.push({name: 'index'})
    },
    gotEetClick () {
      localStorage.setItem('navTabs', 'userlist')
      this.$router.push({name: 'index'})
    }
  }
}
</script>
<style scoped>
.header{height:70px;font-size:24px;line-height:70px;background: linear-gradient( 270deg, #5C9AEF 0%, #113887 100%);color:#fff;width:100%;}
.headerbox{padding:0 40px;}
.header h1{font-weight:500;font-size: 24px;color: #fff;text-align: left;font-style: normal;float:left;}
.header .leftOCbtn{width:220px;float:left;position:relative;top:5px;}
.headerTimes{float:right;font-weight: 500;
  font-size: 16px;
  color: #FFFFFF;
  text-align: right;
  font-style: normal;
  padding-right:16px;
}
.headerMail{float:right;padding:0 16px 0 0;width:32px;position:relative;}
.headerMail .mailIcon{background:url('../../assets/icon11.png') no-repeat 0 0/100%;width:32px;height:30px;display:block;cursor: pointer;position:relative;top:20px;}
.headerMail .SetIcon{background:url('../../assets/icon51.png') no-repeat 0 0/100%;width:32px;height:30px;display:block;cursor: pointer;position:relative;top:20px;}
.headerMail .yuanRed{width: 8px;height: 8px;background: #FF0000;border: 2px solid #3161B3;border-radius:50%;position:absolute;top:20px;right:12px;z-index:9999;display:block;}
.goto{float:right;font-weight: 500;font-size: 16px;color: #FFFFFF;text-align: right;font-style: normal;cursor:pointer;}
.bun{width:300px;height:300px;line-height:300px;background:#ff4400;margin:0 auto;cursor:pointer;color:#fff;}
.loginMain{width:1280px;margin:120px auto;position:relative;}
.countdownTimers{height:30px;line-height:30px;font-size: 16px;color: #161617;margin-bottom:24px;}
.countdownTimers span{height: 30px;padding:0 8px;background: linear-gradient( 180deg, #5E5F62 0%, #303133 100%);box-shadow: inset 0px 2px 2px 0px rgba(0,0,0,0.5);border-radius: 2px;display:inline-block;margin:0 4px 0 12px;color:#fff;}
.firstTip{height: 40px;line-height:40px;background: #FCF6EC;border-radius: 4px;border: 1px solid #F8E3C5;padding:0 15px;margin-bottom:24px;font-size: 14px;color: #E6A23C;}
.firstTip .fisrtIcon{display:inline-block;width:16px;height:16px;margin-right:4px;background:url('../../assets/icon36.png') no-repeat 0 0/100%;position:relative;top:3px;}
.homeW30Sig{width: 398px;height: 468px;background: linear-gradient( 180deg, #FAFAFA 0%, #EDF6FF 100%);box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.08);border-radius: 8px;border: 1px solid #FFFFFF;position:relative;float:left;text-align:center;}
.homeW30Sig.curr{opacity:0.5;}
.homeW30Sig .homeIconOne{display:block;width:120px;height:120px;margin:66px auto 20px;background:url('../../assets/icon38.png') no-repeat 0 0/100%;}
.homeW30Sig .homeIconTwe{display:block;width:120px;height:120px;margin:66px auto 20px;background:url('../../assets/icon37.png') no-repeat 0 0/100%;}
.homeW30Sig .homeIconThr{display:block;width:120px;height:120px;margin:106px auto 20px;background:url('../../assets/icon39.png') no-repeat 0 0/100%;}
.homeW30Sig .chupingbutn{width: 88px;height: 30px;background: #FA8F11;font-size: 20px;color: #FFFFFF;border-radius: 2px 0px 0px 2px;text-align:center;position:absolute;top:36px;right:-1px;}
.homeW30Sig .upDatabutn{display:block;width: 88px;height: 30px;background:  #67C23A;font-size: 20px;color: #FFFFFF;border-radius: 2px 0px 0px 2px;text-align:center;position:absolute;top:36px;right:-1px;}
.homeW30Sig .homeJinDload{width: 130px;height: 40px;line-height: 40px;background: #FFF8ED;border-radius: 20px;border: 1px solid #FFAB26;font-size: 20px;color: #FFAB26;padding:0 16px;margin:0 auto 40px;text-align:left;}
.homeW30Sig .homeTitles{font-weight:bold;font-size: 36px;color: #161617;line-height: 50px;text-align: center;margin-bottom:16px;}
.homeW30Sig .homeTexts{font-size: 20px;color: #606266;line-height: 28px;padding:0 40px;text-align:left;}
.homeW840Sig{width:840px;height: 470px;float:left;}
.homeBomW400{width: 398px;height: 128px;background: linear-gradient( 180deg, #FAFAFA 0%, #EDF6FF 100%);box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.08);border-radius: 8px;border: 1px solid #FFFFFF;float:left;position:relative;}
.homeBomW400 .iconLeft{background:url('../../assets/icon38.png') no-repeat 0 0/100%;display:block;float:left;margin-right:16px;width:80px;height:80px;}
.homeBomW400 .hw400Title{font-weight: bold;font-size: 24px;color: #161617;line-height: 33px;}
.homeBomW400 .hw400Test{font-size: 14px;color: #606266;line-height: 20px;margin-top:4px;}
.homeBomW400 .tipError{width: 88px;height: 30px;background: #E94A1E;border-radius: 2px 0px 0px 2px;line-height:30px;font-size: 20px;color: #FFFFFF;text-align:center;position:absolute;top:-1px;right:-1px;}
.homeBomW400 .jdtBox{width: 316px;height: 6px;position:absolute;bottom:0;left:82px;}
.homeBomW400 .jdtBox .jdtMian{position:relative;width:100%;height: 6px;}
.homeBomW400 .jdtBox .jdtMian .jdtLoad{width:30%;height: 6px;background:  #67C23A;position:absolute;bottom:0;left:0;z-index:99;}
.homeBomW400 .jdtBox .jdtMian .jdtLoad.ctCur{background:#3384E2;}
.homeBomW400 .jdtBox .jdtMian .jdtNum{width: 83px;height: 24px;line-height:24px;background: #FFFFFF;border: 1px solid #67C23A;text-align:center;position:absolute;bottom:-10px;left:30%;z-index:999;font-size: 12px;color: #67C23A;border-radius:12px;margin-left:-83px;}
.homeBomW400 .jdtBox .jdtMian .jdtNum.ctCur{border: 1px solid #3384E2;color:#3384E2;}
.homeTopW400{width: 840px;height: 320px;margin-bottom:20px;box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.08);border-radius: 8px;background:url('../../assets/icon40.png') no-repeat 0 0/100%;}
.homeTopW400 .topW400{height:60px;margin-bottom:16px;}
.homeTopW400 .topW400 .leftTop60{width:60px;height:60px;float:left;position:relative;margin-right:16px;}
.homeTopW400 .topW400 .leftTop60.current{margin-right:47px;}
.homeTopW400 .topW400 .leftTop60 .avatarHome{background:url('../../assets/icon42.png') no-repeat 0 0/100%;font-weight: bold;font-size: 20px;color: #FFFFFF;line-height: 60px;height:60px;width:60px;text-align:center;}
.homeTopW400 .topW400 .leftTop60 .avatarHome.curOne{background:url('../../assets/icon44.png') no-repeat 0 0/100%;}
.homeTopW400 .topW400 .leftTop60 .avatarHome.curTwe{background:url('../../assets/icon45.png') no-repeat 0 0/100%;}
.homeTopW400 .topW400 .leftTop60 .avatarNum{width: 51px;height: 24px;background: #FFFFFF;border-radius: 12px;border: 1px solid #67C23A;font-size: 14px;color: #67C23A;line-height:24px;text-align:center;position:absolute;top:-4px;right:-33px;}
.homeTopW400 .topW400 .leftTop60 .avatarNum .avatarIcon{background:url('../../assets/icon43.png') no-repeat 0 0/100%;width:12px;height:12px;display:inline-block;position:relative;top:1px;}
.homeTopW400 .topW400 .leftTop60 .avatarNum.arrcur{border: 1px solid #E94A1E;color: #E94A1E;}
.homeTopW400 .topW400 .leftTop60 .avatarNum.arrcur .avatarIcon{background:url('../../assets/icon41.png') no-repeat 0 0/100%;width:12px;height:12px;display:inline-block;position:relative;top:1px;}
.homeTopW400 .topW400 .leftTopTil{font-weight:bold;font-size: 24px;color: #161617;line-height: 33px;margin-bottom:4px;}
.homeTopW400 .topW400 .leftTopTxt{font-size: 14px;color: #161617;line-height: 22px;}
.homeTopW400 .topW400Img{margin-bottom:16px;}
.homeTopW400 .topW400Img .img{width:354px;height:32px;}
.homeTopW400 .tipsErrorNmu{font-weight:bold;font-size: 16px;color: #161617;line-height: 24px;margin-bottom:16px;}
.homeTopW400 .tipsErrorNmu .tipsEorIcon{width:20px;height:20px;display:inline-block;background:url('../../assets/icon46.png') no-repeat 0 0/100%;margin-right:12px;position:relative;top:2px;}
.homeTopW400 .tipsErrorNmu span{padding:0 4px;}
.homeTopW400 .txtTopLists{height: 22px;font-size: 14px;color: #161617;line-height: 22px;}
.homeTopW400 .txtTopLists span{padding:0 16px;}
.homeTopW400 .txtTopLists .ups{font-weight: bold;font-size: 14px;color: #67C23A;}
.homeTopW400 .txtTopLists .downs{font-weight: bold;font-size: 14px;color: #E94A1E;}
.homeTopW400 .txtTopLists .jcUpIcon{background:url('../../assets/icon43.png') no-repeat 0 0/100%;width:12px;height:12px;display:inline-block;position:relative;top:1px;}
.homeTopW400 .txtTopLists .jcUpIcon1{background:url('../../assets/icon41.png') no-repeat 0 0/100%;width:12px;height:12px;display:inline-block;position:relative;top:1px;}
.homeTopW400 .txtTopLists1{height: 22px;font-size: 14px;color: #E94A1E;line-height: 22px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;margin-bottom:12px;}
.loginMain.loginMainBox{width:840px;}
.homeW30Sig .tipError{width: 88px;height: 30px;background: #E94A1E;border-radius: 2px 0px 0px 2px;line-height:30px;font-size: 20px;color: #FFFFFF;text-align:center;position:absolute;top:36px;right:-1px;}
</style>
