<script setup lang="ts">
import DataCard from "@/views/dashboard/components/DataCard.vue";
import LiquidChart from "@/views/charts-components/LiquidChart.vue";
import CircleChart from "@/views/charts-components/CircleChart.vue";
import PercentBarChart from "@/views/charts-components/PercentBarChart.vue";
defineOptions({
  // eslint-disable-next-line vue/no-reserved-component-names
  name: "DashboardIndex",
  inheritAttrs: false,
});
// import { getClassList, getSchoolList } from "@/api/school";
import { ClassList, SchoolList } from "@/api/school/types";
import { watch } from "vue";
import { useUserStore } from "@/store/modules/user";
import { CaretBottom } from "@element-plus/icons-vue";
const userStore = useUserStore();
watch(
  () => userStore.schoolId,
  (newValue, oldValue) => {
    console.log("userStore.schoolId", newValue, oldValue);
    // 学校切换后重新加载数据
  }
);
/**
 * 数据卡片
 */
// 全部班级
const classCount = 3000;
// 全部教师
const teacherCount = 5000;
// 全部学生
const studentCount = 6000;
// 设备套数
const equipmentCount = 50;
// 累计训练次数
const trainingCount = 2000;
/**
 * 班级数据
 */
// 班级编号
let classNumber = ref(0);
const classData = ref<ClassList[]>([
  {
    id: 0,
    school_id: 0,
    name: "全部班级",
  },
]);
// function queryClassList() {
// 	getClassList().then(({ data }) => {
//		classData.value.concat(data);
// 	});
// }
watch(
  () => classNumber,
  (newValue, oldValue) => {
    console.log("userStore.schoolId", newValue, oldValue);
    // 班级切换后重新加载班级数据
  }
);
// 数据状态：1正常，2训练次数小于3，3过期，4缺省
const dataStatus = ref(1);
onMounted(() => {
  //queryClassList();
});


const percentData = [5,5,65,10,10];
const percentNumber = [1,2,13,2,2];
</script>

<template>
  <div class="dashboard-container">
    <!-- 数据卡片 -->
    <DataCard
      :classes="classCount"
      :teachers="teacherCount"
      :students="studentCount"
      :equipments="equipmentCount"
      :trainings="trainingCount"
    />

    <!-- 班级选择 及 案例展示 -->
    <div class="class-select clear">
      <el-select
        v-model="classNumber"
        placeholder="全部班级"
        size="large"
        :suffix-icon="CaretBottom"
      >
        <el-option
          v-for="item in classData"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>
      <router-link to="/dashboard/example">优秀教学效果示例</router-link>
    </div>

    <!-- Echarts 图表 -->
    <el-row v-if="dataStatus == 1" :gutter="20">
      <el-col :md="24" :lg="12" :xl="8">
        <div class="charts-item">
          <p class="title">学员专注力平均值整体对比分析</p>
          <el-row justify="space-between">
            <el-col :xs="24" :sm="12">
              <div class="item">
                <LiquidChart
                  id="liquidChart1"
                  data="37.5"
                  height="200px"
                  width="200px"
                  color="#3a7fc2"
                  bg-color="#accded"
                  class="chart"
                />
                <p>全体学员初期</p>
                <p>专注力评估均值</p>
              </div>
            </el-col>
            <el-col :xs="24" :sm="12">
              <div class="item">
                <LiquidChart
                  id="liquidChart2"
                  data="57.6"
                  height="200px"
                  width="200px"
                  color="#5563ac"
                  bg-color="#cacce6"
                  class="chart"
                />
                <p>全体学员训练近期</p>
                <p>专注力评估均值</p>
              </div>
            </el-col>
          </el-row>
          <el-row justify="space-between">
            <el-col :xs="24" :sm="12">
              <div class="item">
                <CircleChart
                  id="circleChart1"
                  data="37.5"
                  height="200px"
                  width="200px"
                  color="#3a7fc2"
                  bg-color="#e4e7f4"
                  font-color="#3a7fc2"
                  font-size="30"
                  round-cap="true"
                />
                <p>初期训练</p>
                <p>专注力50以上人数比例</p>
              </div>
            </el-col>
            <el-col :xs="24" :sm="12">
              <div class="item">
                <CircleChart
                  id="circleChart2"
                  data="57.6"
                  height="200px"
                  width="200px"
                  color="#5563ac"
                  bg-color="#e4e7f4"
                  font-color="#5563ac"
                  font-size="30"
                  round-cap="true"
                />
                <p>近期训练</p>
                <p>专注力50以上人数比例</p>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <!-- 学员专注力评分分级占比分析 -->
      <el-col :md="24" :lg="12" :xl="16">
        <div class="charts-item">
          <p class="title">学员专注力评分分级占比分析</p>
          <el-row justify="space-between">
            <el-col :xs="24" :sm="24" :md="12" :lg="24" :xl="12">
              <div class="bar">
                <PercentBarChart
                  id="barChart1"
                  width="400px"
                  height="500px"
                  title="全体学员初期训练专注力评分占比"
                  :percent="percentData"
                  :data="percentNumber"
                  class="chart"
                />
              </div>
            </el-col>
            <el-col :xs="24" :sm="24" :md="12" :lg="24" :xl="12">
              <div class="bar">
                <PercentBarChart
                  id="barChart2"
                  width="400px"
                  height="500px"
                  title="全体学员训练近期专注力评分平均占比"
									:percent="percentData"
									:data="percentNumber"
                  class="chart"
                />
              </div>
            </el-col>
          </el-row>
        </div>
      </el-col>
    </el-row>
    <el-row v-else :gutter="20">
      <el-col :md="24" :lg="8">
        <div class="charts-item">
          <p class="title">学员专注力平均值整体对比分析</p>
          <div v-if="dataStatus == 2" class="empty">
            <p>筛选条件的学生人群训练3次以上才能进行训练数据分析，</p>
            <p>当前训练数据不足以进行数据分析！</p>
          </div>
          <div v-if="dataStatus == 3" class="empty">
            <p class="red">合作已过期，无法进行数据看板的查看！</p>
          </div>
          <div v-if="dataStatus == 4" class="empty">
            <p>您的学校还没有任何训练数据！</p>
          </div>
        </div>
      </el-col>
      <el-col :md="24" :lg="16">
        <div class="charts-item">
          <p class="title">学员专注力评分分级占比分析</p>
          <div v-if="dataStatus == 2" class="empty">
            <p>筛选条件的学生人群训练3次以上才能进行训练数据分析，</p>
            <p>当前训练数据不足以进行数据分析！</p>
          </div>
          <div v-if="dataStatus == 3" class="empty">
            <p class="red">合作已过期，无法进行数据看板的查看！</p>
          </div>
          <div v-if="dataStatus == 4" class="empty">
            <p>您的学校还没有任何训练数据！</p>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<style lang="scss" scoped>
.dashboard-container {
  position: relative;
  padding: 30px;
}
.class-select {
  margin: 30px auto;
  .el-select {
    width: 160px;
    margin: 0 20px 0 0;
  }
  a {
    display: inline-block;
    height: 38px;
    line-height: 38px;
    padding: 0 30px;
    background: #4284f2;
    border-radius: 12px;
    color: #ffffff;
  }
}
/* 自定义 el-select 样式 */
:deep(.el-input__wrapper) {
  background: #ffffff;
  border-radius: 12px;
}

/* el-select 各种边框线隐藏**/
:deep(.el-select) {
  --el-select-input-focus-border-color: none !important;
}
:deep(.el-input__wrapper) {
  box-shadow: none !important;
}
:deep(.el-select .el-input__wrapper.is-focus) {
  box-shadow: none !important;
}
:deep(.el-select:hover:not(.el-select--disabled) .el-input__wrapper) {
  box-shadow: none !important;
}

.charts-item {
  background: #ffffff;
  border: 1px solid #e8eaec;
  border-radius: 24px;
  text-align: center;
  position: relative;
  .title {
    margin: 0;
    height: 78px;
    line-height: 78px;
    text-align: left;
    text-indent: 2em;
    font-size: 18px;
  }
  .item {
    padding-bottom: 30px;
  }
  .chart {
    margin: 0 auto;
  }
  p {
    margin: 0;
    line-height: 24px;
    font-size: 16px;
  }
  .bar {
    margin-top: 60px;
  }
  .empty {
    box-sizing: border-box;
    height: 400px;
    padding-top: 200px;
    text-align: center;
    background-image: url("../../assets/empty.png");
    background-repeat: no-repeat;
    background-position: center 30%;
    p {
      font-size: 14px;
      color: #a1a1a1;
      &.red {
        color: #e04962;
      }
    }
  }
}
</style>
