<template>
  <!-- <div class="dashboard-editor-container">

    <el-row :gutter="40" class="panel-group">
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="peoples" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">会员数量</div>
            <count-to :start-val="0" :end-val="userTotal" :duration="2600" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('product')">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="product" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">服务者</div>
            <count-to :start-val="0" :end-val="goodsTotal" :duration="3000" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('star')">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="star" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">客户</div>
            <count-to :start-val="0" :end-val="starTotal" :duration="3200" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shopping')">
          <div class="card-panel-icon-wrapper icon-shoppingCard">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">订单数量</div>
            <count-to :start-val="0" :end-val="orderTotal" :duration="3600" class="card-panel-num" />
          </div>
        </div>
      </el-col>
    </el-row>
    <div class="app-container">
      <ve-line :extend="chartExtend" :data="chartData" :settings="chartSettings" />
    </div>

  </div>-->
  <div class="dashboard-editor-container">
    <!-- <p>首页</p> -->
    <!-- 顶部信息 -->
    <div class="user-about">
      <div class="user-left">
        <img :src="avatarUrl" alt class="user-avatar" />
        <!-- <p class="user-detail">kiri|客户服务部-售前客服部-客服专员</p> -->
        <p class="user-detail">{{userName}}</p>
      </div>
      <div class="user-right">
        <div class="total-item">
          <span>我的任务</span>
          <span class="total-num">{{indexData.myBuild}}</span>
        </div>
        <div class="divide-line"></div>
        <div class="total-item">
          <span>我的工单</span>
          <span class="total-num">{{indexData.myTicket}}</span>
        </div>
        <div class="divide-line"></div>
        <div class="total-item">
          <span>全部工单</span>
          <span class="total-num">{{indexData.all}}</span>
        </div>
      </div>
    </div>
    <div class="main-wrapper">
      <div class="main-data">
        <!-- 待完成的任务 -->

        <div class="task-head">
          <span>待完成的任务</span>
          <el-button type="text" @click="goTotalTask">全部任务</el-button>
        </div>

        <el-row :gutter="40" class="panel-group">
          <el-col :xs="8" :sm="8" :lg="8" class="card-panel-col" v-for="(item,index) in indexData.jzBuiltListCounts" :key="index" >
            <div class="card-panel"  @click="goTotalTask" >
              <p class="card-title">
                <i class="el-icon-postcard"></i>
                <span>{{item.name}}</span>
              </p>
              <p class="card-describe">{{item.desc}}</p>
              <div class="card-data">
                <count-to
                  :start-val="0"
                  :end-val="item.count"
                  :duration="1500"
                  class="card-panel-num"
                />
              </div>
            </div>
          </el-col>

        </el-row>
        <!-- 待完成的工单 -->
        <div class="ticket-head">
          <span>待完结的工单</span>
          <el-button type="text" @click="goTotalTicket">全部工单</el-button>
        </div>
        <el-row :gutter="40" class="panel-group ticket-block">
          <el-col :xs="8" :sm="8" :lg="8" class="card-panel-col">
            <div class="card-panel"  @click="goTicketHandle('2')">
              <p class="card-title">
                <i class="el-icon-s-claim"></i>
                <span>工单进行时间>24小时</span>
              </p>
              <p class="card-describe">待完结总量</p>
              <div class="card-data">
                <count-to
                  :start-val="0"
                  :end-val="indexData.moreThan24"
                  :duration="1500"
                  class="card-panel-num"
                />
              </div>
              <div class="link-block" >去看看</div>
            </div>
          </el-col>
          <el-col :xs="8" :sm="8" :lg="8" class="card-panel-col">
            <div class="card-panel" @click="goTicketHandle('3')">
              <p class="card-title">
                <i class="el-icon-s-claim"></i>
                <span>工单进行时间>48小时</span>
              </p>
              <p class="card-describe">待完结总量</p>
              <div class="card-data">
                <count-to
                  :start-val="0"
                  :end-val="indexData.moreThan24"
                  :duration="1500"
                  class="card-panel-num"
                />
              </div>
              <div class="link-block" >去看看</div>
            </div>
          </el-col>
          <el-col :xs="8" :sm="8" :lg="8" class="card-panel-col">
            <div class="card-panel"  @click="goTicketHandle('5')">
              <p class="card-title">
                <i class="el-icon-s-claim"></i>
                <span>工单进行中</span>
              </p>
              <p class="card-describe">待完成任务总量</p>
              <div class="card-data">
                <count-to
                  :start-val="0"
                  :end-val="indexData.processing"
                  :duration="1500"
                  class="card-panel-num"
                />
              </div>
              <div class="link-block" >去看看</div>
            </div>
          </el-col>
        </el-row>
      </div>
      <!-- 定时提醒 -->
      <div class="timing-remind">
        <p class="remind-title">
          <span>定时提醒</span>
          <i class="el-icon-time" />
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import { info } from "@/api/dashboard";
import CountTo from "vue-count-to";
import { statOrder } from "@/api/stat";
import panelApi from "@/api/panel";
import VeLine from "v-charts/lib/line";

export default {
  components: {
    CountTo,
    VeLine
  },
  data() {
    return {
      avatarUrl: require("../../assets/image/logo.png"),
      userName: "",
      userTotal: 0,
      goodsTotal: 42,
      starTotal: 0,
      orderTotal: 0,
      chartData: {},
      chartSettings: {},
      chartExtend: {},
      indexData: {
        all: 0, //全部工单
        myBuild: 0, //我的任务
        myTicket: 0, //我的工单
        moreThan24: 0,
        moreThan48: 0,
        processing: 0,
        jzBuiltListCounts: []
      }
    };
  },
  created() {
    console.log(this.$store.state.user);
    if (this.isEmptyObjVue(this.$store.state.user.avatar) == false) {
      this.avatarUrl = this.$store.state.user.avatar;
    }
    this.userName = this.$store.state.user.name;
    this.initIndexData();

    // info().then(response => {
    //   this.userTotal = response.data.data.userTotal;
    //   this.goodsTotal = response.data.data.goodsTotal;
    //   this.starTotal = response.data.data.starTotal;
    //   this.orderTotal = response.data.data.orderTotal;
    // });

    // statOrder().then(response => {
    //   this.chartData = response.data.data;
    //   this.chartSettings = {
    //     labelMap: {
    //       orders: "订单量",
    //       customers: "下单用户",
    //       amount: "订单总额",
    //       pcr: "客单价"
    //     }
    //   };
    //   this.chartExtend = {
    //     xAxis: { boundaryGap: true }
    //   };
    // });
  },

  methods: {
    initIndexData() {
      panelApi
        .getIndexData()
        .then(res => {
          console.log(res.data);
          this.indexData=res.data.data;
        })
        .catch(error => {
          console.log(error);
        });
    },
    handleSetLineChartData(type) {
      this.$emit("handleSetLineChartData", type);
    },
    goTotalTask() {
      this.$router.push({
        path: "/callcenter/callcenter",
        query: {}
      });
    },
    goTotalTicket() {
      this.$router.push({
        path: "/ticket/ticketEntry",
        query: {}
      });
    },
goTicketHandle(index){
   this.$router.push({
        path: "/ticket/ticketHandle",
        query: {
          activeIndex:index
        }
      });
}


  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  // background-color: rgb(240, 242, 245);
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }
  .card-panel {
    min-height: 130px;
    border-radius: 6px;
    padding: 10px 10px 30px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    // box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.05);
    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
      .icon-people {
        background: #40c9c6;
      }
      .icon-message {
        background: #36a3f7;
      }
      .icon-money {
        background: #f4516c;
      }
      .icon-shoppingCard {
        background: #34bfa3;
      }
    }
    .icon-people {
      color: #40c9c6;
    }
    .icon-message {
      color: #36a3f7;
    }
    .icon-money {
      color: #f4516c;
    }
    .icon-shoppingCard {
      color: #34bfa3;
    }
    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }
    .card-panel-icon {
      float: left;
      font-size: 48px;
    }
    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;
      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }
      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}
.user-about {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 120px;
  max-width: 1200px;
    min-width: 800px;
  .user-left {
    display: flex;
    align-items: flex-end;
    color: #777;
  }
  .user-avatar {
    width: 100px;
    height: 100px;
    border-radius: 100px;
    overflow: hidden;
    object-fit: contain;
  }
  .user-right {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    .total-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      height: 60px;
      color: #777;
      .total-num {
        font-size: 22px;
        color: #111;
      }
    }
    .divide-line {
      height: 50px;
      width: 1px;
      background: #eee;
      margin: 40px;
    }
  }
}
.ticket-head,
.task-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}
.main-wrapper {
  display: flex;
  justify-content: space-between;
  margin: 30px 0 0;
}
.main-data {
  flex: 1;
  max-width: 1200px;
  min-width: 800px;
}
.timing-remind {
  display:none;
  width: 300px;
  margin-left: 40px;
  padding: 20px 0 0;
  // visibility: hidden;
  .remind-title {
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ddd;
    i {
      font-weight: bold;
      margin-left: 8px;
      font-size: 18px;
    }
  }
}
.card-title {
  display: flex;
  align-items: center;
  font-weight: bold;
  font-size: 16px;
  color: #333;
}
.card-title i {
  font-size: 30px;
  color: #36a3f7;
  margin-right: 10px;
}
.card-data {
  text-align: right;
  color: #36a3f7;
  font-size: 16px;
  padding-right: 20px;
}
.link-block {
  height: 40px;
  line-height: 40px;
  border-top: 1px dashed #ccc;
  text-align: center;
  margin-top: 10px;
  color: #36a3f7;
}
.panel-group.ticket-block .card-data {
  text-align: center;
  color: #333;
  padding-right: 0;
}
.panel-group.ticket-block .card-panel {
  padding-bottom: 0;
  cursor: pointer;
}


.panel-group.ticket-block .card-describe {
  // text-align: center;
}
</style>
