<template>
  <div class="Btarget">
    <div v-if="type != 4" class="container linep">
      <van-collapse v-model="activeNames">
        <!-- 拜访数据(实时) -->
        <van-collapse-item name="7" v-if="powerGrade == 1 && !GZdata">
          <template #title>
            <div>拜访数据(实时)</div>
            <!-- 工装不显示 -->
          </template>
          <visitedRealTime
            :reportTargetAll="reportTargetAll"
            :powerGrade="powerGrade"
            :JZQuota="JZQuota"></visitedRealTime>
        </van-collapse-item>
        <!-- 建店布机 -->
        <van-collapse-item name="2" v-if="!JZQuota && !GZdata" title="建店布机">
          <createStoreBJ :reportTargetAll="reportTargetAll"></createStoreBJ>
        </van-collapse-item>
        <!-- 下单点数 -->
        <van-collapse-item v-if="powerGrade == 1 && !JZQuota && !GZdata" name="33" title="下单点数">
          <placeOrder :reportTargetAll="reportTargetAll"></placeOrder>
        </van-collapse-item>
        <!-- 专业时时丽分销店下单 -->
        <van-collapse-item name="16" v-if="!JZQuota && !GZdata" title="专业时时丽分销店下单">
          <ZYPlaceOrder :reportTargetAll="reportTargetAll"></ZYPlaceOrder>
        </van-collapse-item>
        <!-- 超好贴分销店下单 -->
        <van-collapse-item name="17" v-if="!JZQuota && !GZdata" title="超好贴分销店下单">
          <veryGoodPlaceOrder :reportTargetAll="reportTargetAll"></veryGoodPlaceOrder>
        </van-collapse-item>
        <van-collapse-item v-if="powerGrade != 1 && !JZQuota && !GZdata" name="32" title="客户开拓">
          <van-row>
            <van-col span="24"><span class="leftTitle">非片客户开发</span></van-col>
            <van-col span="24">
              <p>
                全年开发数：<span class="colorbalck">{{
                  Micrometer(reportTargetAll.customerAct)
                }}</span>
              </p>
            </van-col>
            <van-col span="24">
              <p>
                全年进度率：
                <span class="colorbalck"> {{ reportTargetAll.customerYearRate }}% </span>
              </p>
            </van-col>
          </van-row>
        </van-collapse-item>
        <van-collapse-item v-if="powerGrade == 2" name="8" title="当日门店拜访情况(实时)">
          <div v-if="reportTargetAll.realTimeVisits == null" style="margin-top: -10px">
            <p style="text-align: center; color: #666">暂无数据</p>
          </div>
          <div v-if="reportTargetAll.realTimeVisits != null" style="margin-top: -10px">
            <div class="container" style="width: 100%; margin: 0 auto; padding: 10px 0">
              <el-table
                :data="reportTargetAll.realTimeVisits"
                border
                class="table-headermd table-headermdhome"
                style="width: 100%">
                <el-table-column label="业务员" prop="userName">
                  <template slot-scope="scope">
                    <span class="tipTitle">{{ scope.row.userName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拜访次数" prop="visitAct" />
                <el-table-column :label="'金牌店\n拜访率'" prop="jpVisitRate">
                  <template slot-scope="scope">
                    <span class="tipTitle">{{ scope.row.jpVisitRate }}%</span>
                  </template>
                </el-table-column>
                <el-table-column :label="'同城店\n拜访率'" prop="tcVisitRate">
                  <template slot-scope="scope">
                    <span class="tipTitle">{{ scope.row.tcVisitRate }}%</span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </van-collapse-item>
      </van-collapse>
    </div>
    <div v-if="type == 4" class="container linep">
      <van-collapse v-model="activeNames" v-if="reportInfo.customerUserTargets">
        <van-collapse-item
          :name="index + ''"
          :title="item.nickName"
          v-for="(item, index) in reportInfo.customerUserTargets"
          :key="index">
          <van-row>
            <van-col span="24"
              ><p class="indexTile" style="margin-top: -2px">
                <van-icon :name="bfindex" class="indexicon"></van-icon>拜访
              </p></van-col
            >
            <van-col span="12"
              ><p><span class="leftTitle">本日实际</span></p></van-col
            >
            <van-col span="12"
              ><p><span class="rightTitle">本月实际</span></p></van-col
            >
            <van-col span="12"
              ><p>
                拜访点数:<span class="colorbalck">{{ Micrometer(item.dayVisitCount) }}</span>
              </p></van-col
            >
            <van-col span="12"
              ><p>
                拜访点数:<span class="colorbalck">{{ Micrometer(item.monthVisitCount) }}</span>
              </p></van-col
            >
            <van-col span="24"
              ><p class="indexTile">
                <van-icon :name="storeindex" class="indexicon"></van-icon>建店
              </p></van-col
            >
            <van-col span="12"
              ><p><span class="leftTitle">本日新增</span></p></van-col
            >
            <van-col span="12"
              ><p><span class="rightTitle">本月实际</span></p></van-col
            >
            <van-col span="12"
              ><p>
                分销店点数:<span class="colorbalck">{{ Micrometer(item.dayFxdAct) }}</span>
              </p></van-col
            >
            <van-col span="12"
              ><p>
                分销店点数:<span class="colorbalck">{{ Micrometer(item.monthFxdAct) }}</span>
              </p></van-col
            >
            <van-col span="24"
              ><p class="indexTile">
                <van-icon :name="oderindex" class="indexicon"></van-icon>下单
              </p></van-col
            >
            <van-col span="12"
              ><p><span class="leftTitle">昨日新增</span></p></van-col
            >
            <van-col span="12"
              ><p><span class="rightTitle">本月实际</span></p></van-col
            >
            <van-col span="12"
              ><p>
                下单点数:<span class="colorbalck">{{ Micrometer(item.yesOrderAct) }}</span>
              </p></van-col
            >
            <van-col span="12"
              ><p>
                下单点数:<span class="colorbalck">{{ Micrometer(item.monthOrderAct) }}</span>
              </p></van-col
            >
          </van-row>
        </van-collapse-item>
      </van-collapse>
    </div>
  </div>
</template>
<script>
import createStoreBJ from '@/views/componentsTarget/createStoreBJ';
import visitedRealTime from '@/views/componentsTarget/visitedRealTime';
import placeOrder from '@/views/componentsTarget/placeOrder';
import ZYPlaceOrder from '@/views/componentsTarget/ZYPlaceOrder';
import veryGoodPlaceOrder from '@/views/componentsTarget/veryGoodPlaceOrder';

import neiqiangzhonggaoduanSAP from '@/views/componentsTarget/neiqiangzhonggaoduanSAP';
export default {
  components: {
    createStoreBJ,
    visitedRealTime,
    placeOrder,
    ZYPlaceOrder,
    veryGoodPlaceOrder,
    neiqiangzhonggaoduanSAP,
  },
  props: {
    reportInfo: {
      type: Object,
    },
  },
  watch: {
    reportInfo: {
      handler(val) {
        if (val.postType == 'GZ') {
          this.GZdata = true;
          this.saptitle = '公裝业绩SAP(千元)';
        } else {
          this.saptitle = '业绩目标SAP(千元)';
          this.GZdata = false;
        }
        if (val.postType == 'JZ') {
          this.JZQuota = true;
        } else {
          this.JZQuota = false;
        }
        this.reportInfoData = val;
        this.powerGrade = val.positionId;
        if (val.reportTargetAll != null) {
          this.reportTargetAll = val.reportTargetAll;
        }
        this.type = val.userType;
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      type: '-1',
      JZQuota: false,
      GZdata: false,
      saptitle: '业绩目标SAP(千元)',
      powerGrade: '2',
      reportTargetAll: {},
      activeNames: [
        '1',
        '2',
        '3',
        '4',
        '5',
        '6',
        '7',
        '8',
        '10',
        '11',
        '12',
        '16',
        '17',
        '20',
        '21',
        '22',
        '23',
        '24',
        '25',
        '26',
        '27',
        '28',
        '29',
        '30',
        '31',
        '32',
        '33',
        '34',
        '35',
        '36',
        '37',
        '38',
        '39',
        '40',
        '41',
        '42',
        '43',
      ],
    };
  },
};
</script>
