<template>
  <div class="warrper">
    <div v-if="subNavShow == true" style="padding:24px 12px 24px 24px;">
      <div class="gotoButton pb24" style="padding-right:12px;" @click="gotoCLick"><i class="gotoIcon"></i>返回</div>
      <div class="gjhqTitle pb24" style="padding-right:12px;" ><span class="rf"><span class="titlesSml">完成度</span> {{parseInt(wcdNum)}} %</span>常态工作记录</div>
      <div style="margin-right:12px;">
        <div class="basiWcd">
          <div class="basiWcdjdNums" :style="{width:parseInt(wcdNum)+'%'}"></div>
        </div>
      </div>
      <div class="basicinBox">
        <div class="ulliBox" v-for="(item, i) in basiDatas" :key="i">
          <div class="ulli"  v-if="item.meun == true">
            <div class="basicTile">{{ item.titles }}</div>
            <div class="basicinLibs" v-for="(itemSub, idex) in item.arrayDatas" :key="idex">
                <div class="basicinLi">
                  <div class="basicTile">{{ itemSub.titles }}</div>
                  <div class="basicInfo">
                    <span class="jrButton" @click="tbClick(item, '')"></span>
                    <span v-if="item.wcd != null"><i class="iconInfo"></i>完整度 {{ item.wcd }} %</span>
                    <span v-else>-</span>
                    <span v-if="item.dbfk != null"><i class="iconInfo1"></i>督办反馈 {{ item.dbfk }}</span>
                    <span v-else>-</span>
                  </div>
              </div>
            </div>
          </div>
        </div>
        <div class="clear"></div>
      </div>
    </div>
    <div v-else>
      <div :is="componentVal" @gotoBack="subNavBack"></div>
    </div>
  </div>
</template>
<script>
import schoolscale from '../schoolscale/schoolscale.vue'
import { adminLoginqx, adminScalelvl, adminreportcycle } from '../../axios/api'
export default {
  name: 'basicinfocoll',
  components: {
    schoolscale
  },
  data () {
    return {
      subNavShow: true,
      componentVal: 'schoolscale',
      wcdNum: 0,
      quanxian: 'admin',
      reportcode: '',
      basiDatas: [
        {
          titles: '1.1 学校基础信息采集量表',
          wcd: 100,
          dbfk: 0,
          url: 'schoolscale',
          showV: '1',
          name: 'admin:school',
          role: [],
          meun: false,
          if_insert: 1,
          reportEdit: true,
          arrayDatas: [
            {
              titles: '1.1.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.1.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            }
          ]
        },
        {
          titles: '1.2 学校基础信息采集量表',
          wcd: 100,
          dbfk: 0,
          url: 'schoolscale',
          showV: '1',
          name: 'admin:school',
          role: [],
          meun: false,
          if_insert: 1,
          reportEdit: true,
          arrayDatas: [
            {
              titles: '1.2.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.2,1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.2.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.2,1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.2.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.2,1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            }
          ]
        },
        {
          titles: '1.3 学校基础信息采集量表',
          wcd: 100,
          dbfk: 0,
          url: 'schoolscale',
          showV: '1',
          name: 'admin:school',
          role: [],
          meun: false,
          if_insert: 1,
          reportEdit: true,
          arrayDatas: [
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            }
          ]
        },
        {
          titles: '1.3 学校基础信息采集量表',
          wcd: 100,
          dbfk: 0,
          url: 'schoolscale',
          showV: '1',
          name: 'admin:school',
          role: [],
          meun: false,
          if_insert: 1,
          reportEdit: true,
          arrayDatas: [
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            }
          ]
        },
        {
          titles: '1.3 学校基础信息采集量表',
          wcd: 100,
          dbfk: 0,
          url: 'schoolscale',
          showV: '1',
          name: 'admin:school',
          role: [],
          meun: false,
          if_insert: 1,
          reportEdit: true,
          arrayDatas: [
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            },
            {
              titles: '1.3.1 学校基础信息采集量表',
              wcd: 100,
              dbfk: 0,
              url: 'schoolscale',
              showV: '1',
              name: 'admin:school',
              role: [],
              meun: false,
              if_insert: 1,
              reportEdit: true
            }
          ]
        }
      ]
    }
  },
  created () {    
    let that = this
    if (navigator.onLine) {      
    } else {
      that.$messageOne({message: '网络异常，请检测网络是否链接！', type: 'error', duration: 3000})
      return false
    }
    adminreportcycle().then(res => {
      if (res.code == 10000) {
        if (res.report_code != null) {
          that.reportcode = res.report_code
        }
      }
    }).catch(error => {
      that.$messageOne({message: error, type: 'error', duration: 3000})
    })
  },
  mounted () {
    let that = this
    setTimeout(() => {
      adminLoginqx().then(res => {
        if (res.code == 10000) {
          if (res.role != null) {
            that.quanxian = res.role.id
          } else {
            that.quanxian = 0
          }
          if (res.system == 1) {
            let menulist = that.basiDatas
            for (var i = 0; i < menulist.length; i++) {
              menulist[i].meun = true
            }
          } else {
            let permissonListDatas = JSON.parse(localStorage.getItem('permissonListDatas'))
            let meunsArray = that.basiDatas
            for (var i = 0; i < meunsArray.length; i++) {
              let names = meunsArray[i].name
              for (var j = 0; j < permissonListDatas.length; j++) {
                let arrNames = permissonListDatas[j].name
                if (names == arrNames) {
                  meunsArray[i].role = permissonListDatas[j].roles
                }
              }
            }
            that.meuns = meunsArray            
            let menulist = that.basiDatas
            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
                }
              }
            }
          }
        } else {
          that.$messageOne({message: res.message, type: 'error', duration: 3000})
        }
      }).catch(error => {
        that.$messageOne({message: error, type: 'error', duration: 3000})
      })
    }, 1500)
  },
  methods: {
    gotoCLick () {
      this.$router.push({name: 'homes'})
    },
    tbClick (obj, txt) {      
      obj.if_insert = 1
      obj.dbfkshow = true
      obj.dbfj = 'dbfk'
      obj.edit = txt
      obj.report_code = this.reportcode
      localStorage.setItem('basicinfollDatas', JSON.stringify(obj))
      this.subNavShow = false
      this.componentVal = obj.url
    },
    tbTweClick (obj, txt) {      
      obj.dbfkshow = true
      obj.dbfj = 'dbfk'
      obj.if_insert = 2
      obj.edit = txt
      obj.report_code = this.reportcode
      localStorage.setItem('basicinfollDatas', JSON.stringify(obj))
      this.subNavShow = false
      this.componentVal = obj.url
    },
    subNavBack (value) {
      this.subNavShow = true
      this.componentVal = ''
    }
  }
}
</script>
<style scoped>
.basicinBox{margin:24px 0 0;height:800px;overflow:hidden;overflow-y:auto;}
.basicinBox .ulli{overflow:hidden;margin-bottom:24px;border-bottom:1px solid #E1E1E6;}
.basicinBox .basicTile{font-weight: bold;font-size: 20px;color: #161617;line-height: 28px;margin-bottom:16px;height:28px;overflow:hidden;}
.basicinBox .basicinLibs{width:25%;float:left;overflow:hidden;}
.basicinBox .basicinLi{background: #FFFFFF;border-radius: 2px;border: 1px solid #D9D9D9;margin-right:12px;padding:16px;margin-bottom:24px;height:70px;}
.basicinBox .basicinLi .basicInfo{padding-bottom:16px;font-size: 14px;color: #595959;line-height: 20px;}
.basicinBox .basicinLi .basicInfo span{margin-right:24px;}
.basicinBox .basicinLi .basicInfo .iconInfo{background:url('../../assets/icon48.png') no-repeat 0 0/100%;width:20px;height:20px;display:inline-block;margin-right:4px;position:relative;top:5px;}
.basicinBox .basicinLi .basicInfo .iconInfo1{background:url('../../assets/icon49.png') no-repeat 0 0/100%;width:20px;height:20px;display:inline-block;margin-right:4px;position:relative;top:5px;}
.basicinBox .basicinLi .basicInfo .jrButton{background:url('../../assets/icon56.png') no-repeat 0 0/100%;width:20px;height:20px;position:relative;top:5px;float:right;margin-right:0;cursor:pointer;}
.basiButton{padding-top:16px;cursor:pointer;font-size: 14px;color: #0071DB;line-height: 20px;text-align:right;}
.basiButton.cur{color:#A8ABB2}
.basiWcd{height: 8px;background: #E6E6E6;border-radius: 2px;overflow:hidden;width:100%;}
.basiWcd .basiWcdjdNums{height: 8px;background: #3384E2;overflow:hidden;}
</style>
