<template>
  <div class="titleCom">
    <div class="titleRow">
      <van-cell v-for="i in list" :key="i.name">
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <span class="custom-title">{{ i.name }}</span>
        </template>

        <div class="itemNum">{{ allData[i.key] }}</div>
      </van-cell>
    </div>
    <!-- 设备 -->
    <div class="equipment">
      <van-cell>
        <template #title>
          <span class="custom-title">大堂式自助设备</span>
        </template>
        <span class="itemNum">{{ allData['lobbyDeviceCount'] }}</span>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="custom-title">穿墙式自助设备</span>
        </template>
        <span class="itemNum">{{ allData['throughwallDeviceCount'] }}</span>
      </van-cell>
    </div>
    <!-- 模块数据展示 -->
    <div class="businessModule">
      <div class="moduleCom">
        <div class="titleText"><span class="leftSty"></span><span>GA38-2021</span></div>
        <div class="complete">
          <div class="numCls wj-title-blue">
            <!--{{ parseInt((allData.ga38['GA382021'].currentCompletedRate || 0) * 100) }}%-->
            {{allData.ga38['GA382021'].shouldComplete || 0}}
          </div>
        </div>
        <div class="moduleItem">
          <!--<div>
            <div class="numCls wj-title-blue">{{ allData.ga38['GA382021'].currentCompletedCount }}</div>
            <div class="fontCls">当月新增数</div>
          </div>
          <div>
            <div class="numCls wj-title-blue tal ga38cls">
              <van-icon v-if="allData.ga38['GA382021'].compare > 0" name="play" class="wj-title-red rate270" />
              <van-icon v-else name="play" class="wj-title-green rate" />
              <span>{{ Math.abs(parseInt(allData.ga38['GA382021'].compare )) }}</span>
            </div>
            <div class="fontCls ">较上月增长数</div>
          </div>-->
          <div class="fontCls">当前达标数</div>
        </div>
      </div>

      <div class="moduleCom">
        <div class="titleText"><span class="leftSty"></span><span>GA38-2015</span></div>
        <div class="complete">
          <div class="numCls wj-title-blue">
            <!--{{ parseInt((allData.ga38['GA382015'].currentCompletedRate||0) * 100) }}%-->

            {{allData.ga38['GA382015'].shouldComplete || 0}}
          </div>
        </div>
        <div class="moduleItem">
    <!--      <div>
            <div class="numCls wj-title-blue">{{ allData.ga38['GA382015'].currentCompletedCount }}</div>
            <div class="fontCls">当月新增数</div>
          </div>
          <div>
            <div class="numCls wj-title-blue tal ga38cls">
              <van-icon v-if="allData.ga38['GA382015'].compare > 0" name="play" class="wj-title-red rate270" />
              <van-icon v-else name="play" class="wj-title-green rate" />

              <span>{{ Math.abs(parseInt(allData.ga38['GA382015'].compare ))}}</span>
            </div>
            <div class="fontCls ">较上月增长数</div>
          </div>-->
          <div class="fontCls">当前达标数</div>
        </div>
      </div>
    </div>
    <div class="businessModule">
      <div class="moduleCom" v-for="(item, index) in Object.keys(allData.taskInfo)" :key="index">
        <div class="titleText">
          <span class="leftSty"></span><span>{{ Object.keys(allData.taskInfo)[index] }}</span>
        </div>
        <div class="complete">
          <div class="numCls wj-title-blue">
            {{ parseInt(allData.taskInfo[Object.keys(allData.taskInfo)[index]].currentCompletedRate * 100) }}%
          </div>

        </div>
        <div class="moduleItem">
          <div>
            <div class="numCls wj-title-blue">
              {{ allData.taskInfo[Object.keys(allData.taskInfo)[index]].currentCompletedCount }}
            </div>
            <div class="fontCls">{{Object.keys(allData.taskInfo)[index]=='预案演练'?'当季完成数':'当月完成数'}}</div>
          </div>
          <div>
            <div class="numCls wj-title-blue tal">
              <van-icon v-if="allData.taskInfo[Object.keys(allData.taskInfo)[index]].compare  > 0" name="play" class="wj-title-red rate270" />
              <van-icon v-else name="play" class="wj-title-green rate" />
              <span
                >{{ Math.abs(parseInt(allData.taskInfo[Object.keys(allData.taskInfo)[index]].compare * 100)) }}%</span
              >
            </div>
            <div class="fontCls">{{Object.keys(allData.taskInfo)[index]=='预案演练'?'完成率(较上季)':'完成率(较上月)'}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getOverview } from '@/api/cockpit.js'
export default {
  name: 'SocAppOverviewCom',
  components: {},
  props: {
    orgId: ''
  },
  data() {
    return {
      list: [
        {
          name: '行社',
          key: 'hangsheCount'
        },
        {
          name: '营业网点',
          key: 'bankingCount'
        },
        {
          name: '中心业务库',
          key: 'centerStoreCount'
        },
        {
          name: '网点业务库',
          key: 'bankingStoreCount'
        },
        {
          name: '在行式自助银行',
          key: 'onlineATMCount'
        },
        {
          name: '离行式自助银行',
          key: 'offlineATMCount'
        }
        // {
        //   name: '大堂式设备数量',
        //   key: 'onlineATMCount'
        // },
        // {
        //   name: '穿墙式设备数量',
        //   key: 'throughwallDeviceCount'
        // }
      ],
      allData: {
        bankingCount: '',
        bankingStoreCount: '',
        centerStoreCount: '',
        hangsheCount: '',
        lobbyDeviceCount: '',
        offlineATMCount: '',
        onlineATMCount: '',
        throughwallDeviceCount: '',
        ga38: {
          GA382015: null,
          GA382021: null
        }
      } //总览数据对象
    }
  },
  created() {
    this.getAllList()
    //获取基础信息
  },
  mounted() {},
  watch: {
    orgId(val) {
      this.getAllList(val)
    }
  },
  methods: {
    // 获取总览数据
    getAllList(val) {
      getOverview({ orgId: val?val:this.orgId }).then(res => {
        let { data } = res
        this.allData = data
        // this.allData.bankingCount = this.remedyZero(this.allData.bankingCount)
        // this.allData.bankingStoreCount = this.remedyZero(this.allData.bankingStoreCount)
        // this.allData.centerStoreCount = this.remedyZero(this.allData.centerStoreCount)
        // this.allData.hangsheCount = this.remedyZero(this.allData.hangsheCount)
        // this.allData.lobbyDeviceCount = this.remedyZero(this.allData.lobbyDeviceCount)
        // this.allData.offlineATMCount = this.remedyZero(this.allData.offlineATMCount)
        // this.allData.onlineATMCount = this.remedyZero(this.allData.onlineATMCount)
        // this.allData.throughwallDeviceCount = this.remedyZero(this.allData.throughwallDeviceCount)
      })
    },
    //自动补0
    remedyZero(val) {
      let newVal = val || ''
      // let newVal = val + ''
      let num = newVal.length

      for (let index = 0; index < num; index++) {
        newVal = newVal[index]
      }
      return ('' + newVal).split('')
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep.van-cell::after {
  border-bottom: 1px solid #008cd6;
}
.titleCom {
  // background-color: #f0f0f0;
  // margin: 10px;
  // box-shadow: 0 2px 10px #ccc;
  .titleRow {
    box-shadow: 0 2px 10px #ccc;
    margin-left: 12px;
    // margin-top: 10px;
    margin-right: 14px;
  }
  .itemNum {
    width: 100%;
    height: 40px;
    margin-left: 10px;
    font-size: 40px;
    //font-family: fantasy;
    text-align: left;
    // font-weight: bold;
    // border: 1px solid #ccc;
    // box-shadow: 0 2px 10px #ccc;
    color: #008cd6;
    display: inline-block;
    text-align: center;
    line-height: 40px;
  }
}
.equipment {
  margin-top: 20px;
  box-shadow: 0 2px 10px #ccc;
  margin-left: 12px;
  margin-right: 14px;
}
.bigModule {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.tal {
  text-align: right;
  padding-right: 0px;
}
.moduleCom {
  width: 47%;
  height: 260px;
  background-color: #fff;
  margin-top: 20px;
  padding: 10px;
  box-shadow: 0 2px 10px #ccc;
  // border-left: 1px solid #008cd6;
  position: relative;

  .moduleItem {
    margin-top: 30px;
    display: flex;
    text-align: center;
    align-content: center;
    justify-content: space-around;
    line-height: 30px;
    .numCls {
      font-size: 30px;
      margin-bottom: 10px;

      .iconcls {
        font-size: 30px;
      }
    }
    .textCCls {
      text-align: right;
    }
    > div {
      width: 42%;
    }
    .fontCls {
      font-size: 20px;
    }
    .ga38cls{
      text-align: center;
    }
  }
}

.businessModule {
  display: flex;
  flex-wrap: wrap;
}
.businessModule {
  .moduleCom {
    margin: 10px;
  }
}

.rate {
  transform: rotate(90deg);
}
.rate270 {
  transform: rotate(270deg);
}
.titleText {
  font-size: 4vw;
  vertical-align: middle;
  .leftSty {
    display: inline-block;
    width: 10px;
    height: 4vw;
    vertical-align: text-top;
    margin-right: 10px;
    margin-left: 10px;
    background-color: #008cd6;
  }
}
.complete {
  text-align: center;
  font-size: 7vw;
  // font-family: fantasy;
  margin-top: 30px;
}
::v-deep.van-icon-play {
  font-size: 40px;
  position: absolute;
  left: 49%;
  top: 62%;
}
</style>
