<!-- 活动量管理 -->
<template>
  <div class="pb40">
    <van-collapse v-model="weeklyNames">
      <van-collapse-item title="活动量统计周报" title-class="fs16 fwb" name="1">
        <van-grid :column-num="2">
          <van-grid-item>
            <p class="fs14">周白板面谈数量</p>
            <p class="fs14 mt20 fwb">{{ weeklyInfo.whiteboard }}</p>
          </van-grid-item>
          <van-grid-item>
            <p class="fs14">周同业面谈数量</p>
            <p class="fs14 mt20 fwb">{{ weeklyInfo.sameTrade }}</p>
          </van-grid-item>
        </van-grid>
      </van-collapse-item>
    </van-collapse>

    <!-- 人才库 -->
    <div class="bg-white">
      <div class="p15" v-if="personnelsList.length == 0">
        <p class="fs16 fwb">人才库</p>
        <div class="text-center van-hairline--top">
          <van-icon name="add-square" size="50" color="#1989fa" />
        </div>
      </div>
      <van-collapse v-model="personnelNames" v-else>
        <van-collapse-item name="1" title-class="fs16 fwb">
          <div slot="title" class="flex justify-content-s align-items-c">人才库 <van-icon name="plus" /></div>
          <TalentPoolItem :talentPoolInfo="info" v-for="(info, index) in personnelsList" :key="index"> </TalentPoolItem>
        </van-collapse-item>
      </van-collapse>
      <p class="p15 text-right blue" v-if="personnelsList.length != 0">查看全部>>></p>
    </div>

    <!-- 当日增员活动日志 -->
    <div class="bg-white">
      <div class="p15" v-if="recordList.length == 0">
        <p class="fs16 fwb">当日增员活动日志</p>
        <div class="text-center van-hairline--top">
          <van-icon name="add-square" size="50" color="#1989fa" @click="toEdit" />
        </div>
      </div>
      <van-collapse v-model="recordNames" v-else>
        <van-collapse-item name="1" title-class="fs16 fwb">
          <div slot="title" class="flex justify-content-s align-items-c">当日增员活动日志 <van-icon name="plus" @click="toEdit" /></div>
          <ActivityLogItem :ActivityLogInfo="info" v-for="(info, index) in recordList" :key="index"></ActivityLogItem>
        </van-collapse-item>
      </van-collapse>
      <p class="p15 text-right blue" v-if="recordList.length != 0" @click="toList">查看全部>>></p>
    </div>
  </div>
</template>
<script>
import formatDate from '@/assets/js/utils/date-utils'
import { Collapse, CollapseItem, Grid, GridItem } from 'vant'
import TalentPoolItem from '@/components/ebiz/manpower/TalentPoolItem'
import ActivityLogItem from '@/components/ebiz/manpower/ActivityLogItem'
import { queryWeekly, queryListFirst, queryRecordList } from '@/api/ebiz/manpower/manpower'

export default {
  components: {
    [Collapse.name]: Collapse,
    [CollapseItem.name]: CollapseItem,
    [Grid.name]: Grid,
    [GridItem.name]: GridItem,
    TalentPoolItem,
    ActivityLogItem
  },
  data() {
    return {
      weeklyNames: ['1'],
      personnelNames: ['1'],
      recordNames: ['1'],
      talentPoolInfo: {
        name: '王辉',
        sameCompany: '中国人寿'
      },
      ActivityLogInfo: {
        recordCode: '',
        name: '王辉',
        // avatarUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
        age: '35岁',
        type: '同业',
        recordDate: formatDate.formatDate().split(' ')[0]
      },
      // 日志统计周报信息
      weeklyInfo: {
        whiteboard: '', // 白板
        sameTrade: '' // 同业
      },
      // 人才库列表
      personnelsList: [],
      // 增员日志列表
      recordList: []
    }
  },
  mounted() {
    this.queryWeekly()
    this.queryListFirst()
    this.queryRecordList()
  },
  methods: {
    // 获取日志统计周报
    queryWeekly() {
      queryWeekly({})
        .then(res => {
          console.log(res)
          if (res.result == 0) {
            this.weeklyInfo = res.content.weekly
          } else {
            this.$toast(res.resultMessage)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 获取日志统计的人才库列表
    queryListFirst() {
      queryListFirst({})
        .then(res => {
          console.log(res)
          if (res.result == 0) {
            this.personnelsList = res.content.personnels
          } else {
            this.$toast(res.resultMessage)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 查询增员日志列表
    queryRecordList() {
      let data = {
        recordDate: ''
      }
      queryRecordList(data)
        .then(res => {
          console.log(res)
          if (res.result == 0) {
            this.recordList = res.content.records
          } else {
            this.$toast(res.resultMessage)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    toList() {
      this.$jump({
        flag: 'h5',
        extra: {
          url: location.origin + `/#/manpower/ActivityLog/List`,
          forbidSwipeBack: '1'
        },
        routerInfo: { path: '/manpower/ActivityLog/List' }
      })
    },
    toEdit() {
      this.$jump({
        flag: 'h5',
        extra: {
          url: location.origin + `/#/manpower/ActivityLog/Edit`,
          forbidSwipeBack: '1'
        },
        routerInfo: { path: '/manpower/ActivityLog/Edit' }
      })
    }
  }
}
</script>
<style lang="scss" scoped></style>
