<template>
  <el-collapse v-model="activeName" accordion >
    <el-collapse-item :name="deptName">
      <template slot="title">
        <div style="width: 100%;height:100%;margin-left: 5%;text-align: center;line-height: 50px">
          <button class="deptName">{{deptName}}
            <span v-if="type==='ks'||type==='cq'">({{type==='ks'?'总人数:':'出勤:'}}{{users}})</span>
          </button>
        </div>
      </template>
      <div class="box" v-for="(item,index) in data[deptName]" @click="itemClick(item)">
        <div style="font-size: 16px;text-align: center">
          {{item.name}}
        </div>
        <div style="text-align: center;">
          <img :src="item.headImage" :style="{width: myStyle.headImgWidth||'100%'}">
        </div>
        <div v-if="!!item.cq" style="width:100%;font-size: 12px;text-align: center;color:blue;margin-bottom: 15px;line-height: 19px">
          任务:{{test()}}
          <el-progress type="line" :text-inside="true" :stroke-width="18" :style="{width:'65%',float:'left',marginLeft:'2%'}"
            :percentage="Math.round(item.gzl/test()*100,2)>100?100:65"
            :color="'green'" text-color="white"/>
        </div>
      </div>
    </el-collapse-item>
  </el-collapse>
</template>

<script>
import XEUtils from 'xe-utils'
export default {
  name:"Template",
  props:{
    data:Object,
    deptName:String,
    type:String,
    myStyle:Object,
    users:Number
  },
  data(){
    return {
      activeName:'1',
    }
  },
  methods:{
    itemClick(item){
      this.$emit('initDetail',item);
    },
    test(){
      return XEUtils.random(1,60)
    }
  }
}
</script>

<style scoped>
.box{
  width:49%;
  text-align: center;
  border: 3px solid yellow;
  border-radius: 25px;
  float: left;
  margin: 1px;
}
.deptName{
  color: white;
  border:1px solid blue;
  border-radius:15px;
  background-color: blue;
  width: 80%;
  height: 30px;
  line-height: 30px;
  font-size: 16px;
  box-shadow: 2px 2px 2px 1px black;
}
</style>
