
<style>
.job {
  height: calc(100% - 25px);
}
.statistics-title {
  font-size: 24px;
  color: #111;
  margin-bottom: 30px;
  font-family: perfectFont;
}
.job .conten-box {
  display: flex;
  flex-direction: column;
  height: calc(100% - 62px);
}
.job .conten-box .el-card .el-card__header {
  font-weight: normal !important;
}
.job .conten-box .top {
  flex: 1.2;
  margin-bottom: 25px;
}
.job .conten-box .bottom {
  flex: 0.8;
}
.job .conten-box .left {
  height: 100%;
}
.job .conten-box .el-card.blue {
  background: #409efe !important;
  color: #fff !important;
  height: calc(100% - 2px);
}
.job .conten-box .el-card .el-card__body {
  padding: 20px;
  height: calc(100% - 98px);
  max-height: calc(100% - 98px);
}
.job .conten-box .img {
  display: flex;
  align-items: flex-end;
  text-align: center;
  padding: 27px 0 0 90px !important;
  justify-content: center;
  font-size: 14px;
}
.job .sjsm {
  height: 198px;
  overflow: auto;
}
.job .sjsm > div {
  margin-bottom: 20px;
}
.job .sjsm > div:last-child {
  margin-bottom: 0px;
}
.job .sjsm > div {
  flex: 1;
  background: rgba(244, 245, 249, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}
.job .sjsm > div .left {
  display: flex;
  align-items: center;
}
.job .sjsm > div .left img {
  padding-right: 10px;
}
.job .sjsm > div .right {
  text-align: right;
  color: #888888;
  font-size: 12px;
}
.job .hight-font {
  color: #409efe !important;
  font-size: 14px;
}
</style>
<template>
  <div class="job" v-loading="loading">
    <div class="statistics-title bold18">职业类型统计</div>
    <div class="conten-box" v-if="!loading">
      <el-row :gutter="25" class="top">
        <el-col :span="24" class="left">
          <el-card class="blue">
            <div slot="header" class="clearfix">
              <span>订单统计</span>
            </div>
            <el-row :gutter="80" style="height: 100%;">
              <el-col :span="6" class="img">
                <div>
                  <div style="margin-bottom: 10px;">
                    <img src="../../assets/img/tongji/qinzi.png" alt />
                  </div>
                  <p>教育</p>
                </div>
              </el-col>
              <el-col :span="18" style="height: 100%;">
                <sexChart :myData="chartData" :strArr="strArr" />
              </el-col>
            </el-row>
          </el-card>
        </el-col>
      </el-row>
      <el-row :gutter="25" class="bottom">
        <el-col :span="12" style="height: 100%;">
          <el-card style="height: 100%;">
            <div slot="header" class="clearfix">
              <span>数据说明</span>
            </div>
            <div class="sjsm">
              <div v-for="(item, index) in orders" :key="index">
                <div class="left">
                  <img v-if="index==0" src="../../assets/img/tongji/qinzhi.png" alt />
                  <img v-else-if="index==1" src="../../assets/img/tongji/miyue.png" alt />
                  <img v-else-if="index==2" src="../../assets/img/tongji/in3.png" alt />
                  <img v-else-if="index==3" src="../../assets/img/tongji/d1.png" alt />
                  <img v-else-if="index==4" src="../../assets/img/tongji/hanjia.png" alt />
                  <img v-else src="../../assets/img/tongji/qinzhi.png" alt />
                  <span class="font-size-12">{{item.DutyTypeName}}</span>
                </div>
                <div class="right">
                  <p>
                    累计报名
                    <span class="hight-font">{{item.OrderCount}}</span>人，报名均价为
                    <span class="hight-font">{{item.Unit_Price}}</span>元
                  </p>
                  <!-- 关联购物金额<span class="hight-font">{{item.ShopMoney}}</span>万， -->
                  <p>
                    最喜爱产品
                    <span class="hight-font">《{{item.LtName}}》</span>
                  </p>
                </div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="12" style="height: 100%;">
          <el-card style="height: 100%;">
            <div slot="header" class="clearfix">
              <el-row style="width:100%">
                <el-col :span="12" size="30">推荐解答</el-col>
                <el-col :span="12" class="right-title">
                  <i class="iconfont icondianzan1"></i> 点赞
                </el-col>
              </el-row>
            </div>
            <div class="situ">
              <div class="c">{{topOne && topOne.Content ? topOne.Content : '暂无'}}</div>
                <div class="bot"  @click="drawer = true">
                  {{BbsList.length ? '查看更多，参与讨论('+ BbsList.length +')' : '暂时还没有讨论，快来发起讨论吧~'}}
                  <i class="el-icon-d-arrow-right"></i>
                </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <el-drawer size="695px" :visible.sync="drawer" direction="rtl" :with-header="false">
      <discussBox :type="discussID" />
    </el-drawer>
  </div>
</template>
<script>
import sexChart from "./model/sexChart";
import shopChart from "./model/shopChart";
import discussBox from "./model/discussBox";
export default {
  components: {
    sexChart,
    shopChart,
    discussBox,
  },
  data() {
    return {
      orders: [],
      discussID: 0,
      drawer: false,
      chartData: [],
      shopChartData: [],
      SexOrder: [],
      loading: false,
      strArr: ["娱乐", "教育", "服务"],
      discussID: 13,
      BbsList: [],
      topOne: {},
    };
  },
  watch: {},
  mounted() {
    this.GetSexOrderList();
    this.GetBbsListByType();
  },
  methods: {
    GetBbsListByType() {
      this.apipost(
        "/api/Customer/GetBbsListByType",
        { t: this.discussID },
        (res) => {
          this.BbsList = res.data.data;

          if (this.BbsList && this.BbsList.length > 0) {
            this.topOne = this.BbsList[0];
            this.BbsList.forEach((x) => {
              if (x.Likes > this.topOne.Likes) {
                this.topOne = x;
              }
            });
          }
        }
      );
    },
    GetSexOrderList() {
      this.loading = true;
      this.apipost("/api/Statistic/GetDutyTypeOrderList", {}, (res) => {
        this.loading = false;
        if (res.data.resultCode == 1) {
          this.strArr = [];
          let data = res.data.data;
          var totalOrder = 0;
          var totalMoney = 0;
          data.forEach((item) => {
            this.strArr.push(item.DutyTypeName);
            totalOrder += item.OrderCount;
            totalMoney += item.ShopMoney;
          });
          data.forEach((item) => {
            this.chartData.push(
              ((item.OrderCount / totalOrder) * 100).toFixed(2)
            );
          });
          this.orders = res.data.data;
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
  },
};
</script>
