<template>
  <div class="mycareer" :style="{'zoom':this.zoom}">
    <div class="close" @click="close" v-if="showClose"></div>
    <div class="title">
      <div class="star"></div>
      <div class="company-name">{{emp.companyName}}</div>
      <div class="uerf">
        <div class="dept-name">{{emp.deptName}}</div>
        <div class="uer-name">{{emp.name}}</div>
      </div>
      <div class="post-name">{{emp.job}}</div>
    </div>
    <div class="uer-box">
      <div class="photo">
        <img :src="emp.photo" />
        <div class="zezhao"></div>
        <div class="bottom"></div>
      </div>
      <div class="my-score">
        <div class="item">
          <div class="k">综合能力</div>
          <div class="v">{{emp.sumScore}}</div>
        </div>
        <div class="item">
          <div class="k">周冠</div>
          <div class="v">{{emp.champions}}</div>
        </div>
        <div class="item">
          <div class="k">能力排名</div>
          <div class="v white">#{{emp.rank}}</div>
        </div>
      </div>
      <div class="dashboards" v-if="emp.name">
        <div class="item">
          <dashboard :score="emp.development" title="名单开发"></dashboard>
        </div>
        <div class="item">
          <dashboard :score="emp.appointment" title="约访"></dashboard>
        </div>
        <div class="item">
          <dashboard :score="emp.demand" title="探询需求"></dashboard>
        </div>
        <div class="item">
          <dashboard :score="emp.solveDemand" title="解决需求"></dashboard>
        </div>
        <div class="item">
          <dashboard :score="emp.clinch" title="说明成交"></dashboard>
        </div>
        <div class="item">
          <dashboard :score="emp.service" title="售后服务"></dashboard>
        </div>
      </div>
    </div>
    <div class="split"></div>
    <div class="change-box">
      <div class="btn" @click="ClickChoose1(-1)" :class="{'dis':index1==0}">
        <i class="el-icon-caret-left"></i>
      </div>
      <div class="option">{{choose1[index1]}}</div>
      <div class="btn" @click="ClickChoose1(1)" :class="{'dis':choose1.length-1==index1}">
        <i class="el-icon-caret-right"></i>
      </div>
    </div>
    <div class="data-box-before"></div>

    <div class="data-box" v-loading="isLoadingTableData">
      <div class="tab-head" ref="mycareerHead">
        <table>
          <thead>
            <tr>
              <th style="min-width: 100px;max-width: 100px;">&nbsp;</th>
              <th @click="sort" data-key="SumScore">总分</th>
              <th @click="sort" data-key="AddCustomer">新增同行</th>
              <th @click="sort" data-key="AdSend">IM广告</th>
              <th @click="sort" data-key="ImUsedCount">IM互动</th>
              <th @click="sort" data-key="ImUsedTime">IM时长</th>
              <th @click="sort" data-key="ClientPv">同行PV</th>
              <th @click="sort" data-key="OutTime">外出时长</th>
              <th @click="sort" data-key="FinishPlanCount">拜访次数</th>
              <th @click="sort" data-key="FutureCount">计划次数</th>
              <th @click="sort" data-key="FutureClientCount">计划同行数</th>
              <th @click="sort" data-key="AvgFutureSee">2周内平均拜访</th>
              <th @click="sort" data-key="FutureSeeOldClient,FutureSeeNewClient">新老同行占比</th>
              <th @click="sort" data-key="TripSite">询价目的地</th>
              <th @click="sort" data-key="PeopleCount">询价人数</th>
              <th @click="sort" data-key="TripMonth">出发日期</th>
              <th @click="sort" data-key="OldClientEnquiry">老客户询价</th>
              <th @click="sort" data-key="DownloadTrip">下载行程</th>
              <th @click="sort" data-key="UsedApp">42助手时长</th>
              <th @click="sort" data-key="UsedErp">ERP时长</th>
              <th @click="sort" data-key="UsedWe">知识圈时长</th>
              <th @click="sort" data-key="SevenDayOrder">7日人数</th>
              <th @click="sort" data-key="FifteenDayOrder">15日人数</th>
              <th @click="sort" data-key="MonthOrder">30日人数</th>
              <th @click="sort" data-key="OutMonthOrder">30日以外人数</th>
              <th @click="sort" data-key="SanCount">散客人数</th>
              <th @click="sort" data-key="DanCount">单团数量</th>
              <th @click="sort" data-key="IsSeeClient">拜访报名同行</th>
              <th @click="sort" data-key="OldClientOrders">老同行报名</th>
              <th @click="sort" data-key="BuilderAd">广告制作</th>
              <th @click="sort" data-key="AdToApp">广告转发IM</th>
              <th @click="sort" data-key="IncomeMoney">收款次数</th>
              <th @click="sort" data-key="Tousu">处理投诉</th>
              <th @click="sort" data-key="SeeOldClient">拜访老客户</th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="lft-head">
        <table>
          <thead>
            <tr>
              <th style="min-width: 100px;max-width: 100px;">时间</th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="lft-body" ref="mycareerLeft">
        <table>
          <tbody>
            <tr v-for="(item, index) in tableData" :key="index">
              <td class="odd">{{item.CreateTimeFM}}</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="content-body" ref="mycareerContent">
        <table>
          <tbody>
            <tr v-for="(item, index) in tableData" :key="index">
              <td style="min-width: 100px;max-width: 100px;background:#1d160b">&nbsp;</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,1)">{{item.SumScore}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,2)">{{item.AddCustomer}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,3)">{{item.AdSend}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,4)">{{item.ImUsedCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,5)">{{item.ImUsedTime}}分钟</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,6)">{{item.ClientPv}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,7)" class="even">{{item.OutTime}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,8)" class="even">{{item.FinishPlanCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,9)" class="even">{{item.FutureCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,10)" class="even">{{item.FutureClientCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,11)" class="even">{{item.AvgFutureSee}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,12)" class="even">{{item.FutureSeeOldClient+"/"+item.FutureSeeNewClient}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,13)">{{item.TripSite?item.TripSite.split(',').length:""}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,14)">{{item.PeopleCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,15)">{{item.TripMonth?item.TripMonth.split(',').length:""}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,16)">{{item.OldClientEnquiry}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,17)" class="even">{{item.DownloadTrip}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,18)" class="even">{{(item.UsedApp/60).toFixed(1)}}小时</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,19)" class="even">{{(item.UsedErp/60).toFixed(1)}}小时</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,20)" class="even">{{item.UsedWe}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,21)">{{item.SevenDayOrder}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,22)">{{item.FifteenDayOrder}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,23)">{{item.MonthOrder}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,24)">{{item.OutMonthOrder}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,25)">{{item.SanCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,26)">{{item.DanCount}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,27)">{{item.IsSeeClient}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,28)">{{item.OldClientOrders}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,29)" class="even">{{item.BuilderAd}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,30)" class="even">{{item.AdToApp}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,31)" class="even">{{item.IncomeMoney}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,32)" class="even">{{item.Tousu}}</td>
              <td @mouseleave="outTable" @mouseover="activeTd(index,33)" class="even">{{item.SeeOldClient}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</template>
<script>
import dashboard from "./dashboard";
export default {
  components: {
    dashboard
  },
  props: {
    showClose: {
      type: Boolean,
      default: false
    },
    uid: {
      type: Number
    }
  },
  data() {
    return {
      choose1: ["每日数据", "每周数据", "每月数据", "每年数据"],
      index1: 1,
      isLoadingTableData: false,
      tableData:[],
      emp:{},
      zoom:1
    };
  },
  mounted() {
    this.zoom=parseFloat(document.body.offsetHeight)/969.00;
    this.zoom=this.zoom<0.8?0.8:this.zoom;
    this.$refs.mycareerContent.addEventListener(
      "scroll",
      this.handleScroll,
      true
    );
    this.getUserInfo()
    this.init();
  },
  methods: {
    handleScroll() {
      this.$refs.mycareerLeft.scrollTop = this.$refs.mycareerContent.scrollTop;
      this.$refs.mycareerHead.scrollLeft = this.$refs.mycareerContent.scrollLeft;
    },
    close() {
      this.$emit("close");
    },
    sort(){

    },
    getUserInfo(empId) {
      if (empId != 0) {
        this.apipost("user_post_get_usersixdetails", { 'empId':this.uid }, r => {
          this.emp = r.data.data
        });
      }
    },
    activeTd(row, col) {
      document.querySelectorAll(".mycareer .content-body table tr").forEach((x, r) => {
        x.querySelectorAll("td").forEach((y, i) => {
          y.className = y.className.replace(" hover", "");
          if (i == col && r != row) {
            y.className = y.className + " hover";
          }
        });
      });
    },
    outTable() {
      document.querySelectorAll(".content-body table tr").forEach((x, r) => {
        x.querySelectorAll("td").forEach((y, i) => {
          y.className = y.className.replace(" hover", "");
        });
      });
    },
    init() {
      this.isLoadingTableData = true;
      let msg = {
        timeRange: this.index1 + 1,
        empId:this.uid
      };
      this.apipost("user_post_get_usersixstatistics", msg, r => {
        (this.tableData = r.data.data), (this.isLoadingTableData = false);
      });
    },
    ClickChoose1(num) {
      if(!this.isLoadingTableData){
        let temp = this.index1;
        if (this.index1 == 0) {
          if (num > 0) {
            this.index1 = this.index1 + num;
          }
        } else if (this.index1 == this.choose1.length - 1) {
          if (num < 0) {
            this.index1 = this.index1 + num;
          }
        } else {
          this.index1 = this.index1 + num;
        }
        if (temp != this.index1) {
          this.init();
        }
      }
    }
  }
};
</script>

<style scoped>
.mycareer {
  height: 740px;
  width: 1027px;
  background: url("../../assets/img/champion/bg.png");
  position: relative;
  user-select: none;
  cursor: default;
}
.mycareer .close {
  position: absolute;
  top: 64px;
  right: 33px;
  width: 20px;
  height: 20px;
  background: url("../../assets/img/champion/close.png");
  cursor: pointer;
}
.mycareer .close:hover {
  background: url("../../assets/img/champion/close_before.png");
}
.mycareer .title {
  width: 554px;
  height: 69px;
  background: url("../../assets/img/champion/title.png");
  position: relative;
  z-index: 2;
  margin: 0 auto;
  display: flex;
}
.mycareer .title .star {
  position: absolute;
  top: 21px;
  left: 154px;
  width: 244px;
  height: 16px;
  background: url("../../assets/img/champion/star.png");
}
.mycareer .title .company-name {
  font-size: 18px;
  color: rgba(255, 255, 255, 1);
  background: linear-gradient(
    0deg,
    rgba(246, 134, 15, 1) 0%,
    rgba(253, 207, 52, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: pingfangR;
  margin-top: 17px;
  width: 154px;
  text-align: center;
}
.mycareer .title .uerf {
  flex: 1;
  margin-top: 12px;
}
.mycareer .title .uerf .dept-name {
  height: 12px;
  font-size: 12px;
  color: #ffffff;
  text-align: center;
  margin-bottom: 4px;
}
.mycareer .title .uerf .uer-name {
  background: linear-gradient(
    0deg,
    rgba(246, 134, 15, 1) 0%,
    rgba(253, 207, 52, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 24px;
  font-family: pingfangR;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  text-align: center;
}
.mycareer .title .post-name {
  width: 156px;
  text-align: center;
  margin-top: 17px;
  font-family: pingfangR;
  font-size: 18px;
  color: rgba(255, 255, 255, 1);
  background: linear-gradient(
    0deg,
    rgba(163, 169, 164, 1) 0%,
    rgba(255, 255, 255, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mycareer .uer-box {
  margin-top: 13px;
  display: flex;
}
.mycareer .uer-box .photo {
  margin-left: 81px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  position: relative;
}
.mycareer .uer-box .photo img {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  position: absolute;
  /* top: 5px;
  left: 5px; */
  z-index: 2;
}
.mycareer .uer-box .photo .zezhao {
  background: radial-gradient(
    circle,
    rgba(91, 52, 9, 0) 0%,
    rgba(0, 0, 0, 1) 74%
  );
  width: 230px;
  height: 230px;
  z-index: 1;
  position: absolute;
  top: 5px;
  left: 5px;
  border-radius: 50%;
  z-index: 3;
}
.mycareer .uer-box .photo .bottom {
  width: 177px;
  height: 63px;
  left: 33px;
  bottom: -29px;
  position: absolute;
  background: url("../../assets/img/champion/bottom.png");
  z-index: 1;
}
.mycareer .uer-box .my-score {
  margin-left: 38px;
}
.mycareer .uer-box .my-score .item {
  margin-top: 27px;
}
.mycareer .uer-box .my-score .item .k {
  font-family: pingfangR;
  font-size: 14px;
  color: rgba(255, 255, 255, 1);
  background: linear-gradient(
    0deg,
    rgba(163, 169, 164, 1) 0%,
    rgba(255, 255, 255, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mycareer .uer-box .my-score .item .v {
  font-family: pingfangR;
  font-size: 31px;
  color: rgba(255, 255, 255, 1);
  background: linear-gradient(
    0deg,
    rgba(246, 134, 15, 1) 0%,
    rgba(253, 207, 52, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mycareer .uer-box .my-score .item .v.white {
  background: linear-gradient(
    0deg,
    rgba(163, 169, 164, 1) 0%,
    rgba(255, 255, 255, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mycareer .uer-box .dashboards {
  margin-right: 50px;
  flex: 1;
  display: flex;
  margin-left: 60px;
  flex-wrap: wrap;
}
.mycareer .uer-box .dashboards .item {
  width: 120px;
  height: 120px;
  margin-right: 40px;
  margin-top: 25px;
}
.mycareer .split {
  margin: 10px 33px 0 32px;
  height: 27px;
  background: url("../../assets/img/champion/split.png");
}
.mycareer .change-box {
  width: 250px;
  margin: 5px auto;
  display: flex;
  margin-bottom: 0px;
}
.mycareer .change-box .btn {
  width: 35px;
  height: 22px;
  background: rgba(255, 179, 57, 1);
  opacity: 0.8;
  border-radius: 2px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 0 5px rgba(255, 179, 57, 0.8);
}
.mycareer .change-box .btn.dis {
  background: #333;
  cursor: no-drop;
  color: #ddd;
  box-shadow: 0 0 5px #333c;
}
.mycareer .change-box .option {
  flex: 1;
  text-align: center;
  color: #ffffff;
  font-size: 14px;
  font-family: pingfangR;
  height: 22px;
  line-height: 22px;
}
.mycareer .data-box {
  overflow: hidden;
  position: absolute;
  bottom: 39px;
  top: 433px;
  left: 33px;
  right: 33px;
  z-index: 2;
}
.mycareer .data-box .tab-head {
  height: 43px;
  overflow: hidden;
}
.mycareer .data-box .lft-head {
  left: -1px;
  top: 0;
  width: 100px;
  overflow: hidden;
  right: unset;
  height: 43px;
  position: absolute;
  background: url("../../assets/img/champion/head.png") no-repeat;
}
.mycareer .data-box .lft-body {
  left: -1px;
  top: 43px;
  width: 100px;
  bottom: 6px;
  right: unset;
  position: absolute;
  overflow: hidden;
  z-index: 3;
}
.mycareer .data-box .content-body {
  left: -1px;
  top: 43px;
  right: 0;
  bottom: 0px;
  position: absolute;
  overflow: auto;
  z-index: 2;
  margin: 0 2px;
}
.mycareer .data-box-before {
  display: block;
  position: absolute;
  z-index: 1;
  background: url("../../assets/img/champion/head.png") no-repeat;
  height: 43px;
  content: " ";
  top: 433px;
  left: 33px;
  right: 33px;
}
.mycareer .data-box table {
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
}
.mycareer .data-box table thead th {
  height: 43px;
  padding-top: 10px;
  box-sizing: border-box;
  text-align: left;
  padding-left: 10px;
  font-size: 14px;
  font-family: pingfangR;
  color: rgba(255, 168, 53, 1);
  min-width: 80px;

  background: linear-gradient(
    0deg,
    rgba(163, 169, 164, 1) 0%,
    rgba(255, 255, 255, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mycareer .data-box table thead th {
  min-width: 105px;
  max-width: 105px;
}
.mycareer .data-box table tbody td {
  height: 30px;
  line-height: 30px;
  font-size: 12px;
  color: #FFF;
  text-align: left;
  padding-left: 10px;
  min-width: 105px;
  max-width: 105px;
}
.mycareer .data-box table tbody td.odd {
  background: #1d160b;
  color: #fff;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  min-width: 100px;
  max-width: 100px;
}
.mycareer .content-body table tr:hover td,
.mycareer .content-body table tr:hover td.even {
  background: #1d160bdd;
  color: #fff;
}
.mycareer .content-body table td.hover {
  background: #1d160bdd !important;
  color: #fff !important;
}
.mycareer .content-body table td:hover {
  background: #E3e3e3 !important;
  color: #1d160b !important;
}
.mycareer .content-body table td.even{
  background: hsla(41, 63%, 38%, 0.212);
}
.mycareer .data-box .content-body::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 5px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 5px;
  border: 1px solid rgba(161, 154, 147, 1);
  border-radius: 5px;
  background: transparent;
  padding: 2px;
}
.mycareer .data-box .content-body::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  height: 4px;
  width: 4px;
  background: rgba(222, 186, 102, 1);
  border-radius: 5px;
}
.mycareer .data-box .content-body::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  background: transparent;
}
.mycareer .data-box .content-body::-webkit-scrollbar-corner {
  color: transparent;
}

</style>