<template>
  <div class="content-box">
    <div class="pageIndex" v-if="pageIndex == 1">
      <div class="left">
        <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
        <span class="cameratxt">教师综合素质评价</span>
      </div>
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <el-input
              :clearable="true"
              @clear="searchBtn"
              v-model.trim="searchInput.keyWord"
              class="sel"
              placeholder="请输入教师姓名或学工号"
            /><el-button
              color="rgba(0, 97, 255, 1)"
              type="primary"
              class="search"
              @click="searchBtn"
              >查询</el-button
            >
          </div>
          <div class="condition">
            <span class="title">学期 :</span>
            <el-select
              v-model="searchInput.semester"
              class="sel"
              placeholder="请选择学期"
              style="width: 250px"
              @change="searchBtn"
              :clearable="true"
            >
              <el-option
                :label="i.name"
                :value="i.name"
                v-for="i in semesterData"
              />
            </el-select>
          </div>

          <div class="condition">
            <span class="title">年级 :</span>
            <el-select
              v-model="searchInput.grade"
              placeholder="请选择年级"
              style="width: 160px"
              @change="yearClassChange"
              :clearable="true"
            >
              <el-option
                v-for="i in gradeData"
                :label="i.name"
                :value="`${i.name}-${i.id}`"
              >
              </el-option>
            </el-select>
          </div>
          <div class="condition">
            <span class="title">班级 :</span>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="请先选择年级"
              placement="top"
            >
              <el-select
                v-model="searchInput.class"
                placeholder="请选择班级"
                style="width: 160px"
                @change="searchBtn"
                :clearable="true"
              >
                <el-option
                  v-for="i in classsData"
                  :label="i.name"
                  :value="i.name"
                />
              </el-select>
            </el-tooltip>
          </div>
          <!-- <div class="condition">
            <span class="title">教学学科 :</span>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="请先选择年级"
              placement="top"
            >
              <el-select
                v-model="searchInput.subject"
                class="sel"
                placeholder="请选择学科"
                style="width: 160px"
                @change="searchBtn"
                :clearable="true"
              >
                <el-option
                  v-for="i in subjectData"
                  :label="i.name"
                  :value="i.name"
                /> </el-select
            ></el-tooltip>
          </div> -->
        </div>
        <!-- 按钮列表 -->
        <div class="gongneng">
          <el-button
            type="primary"
            color="rgba(0, 97, 255, 1)"
            plain
            @click="scoringItemsClick"
            >评分项管理</el-button
          >
          <el-button
            type="primary"
            color="rgba(0, 97, 255, 1)"
            @click="updateClick"
            plain
            >更新</el-button
          >
          <el-button
            type="primary"
            color="rgba(0, 97, 255, 1)"
            plain
            @click="importExcel"
            >导出</el-button
          >
        </div>
      </div>
      <div class="scroll">
        <div class="footer" v-loading="loading">
          <el-table
            :row-class-name="tableRowClassName"
            :data="tableData.list"
            @selection-change="handleSelectionChange"
            style="width: 100%"
            :header-cell-style="{
              background: 'rgba(240, 243, 247, 1)',
              height: '50px',
              border: 0,
            }"
          >
            <!-- <el-table-column align="center" type="selection" width="80" /> -->
            <el-table-column
              align="center"
              prop="term"
              width="200"
              label="学期"
            />
            <el-table-column
              align="center"
              prop="gradeName"
              width="100"
              label="年级"
            />
            <el-table-column align="center" prop="name" label="教师姓名">
              <template #default="scope">
                <span class="normal" @click="teacherInfoClick(scope.row)">{{
                  scope.row.name
                }}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="cardNo" label="职工号" />
            <el-table-column align="center" prop="className" label="带教班级" />
            <el-table-column
              align="center"
              prop="lowingScore"
              label="“扣分”评分"
            />
            <el-table-column
              align="center"
              prop="totalScore"
              label="最终评分"
            />
            <!-- <el-table-column align="center" prop="status" label="教学学科">
            <template #default="scope">
              <span class="normal">正常</span>
            </template>
          </el-table-column> -->
            <el-table-column align="center" label="操作">
              <template #default="scope">
                <div class="edit">
                  <div class="look" @click="goScore(scope.row)">去评分</div>
                  <!-- <el-popconfirm
                  width="220"
                  confirm-button-text="确认"
                  cancel-button-text="取消"
                  :icon="InfoFilled"
                  icon-color="#f89626"
                  title="是否删除此房型?"
                  @confirm="del(scope.row)"
                  @cancel="cancelEvent"
                >
                  <template #reference>
                    <div class="del">删除</div>
                  </template>
                </el-popconfirm> -->
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <!-- 分页组件 -->
        <div class="pageSize">
          <span></span>
          <el-pagination
            background
            :current-page="currentPage"
            :page-size="pageSize"
            layout="total, prev, pager, next, jumper, slot"
            :total="total"
            @update:current-page="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <div v-if="pageIndex == 2" class="teacherInfo">
      <div class="left">
        <img
          src="@/assets/images/close.png"
          alt=""
          @click="teacherInfoConcel"
        />
        <span class="cameratxt">教师综合素质评价/详情</span>
      </div>
      <div class="scroll_score">
        <div class="semester">
          <div class="title">{{ teacherRowInfo.term }}</div>
          <div class="score">
            <div class="score_left">
              <div v-viewer>
                <img :src="teacherRowInfo.headImage" alt="" />
              </div>
              <div class="info">
                <div class="info_name">{{ teacherRowInfo.name }}</div>
                <div class="info_object">
                  教学学科:
                  {{ teacherRowInfo.subject }}&nbsp;&nbsp;&nbsp;职工号:
                  {{ teacherRowInfo.cardNo }}
                </div>
                <div class="info_object">
                  所带班级: {{ teacherRowInfo.className }}
                </div>
              </div>
            </div>
            <div class="score_right">
              <span class="num">{{ teacherRowInfo.totalScore }}</span
              >分
            </div>
          </div>
        </div>
        <div class="scoreList">
          <div class="title">
            <img src="@/assets/images/basicInfo.png" alt="" />
            <span>评分列表</span>
            <el-button
              color="rgba(0, 97, 255, 1)"
              type="primary"
              class="goScore"
              @click="goScore({ id: teacherRowInfo.id })"
              >去评分</el-button
            >
          </div>
          <div class="table">
            <div class="items" v-for="item in teacherList">
              <div class="txt scoreItem">
                {{ `${item.scoreItem}(${item.scoreNum})` }}
              </div>
              <div class="items_li">
                <div class="lis" v-for="i in item.evaluateList">
                  <div class="li">
                    <div class="txt">{{ `${i.scoreItem}(${i.scoreNum})` }}</div>
                    <div class="txt">{{ i.ownNum }}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="score_footer">
          <div class="footer_left">
            <div class="title">
              <img src="@/assets/images/basicInfo.png" alt="" />
              <span>评分对比</span>
            </div>
            <div id="scoreEcharts"></div>
          </div>
          <div class="footer_right">
            <div class="title">
              <div class="title_ranking">
                <img src="@/assets/images/basicInfo.png" alt="" />
                <span>评分排行榜</span>
              </div>
              <!-- <el-select
                v-model="rankInput"
                class="m-2"
                placeholder="请选择学科"
                @change="rankSel"
              >
                <el-option label="全部" value="全部" />
                <el-option
                  v-for="i in teacherComparison.name"
                  :label="i"
                  :value="i"
                />
              </el-select> -->
            </div>
            <el-table
              :row-class-name="tableRowClassName"
              :data="rankData"
              :header-cell-style="{
                background: 'rgba(240, 243, 247, 1)',
                height: '40px',
                border: 0,
              }"
            >
              <el-table-column
                align="center"
                type="index"
                width="100"
                label="排名"
              />
              <el-table-column align="center" prop="name" label="姓名" />
              <!-- <el-table-column align="center" prop="status" label="教学学科" /> -->
              <el-table-column
                align="center"
                prop="totalScore"
                label="最终得分"
              />
            </el-table>
          </div>
        </div>
      </div>
    </div>
    <!-- 去评分按钮 -->
    <el-dialog
      class="scoreDialog"
      v-model="scoreVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="评分"
      align-center
      width="1150"
      :before-close="cancelScore"
    >
      <div class="table">
        <div class="items" v-for="item in scoreData.list">
          <div class="txt scoreItem">
            {{ `${item.scoreItem}(${item.scoreNum})` }}
          </div>
          <div class="items_li">
            <div class="lis" v-for="i in item.evaluateList">
              <div class="li">
                <div class="txt">{{ `${i.scoreItem}(${i.scoreNum})` }}</div>
                <div class="txt">
                  <el-input
                    style="width: 110px"
                    v-model="i.ownNum"
                    placeholder=""
                    @blur="goScoreChange($event, item)"
                  />
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="items">
          <div class="txt scoreItem">扣分项</div>
          <div class="items_li">
            <div class="lis">
              <div class="li">
                <div class="txt">总扣分</div>
                <div class="txt">{{ lowingScore }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="options">
        <el-button
          color="rgba(41, 109, 227, 1)"
          class="queding"
          type="primary"
          @click="confirmGoScore"
        >
          确认
        </el-button>
        <el-button @click="cancelScore">取消</el-button>
      </div>
    </el-dialog>

    <!-- 评分项管理 -->
    <el-dialog
      class="scoringItems"
      v-model="scoringItemsVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="评分项管理"
      align-center
      width="1200"
      :before-close="cancelScoringItems"
    >
      <div class="btn">
        <el-button
          type="primary"
          color="rgba(0, 97, 255, 1)"
          plain
          @click="bigItemClick"
          >添加项</el-button
        >
      </div>
      <div class="btn">
        <span
          class="semester"
          :class="item.name == semesterName ? 'semester_active' : ''"
          v-for="item in semesterData"
          @click="getAllData(item)"
        >
          {{ item.name }}
        </span>
      </div>
      <div :key="resetTableIndex">
        <el-table
          ref="resetTable"
          :row-class-name="tableRowClassName"
          :data="scoringItemsData.list"
          :span-method="objectSpanMethod"
          :header-cell-style="{
            background: 'rgba(240, 243, 247, 1)',
            height: '50px',
          }"
        >
          <el-table-column fixed align="center" prop="scoreItem" label="评分项">
            <template #default="scope">
              <span>{{ scope.row.scoreItem }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="scoreItem_li" label="评分子项">
            <template #default="scope">
              <span>{{ scope.row.scoreItem_li }}</span>
            </template></el-table-column
          >
          <el-table-column align="center" prop="scoreNum" label="分值"
            ><template #default="scope">
              <span>{{ scope.row.scoreNum }}</span>
            </template></el-table-column
          >
          <el-table-column align="center" label="操作">
            <template #default="scope">
              <div class="edit">
                <el-popconfirm
                  width="220"
                  confirm-button-text="确认"
                  cancel-button-text="取消"
                  icon-color="#f89626"
                  title="是否删除此子项?"
                  @confirm="delScoringItems(scope.row)"
                  @cancel="cancelEvent"
                  v-if="scope.row.scoreItem_li"
                >
                  <template #reference>
                    <div class="look">删除</div>
                  </template>
                </el-popconfirm>
                <div
                  v-if="scope.row.scoreItem_li"
                  class="look"
                  @click="editScoringItems(scope.row)"
                >
                  编辑
                </div>
                <div
                  v-if="!scope.row.scoreItem_li"
                  class="look"
                  @click="secondaryItemClick(scope.row)"
                >
                  添加子项
                </div>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="option">
        <!-- <el-button
          color="rgba(41, 109, 227, 1)"
          class="queding"
          type="primary"
          @click="confirmSelDel"
        >
          保存
        </el-button> -->
        <el-button @click="cancelScoringItems">返回</el-button>
      </div>
    </el-dialog>

    <!-- 添加项弹窗 -->
    <el-dialog
      class="addItemDialog"
      v-model="addItemVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :title="addItemTitle"
      align-center
      width="550"
      :before-close="cancelAddItem"
    >
      <el-form
        ref="addItemRef"
        :model="addItemRuleForm"
        :rules="addItemRules"
        label-width="100px"
        class="demo-ruleForm"
        :size="formSize"
        label-position="right"
        status-icon
      >
        <!-- <el-form-item label="学期 :" prop="term">
          <el-select
            v-model="addItemRuleForm.term"
            class="sel"
            placeholder="请选择学期"
          >
            <el-option
              :label="i.name"
              :value="i.name"
              v-for="i in semesterData"
            />
          </el-select>
        </el-form-item> -->

        <el-form-item
          v-if="addItemTitle == '添加评分项'"
          label="评分项 :"
          prop="bigitem"
        >
          <el-input
            v-model.trim="addItemRuleForm.bigitem"
            placeholder="请输入评分项"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="评分子项 :" prop="subitem">
          <el-input
            v-model.trim="addItemRuleForm.subitem"
            placeholder="请输入评分子项"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="分值 :" prop="score">
          <el-input
            v-model.trim="addItemRuleForm.score"
            placeholder="请输入分值"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item class="options">
          <el-button
            color="rgba(41, 109, 227, 1)"
            class="queding"
            type="primary"
            @click="confirmAddItem(addItemRef)"
          >
            确认
          </el-button>
          <el-button @click="cancelAddItem">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script setup>
import * as echarts from "echarts";
import { markRaw } from "vue";
import {
  ref,
  reactive,
  watch,
  nextTick,
  onBeforeMount,
  onMounted,
  onUnmounted,
} from "vue";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { Calendar } from "@element-plus/icons-vue";
import vidiconsApi from "@/api/vidicons.js";
import { dayjs } from "element-plus";
import lodash from "lodash";
import eds from "@/utils/eds.js";
import axios from "axios";
import { useStore } from "vuex";
const store = useStore();
const api = ref("");
const router = useRouter();
// 表格数据
const loading = ref(false);
const tableData = reactive({
  list: [],
});
const evaluateDetail = ref(); // 表格中的评分字段
const searchInput = reactive({
  keyWord: "",
  semester: "", // 学期
  subject: "", // 学科
  grade: "", // 年级
  class: "", // 班级
}); // 搜索按钮数据

const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(5); // 当前总数

const semesterData = ref(); //学期下拉数据
const gradeData = ref(); //年级下拉数据
const classsData = ref(); //班级下拉数据
const subjectData = ref(); //学科下拉数据

// 去评分弹窗 (----------------------------------------------------)
const scoreVisible = ref(false);
const scoreData = reactive({ list: [] });
const goScoreId = ref();
const lowingScore = ref(); // 总扣分
const totalScore = ref(); // 总得分
const goScoreFlag = ref(true); // 判断是否能保存

// 评分项管弹窗 (----------------------------------------------------)
const scoringItemsVisible = ref(false);
const resetTable = ref(); // 表格ref
const semesterName = ref(); // 选择的学期名称
const semestertermId = ref(); // 选择的学期id
const adjustData = ref(); // 接口获取的初始数据
const scoringItemsData = reactive({
  list: [],
}); // 调整后的数据
const resetTableIndex = ref(); // 表格ref

// 添加项功能弹窗 (----------------------------------------------------)
const addItemTitle = ref("");
const addItemVisible = ref(false);
const addItemRef = ref();
const addItemRuleForm = reactive({
  term: "", // 学期
  termId: "", // 学期
  bigitem: "", // 评分项
  subitem: "", // 评分子项
  score: "", // 分值
  id: "",
});
const editItemRow = ref(); // 编辑时的数据
const validateScore = (rule, value, callback) => {
  if (/^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/.test(value)) {
    callback();
  } else {
    callback(new Error("请输入正确的分值"));
  }
};
// 表单验证
const addItemRules = reactive({
  term: [{ required: true, message: "学期不能为空", trigger: "blur" }],
  bigitem: [{ required: true, message: "评分项不能为空", trigger: "blur" }],
  subitem: [
    {
      required: true,
      message: "评分子项不能为空",
      trigger: "blur",
    },
  ],
  score: [
    {
      required: true,
      message: "分值不能为空",
      trigger: "blur",
    },
    { validator: validateScore, trigger: "blur" },
  ],
});
// 获取学期下拉
const semesterList = async () => {
  let semester = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartScore/querySmartSemesters",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    // params: data,
  });
  console.log(semester, "学期下拉数据");
  if (semester.data.code == 200) {
    semesterData.value = JSON.parse(eds.decryptDes(semester.data.data));
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: semester.data.message,
      center: true,
    });
  }

  let grade = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartGrade/querySmartGrades",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    // params: data,
  });
  console.log(
    grade,
    JSON.parse(eds.decryptDes(grade.data.data)),
    "年级下拉数据"
  );
  gradeData.value = JSON.parse(eds.decryptDes(grade.data.data));
};

// 学科下拉、班级下拉
const subjectDataList = async (value) => {
  // let subject = await axios({
  //   method: "get",
  //   url: api.value + "/wanzai/api/smartScore/querySubjects",
  //   headers: {
  //     token: sessionStorage.getItem("token"),
  //     user_head: sessionStorage.getItem("userhead"),
  //   },
  //   params: {
  //     gradeId: value,
  //   },
  // });
  // console.log(
  //   subject,
  //   JSON.parse(eds.decryptDes(subject.data.data)),
  //   "学科下拉数据"
  // );
  // if (subject.data.code == 200) {
  //   subjectData.value = JSON.parse(eds.decryptDes(subject.data.data));
  // } else {
  //   ElMessage({
  //     type: "error",
  //     showClose: true,
  //     message: subjectData.data.message,
  //     center: true,
  //   });
  // }

  let classs = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartClass/querySmartClasss",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: {
      gradeId: value,
    },
  });
  console.log(
    classs,
    JSON.parse(eds.decryptDes(classs.data.data)),
    "班级下拉数据"
  );
  if (classs.data.code == 200) {
    classsData.value = JSON.parse(eds.decryptDes(classs.data.data));
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: classsData.data.message,
      center: true,
    });
  }
};
// 改变年级选择
const yearClassChange = async (value) => {
  console.log(value, 111111111);
  if (value) {
    subjectDataList(value.split("-")[1]);
  } else {
    subjectData.value = [];
    classsData.value = [];
    searchInput.class = "";
    searchInput.subject = "";
  }
  getList();
};

// 教师综合素质评价/详情 页面 (----------------------------------------------------)
const pageIndex = ref(1); // 切换到详情页面
const teacherRowInfo = ref(); // 当前点击的老师的信息
const teacherList = ref(); // 评分列表
const teacherComparison = reactive({
  name: [],
  avgScore: [], // 评价得分
  ownScore: [], //所得评分
}); // 评分比对
const rankCurrentPage = ref(1); // 当前页
const rankPageSize = ref(100);
const rankInput = ref("全部"); // 搜索
const rankData = ref(); // 排行榜对比
const scoreEcharts = ref(); // 评分对比统计图

// 查看教师
const getList = async () => {
  loading.value=true
  if (pageIndex.value == 1) {
    let params = {
      currentPage: currentPage.value,
      pageCount: pageSize.value,
      // managerId: sessionStorage.getItem("token"),
    };
    let data = {
      name: searchInput.keyWord,
      term: searchInput.semester,
      className: searchInput.class,
      // subject: searchInput.subject,
    };
    if (searchInput.grade) {
      data.gradeName = searchInput.grade.split("-")[0];
    }
    let res = await axios({
      method: "post",
      url: api.value + "/wanzai/api/smartEvaluateTeacher/getTeacherScoreList",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      params: params,
      data: data,
    });
    console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "教师分页");
    if (res.data.code == 200) {
      let data = JSON.parse(eds.decryptDes(res.data.data));
      data.list.forEach((item) => {
        if (item.evaluateDetail) {
          console.log(JSON.parse(item.evaluateDetail));
          evaluateDetail.value = [];
          let obj = JSON.parse(item.evaluateDetail);
          for (let key in obj) {
            evaluateDetail.value.push({
              label: key,
              value: obj[key],
            });
          }
        }
      });
      tableData.list = data.list;
      console.log(tableData.list);
      total.value = data.totalCount;
      loading.value=false
      // ElMessage({
      //   type: "success",
      //   showClose: true,
      //   message: res.data.message,
      //   center: true,
      // });
    } else {
      loading.value=false
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  } else if (pageIndex.value == 2) {
    let formData = new FormData();
    formData.append("id", teacherRowInfo.value.id);
    let res = await axios({
      method: "post",
      url: api.value + "/wanzai/api/smartEvaluateTeacher/getTeacherScoreDetail",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      data: formData,
    });
    console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "评分列表");
    if (res.data.code == 200) {
      teacherList.value = JSON.parse(
        eds.decryptDes(res.data.data)
      ).simpleScoreList.simpleScoreDetailList;
      loading.value=false
      // ElMessage({
      //   type: "success",
      //   showClose: true,
      //   message: res.data.message,
      //   center: true,
      // });
    } else {
      loading.value=false
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }

    let ress = await axios({
      method: "post",
      url: api.value + "/wanzai/api/smartEvaluateTeacher/getScoreComparison",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      data: formData,
    });
    console.log(ress, "评分对比");
    console.log(ress, JSON.parse(eds.decryptDes(ress.data.data)), "评分对比");

    if (ress.data.code == 200) {
      if (ress.data.data) {
        teacherComparison.name = [];
        teacherComparison.avgScore = [];
        teacherComparison.ownScore = [];
        JSON.parse(eds.decryptDes(ress.data.data)).forEach((item) => {
          teacherComparison.name.push(item.name);
          teacherComparison.avgScore.push(item.avgScore);
          teacherComparison.ownScore.push(item.ownScore);
        });
      }
      nextTick(() => {
        scoreEchart();
      });
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: ress.data.message,
        center: true,
      });
    }

    rankSel(); //评分排行榜
  }
};
// 更新按钮
const updateClick = async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartSemester/pullSemesterTeacher",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
  });
  console.log(res, "教师分页");
  if (res.data.code == 200) {
    getList();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 评分排行榜
const rankSel = async () => {
  let formDatass = new FormData();
  formDatass.append("currentPage", rankCurrentPage.value);
  formDatass.append("pageCount", rankPageSize.value);
  if (rankInput.value != "全部") {
    formDatass.append("scoreItem", rankInput.value);
  }
  let resss = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/getScoreRank",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: formDatass,
  });
  console.log(resss, JSON.parse(eds.decryptDes(resss.data.data)), "评分排行榜");
  if (resss.data.code == 200) {
    rankData.value = JSON.parse(eds.decryptDes(resss.data.data)).list;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: resss.data.message,
      center: true,
    });
  }
};

// 搜索功能
const searchBtn = lodash.debounce(async () => {
  getList();
}, 300);

const handleSelectionChange = () => {};

//导出功能 (-------------------------------------------------)
const importExcel = async () => {
  let data = {
    name: searchInput.keyWord,
    term: searchInput.semester,
    className: searchInput.class,
  };
  if (searchInput.grade) {
    data.gradeName = searchInput.grade.split("-")[0];
  }
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/getTEvaluationExcel",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
    responseType: "blob",
  });
  console.log(res, "学生评价信息");
  if (res.status == 200) {
    let name = `教师评价信息`;
    var content = res.data;
    var datas = new Blob([content]);
    var downloadUrl = window.URL.createObjectURL(datas);
    var anchor = document.createElement("a");
    anchor.href = downloadUrl;
    anchor.download = name + ".xlsx";
    anchor.click();
    window.URL.revokeObjectURL(datas);
    ElMessage({
      type: "success",
      showClose: true,
      message: "导出成功",
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 点击老师查看老师详情 （---------------------------------------------）
const teacherInfoClick = (row) => {
  pageIndex.value = 2;
  // teacherId.value = row.id;
  teacherRowInfo.value = row;
  console.log(row, "点击的教师信息");
  getList();
};
// 取消查看老师详情
const teacherInfoConcel = () => {
  pageIndex.value = 1;
  scoreEcharts.value = "";
};
// 评分对比统计图
const scoreEchart = () => {
  scoreEcharts.value = markRaw(
    echarts.init(document.getElementById("scoreEcharts"))
  );
  scoreEcharts.value.setOption({
    legend: {
      // orient: "",
      top: "5%",
      right: "8%",
      itemGap: 20,
      itemWidth: 15,
      itemHeight: 15,
      data: ["所得评分", "平均得分"],
      color: ["red", "black"],
    },
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },

    grid: {
      show: false,
      top: "22%", // 一下数值可为百分比也可为具体像素值
      right: "8%",
      bottom: "12%",
      left: "10%",
    },
    dataZoom: [
      {
        type: "slider",
        realtime: true,
        start: 0,
        end: 100, // 数据窗口范围的结束百分比。范围是：0 ~ 100。
        height: 5, // 组件高度
        left: 5, // 左边的距离
        right: 5, // 右边的距离
        bottom: 2, // 下边的距离
        show: false, // 是否展示
        fillerColor: "rgba(180, 226, 251, 1)", // 滚动条颜色
        borderColor: "rgba(180, 226, 251, 0.12)",
        handleSize: 0, // 两边手柄尺寸
        showDetail: false, // 拖拽时是否展示滚动条两侧的文字
        zoomLock: true, // 是否只平移不缩放
        moveOnMouseMove: false, // 鼠标移动能触发数据窗口平移
        zoomOnMouseWheel: true, // 鼠标移动能触发数据窗口缩放
      },
      {
        type: "inside", // 支持内部鼠标滚动平移
        start: 0,
        end: 100,
        zoomOnMouseWheel: false, // 关闭滚轮缩放
        moveOnMouseWheel: true, // 开启滚轮平移
        moveOnMouseMove: true, // 鼠标移动能触发数据窗口平移
      },
    ],
    xAxis: [
      {
        // type: "category",
        axisLine: {
          show: true,
          //这是x轴文字颜色
          lineStyle: {
            color: "rgba(108, 128, 151, 1)",
          },
        },
        axisTick: {
          show: false,
        },
        data: teacherComparison.name,
      },
    ],
    yAxis: {
      // name: "吨/度",
      nameTextStyle: {
        color: "#aaa",
        nameLocation: "start",
      },
      axisLine: {
        //这是x轴文字颜色
        show: true,
        lineStyle: {
          color: "##5B5B5B",
        },
      },
      splitLine: {
        //x轴的网格 样式
        lineStyle: {
          color: "#F0EEEE",
          width: 1,
          type: "dashed",
        },
      },
    },
    // Declare several bar series, each will be mapped
    // to a column of dataset.source by default.
    series: [
      {
        name: "所得评分",
        type: "bar",
        data: teacherComparison.ownScore,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: "rgba(197, 211, 246, 0.8)" },
            { offset: 1, color: "rgba(21, 154, 255, 1)" },
          ]),
          borderWidth: 1,
          borderColor: "rgba(21, 154, 255, 1)",
        },
        barGap: "0%", // 同一列柱子的间距
        barWidth: 20, // 柱子的宽度
        emphasis: {
          focus: "series",
        },
        label: {
          normal: {
            show: true,
            lineHeight: 10,
            formatter: "{c}",
            position: "top",
            textStyle: {
              color: "#000",
              fontSize: 10,
            },
          },
        },
      },
      {
        name: "平均得分",
        type: "bar",
        data: teacherComparison.avgScore,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: "rgba(255, 233, 168, 1)" },
            { offset: 1, color: "rgba(222, 123, 2, 1)" },
          ]),
          borderWidth: 1,
          borderColor: "rgba(222, 123, 2, 1",
        },
        barWidth: 20, // 柱子的宽度
        emphasis: {
          focus: "series",
        },
        label: {
          normal: {
            show: true,
            lineHeight: 10,
            formatter: "{c}",
            position: "top",
            textStyle: {
              color: "#000",
              fontSize: 10,
            },
          },
        },
      },
    ],
  });
};
//去评分按钮  （-------------------------------------------）
const goScore = async (row) => {
  scoreVisible.value = true;
  goScoreId.value = row.id;
  let formData = new FormData();
  formData.append("id", row.id);
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/getTeacherScoreDetail",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: formData,
  });
  console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "评分列表");
  if (res.data.code == 200) {
    scoreData.list = JSON.parse(
      eds.decryptDes(res.data.data)
    ).simpleScoreList.simpleScoreDetailList;
    lowingScore.value = JSON.parse(eds.decryptDes(res.data.data)).lowingScore;
    totalScore.value = JSON.parse(eds.decryptDes(res.data.data)).totalScore;

    // ElMessage({
    //   type: "success",
    //   showClose: true,
    //   message: res.data.message,
    //   center: true,
    // });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 修改评分
const goScoreChange = (value, row) => {
  // console.log(value, item);
  let sum = 0; // 表示满评分多少
  totalScore.value = 0;
  lowingScore.value = 0;
  console.log(scoreData.list);
  goScoreFlag.value = true;
  scoreData.list.forEach((item) => {
    // console.log(item);
    sum += Number(item.scoreNum); // 计算满评分
    let smallTotalScore = 0; // 单独项的评分和
    item.evaluateList.forEach((i) => {
      if (i.ownNum) {
        var reg = /^\d+(?=\.{0,1}\d+$|$)/;
        if (reg.test(i.ownNum)) {
          if (i.ownNum > i.scoreNum) {
            // i.ownNum = 0;
            i.ownNum = i.scoreNum;
            goScoreFlag.value = false;
            ElMessage({
              type: "error",
              showClose: true,
              message: `（${i.scoreItem}）输入的分值过大`,
              center: true,
            });
          } else {
            smallTotalScore += Number(i.ownNum);
            totalScore.value += Number(i.ownNum); // 计算总得分
          }
        } else {
          goScoreFlag.value = false;
          ElMessage({
            type: "error",
            showClose: true,
            message: `（${i.scoreItem}）请输入大于等于0的正数分`,
            center: true,
          });
        }
      } else {
        goScoreFlag.value = false;
      }
    });
    console.log(smallTotalScore, "单独项的评分和");
    item.ownNum = smallTotalScore;
  });
  console.log(goScoreFlag.value, "判断是否能保存");
  lowingScore.value = sum - totalScore.value;
};

const cancelScore = () => {
  scoreVisible.value = false;
  lowingScore.value = "";
  totalScore.value = "";
  goScoreId.value = "";
};

// 确定去评分
const confirmGoScore = async () => {
  console.log(goScoreFlag.value, "判断是否能保存");

  if (goScoreFlag.value) {
    let data = {
      id: goScoreId.value, // 该条数据ID，用户信息ID
      lowingScore: lowingScore.value, // 总扣分，前端计算
      totalScore: totalScore.value, // 总得分，前端计算
      simpleScoreList: scoreData.list,
    };
    let res = await axios({
      method: "post",
      url: api.value + "/wanzai/api/smartEvaluateTeacher/evaluateScore",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      data: data,
    });
    console.log(res, "确定评分");
    if (res.data.code == 200) {
      scoreVisible.value = false;
      lowingScore.value = "";
      totalScore.value = "";
      goScoreId.value = "";
      getList();
      ElMessage({
        type: "success",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: "评分项不能为空或分值不正确",
      center: true,
    });
  }
};

// 评分项管理 (------------------------------------------------------)
const scoringItemsClick = async () => {
  scoringItemsVisible.value = true;
  semesterName.value = semesterData.value[0].name;
  semestertermId.value = semesterData.value[0].id;
  // console.log(semesterData.value,semesterName.value,semestertermId.value);
  getAllData({ name: semesterName.value, id: semestertermId.value });
};
// 获取评分项全部数据
const getAllData = async (termName) => {
  console.log(termName);
  semesterName.value = termName.name;
  semestertermId.value = termName.id;
  let formData = new FormData();
  formData.append("term", semesterName.value);
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/getScoreManage",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: formData,
  });
  console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "评分项管理");
  if (res.data.code == 200) {
    let data = JSON.parse(eds.decryptDes(res.data.data));
    if (data.simpleScoreList.length) {
      adjustData.value = data.simpleScoreList;
      addItemRuleForm.term = semesterName.value;
      addItemRuleForm.termId = semestertermId.value;
      adjustItem();
    } else {
      adjustData.value = data.simpleScoreList;
      addItemRuleForm.term = semesterName.value;
      addItemRuleForm.termId = semestertermId.value;
      scoringItemsData.list = [];
    }
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 整理评分项数据
const adjustItem = () => {
  let arr = [];
  adjustData.value.forEach((item) => {
    arr.push({
      deleted: item.deleted,
      id: item.id,
      parentId: item.parentId,
      scoreItem: item.scoreItem,
      scoreItem_li: "",
      scoreNum: item.scoreNum,
      smartScoreManageList: item.smartScoreManageList,
      term: item.term,
      termId: item.termId,
      index: item.smartScoreManageList.length + 1,
    });
    item.smartScoreManageList.forEach((i) => {
      arr.push({
        deleted: i.deleted,
        id: i.id,
        parentId: i.parentId,
        scoreItem: item.scoreItem,
        scoreItem_li: i.scoreItem,
        scoreNum: i.scoreNum,
        smartScoreManageList: "",
        term: i.term,
        termId: item.termId,
        index: 0,
      });
    });
  });
  scoringItemsData.list = arr;
  console.log(arr, "评分项整理数据");
};
// 合并表格
const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    const _row = scoringItemsData.list[rowIndex].index;
    const _col = _row > 0 ? 1 : 0;
    return {
      rowspan: _row,
      colspan: _col,
    };
  }
};
const cancelScoringItems = () => {
  scoringItemsVisible.value = false;
};
// 添加项按钮 （-------------------------------------------）
const bigItemClick = async () => {
  // let arr={ pf: "", pfz: "", fz: "" }
  console.log(semesterName.value, semestertermId.value);
  addItemVisible.value = true;
  addItemTitle.value = "添加评分项";
  addItemRuleForm.term = semesterName.value;
  addItemRuleForm.termId = semestertermId.value;
  addItemRuleForm.id = "";
  addItemRuleForm.bigitem = "";
  addItemRuleForm.subitem = "";
  addItemRuleForm.score = "";
};
// 取消添加项
const cancelAddItem = () => {
  addItemVisible.value = false;
  addItemRef.value.resetFields();
  addItemRuleForm.term = semesterName.value;
  addItemRuleForm.termId = semestertermId.value;
  addItemRuleForm.id = "";
  addItemRuleForm.bigitem = "";
  addItemRuleForm.subitem = "";
  addItemRuleForm.score = "";
};
// 确定添加项
const confirmAddItem = (formEl) => {
  if (addItemTitle.value == "添加评分项") {
    if (!formEl) return;
    formEl.validate(async (valid, fields) => {
      if (valid) {
        // let data = {
        //   deleted: 0,
        //   id: "",
        //   parentId: 0,
        //   scoreItem: addItemRuleForm.bigitem,
        //   scoreNum: addItemRuleForm.score,
        //   term: addItemRuleForm.term,
        //   smartScoreManageList: [
        //     {
        //       deleted: 0,
        //       id: "",
        //       parentId: "",
        //       scoreItem: addItemRuleForm.subitem,
        //       scoreNum: addItemRuleForm.score,
        //       smartScoreManageList: "",
        //       term: addItemRuleForm.term,
        //     },
        //   ],
        // };
        // let flag = "";
        // console.log(adjustData.value);
        // if (adjustData.value) {
        //   flag = adjustData.value.some((item) => {
        //     return item.scoreItem == addItemRuleForm.bigitem;
        //   });
        // } else {
        //   flag = false;
        //   adjustData.value = [];
        // }
        // console.log(flag, "重复添加评分项");
        // if (flag) {
        //   ElMessage({
        //     type: "warning",
        //     showClose: true,
        //     message: "重复添加评分项",
        //     center: true,
        //   });
        // } else {
        //   adjustData.value.push(data);
        //   operateScore(); // 评分管理操作-增加/删除/更新 调用
        //   addItemVisible.value = false;
        // }
        let data = {
          termId: addItemRuleForm.termId,
          scoreItem: addItemRuleForm.bigitem,
          scoreChildItem: addItemRuleForm.subitem,
          scoreNum: addItemRuleForm.score,
        };
        console.log(data);
        let res = await axios({
          method: "post",
          url: api.value + "/wanzai/api/smartEvaluateTeacher/addScoreManage",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "总选项添加");
        if (res.data.code == 200) {
          getAllData({
            name: semesterName.value,
            id: semestertermId.value,
          });
          // addItemRef.value.resetFields();
          addItemVisible.value = false;
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    });
  } else if (addItemTitle.value == "添加评分子项") {
    if (!formEl) return;
    formEl.validate(async (valid, fields) => {
      if (valid) {
        // let data = {
        //   deleted: 0,
        //   id: "",
        //   parentId: "",
        //   scoreItem: addItemRuleForm.subitem,
        //   scoreNum: addItemRuleForm.score,
        //   smartScoreManageList: "",
        //   term: addItemRuleForm.term,
        // };
        // // 用原数据判断要往哪个大项里面添加子项
        // adjustData.value.forEach((item) => {
        //   if (item.scoreItem == addItemRuleForm.bigitem) {
        //     // 判断是否重复添加子项
        //     let flag = item.smartScoreManageList.some((i) => {
        //       return addItemRuleForm.subitem == i.scoreItem;
        //     });
        //     if (flag) {
        //       ElMessage({
        //         type: "warning",
        //         showClose: true,
        //         message: "重复添加评分子项",
        //         center: true,
        //       });
        //     } else {
        //       item.smartScoreManageList.push(data);
        //       let score = 0;
        //       item.smartScoreManageList.forEach((item) => {
        //         score += Number(item.scoreNum);
        //       });
        //       item.scoreNum = score;
        //       operateScore(); // 评分管理操作-增加/删除/更新 调用
        //       addItemVisible.value = false;
        //     }
        //   }
        // });
        let data = {
          id: addItemRuleForm.id,
          termId: addItemRuleForm.termId,
          scoreItem: addItemRuleForm.subitem,
          scoreNum: addItemRuleForm.score,
        };
        console.log(data);
        let res = await axios({
          method: "post",
          url:
            api.value + "/wanzai/api/smartEvaluateTeacher/addChildScoreManage",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "子选项添加");
        if (res.data.code == 200) {
          getAllData({
            name: semesterName.value,
            id: semestertermId.value,
          });
          addItemVisible.value = false;
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    });
  } else if (addItemTitle.value == "编辑评分子项") {
    if (!formEl) return;
    formEl.validate(async (valid, fields) => {
      if (valid) {
        // let data = {
        //   deleted: editItemRow.value.deleted,
        //   id: editItemRow.value.id,
        //   parentId: editItemRow.value.parentId,
        //   scoreItem: addItemRuleForm.subitem,
        //   scoreNum: addItemRuleForm.score,
        //   smartScoreManageList: "",
        //   term: editItemRow.value.term,
        // };
        // // 用原数据判断要往哪个大项里面添加子项
        // adjustData.value.forEach((item) => {
        //   if (item.scoreItem == addItemRuleForm.bigitem) {
        //     item.smartScoreManageList.forEach((i) => {
        //       if (addItemRuleForm.subitem == i.scoreItem) {
        //         i.deleted = editItemRow.value.deleted;
        //         i.id = editItemRow.value.id;
        //         i.parentId = editItemRow.value.parentId;
        //         i.scoreItem = addItemRuleForm.subitem;
        //         i.scoreNum = addItemRuleForm.score;
        //         i.smartScoreManageList = "";
        //         i.term = editItemRow.value.term;
        //       }
        //     });
        //     let score = 0;
        //     item.smartScoreManageList.forEach((i) => {
        //       score += Number(i.scoreNum);
        //     });
        //     item.scoreNum = score;
        //   }
        // });
        // console.log(adjustData.value);
        // operateScore(); // 评分管理操作-增加/删除/更新 调用
        // addItemVisible.value = false;
        let data = {
          id: addItemRuleForm.id,
          scoreItem: addItemRuleForm.subitem,
          scoreNum: addItemRuleForm.score,
        };
        console.log(data);
        let res = await axios({
          method: "post",
          url: api.value + "/wanzai/api/smartEvaluateTeacher/updateScoreManage",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "子选项编辑");
        if (res.data.code == 200) {
          getAllData({
            name: semesterName.value,
            termId: semestertermId.value,
          });
          addItemVisible.value = false;
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    });
  }
};
// 评分管理操作-增加/删除/更新
const operateScore = async () => {
  let data = {
    simpleScoreList: adjustData.value,
  };
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/operateSmartScoreManage",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  console.log(res, "分管理操作-增加/删除/更新");
  if (res.data.code == 200) {
    getAllData({ name: semesterName.value, id: semestertermId.value });
    // addItemRef.value.resetFields();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 添加子选项 （\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\）
const secondaryItemClick = (row) => {
  addItemVisible.value = true;
  addItemTitle.value = "添加评分子项";
  addItemRuleForm.bigitem = row.scoreItem;
  addItemRuleForm.term = semesterName.value;
  addItemRuleForm.termId = semestertermId.value;
  console.log(semestertermId.value);
  
  addItemRuleForm.id = row.id;
  addItemRuleForm.subitem = "";
  addItemRuleForm.score = "";
};
// 编辑项（-----------------------------------------------------------）
const editScoringItems = (row) => {
  addItemVisible.value = true;
  console.log(row);
  addItemTitle.value = "编辑评分子项";
  addItemRuleForm.bigitem = row.scoreItem;
  addItemRuleForm.subitem = row.scoreItem_li;
  addItemRuleForm.score = row.scoreNum;
  addItemRuleForm.term = row.term;
  addItemRuleForm.termId = row.termId;
  addItemRuleForm.id = row.id;
  editItemRow.value = row;
};

// 删除功能（-----------------------------------------------------------）
const delScoringItems = async (row) => {
  console.log(row);
  // adjustData.value.forEach((item) => {
  //   console.log(item);
  //   if (item.scoreItem == row.scoreItem) {
  //     if (item.smartScoreManageList.length == 1) {
  //       item.deleted = 1;
  //     }
  //     item.smartScoreManageList.forEach((i) => {
  //       if (i.id == row.id) {
  //         console.log(i, "删除项");
  //         i.deleted = 1;
  //       }
  //     });
  //     let score = 0;
  //     item.smartScoreManageList.forEach((i) => {
  //       if (i.deleted == 0) {
  //         score += Number(i.scoreNum);
  //       }
  //     });
  //     item.scoreNum = score;
  //   }
  // });
  // console.log(adjustData.value);
  // operateScore();
  let data = {
    id: row.id,
  };
  console.log(data);
  let res = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartEvaluateTeacher/deleteScoreManage",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "子选项编辑");
  if (res.data.code == 200) {
    getAllData({
      name: semesterName.value,
      id: semestertermId.value,
    });
    addItemVisible.value = false;
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
const cancelEvent = () => {};

// 表格斑马纹颜色修改
const tableRowClassName = ({ row, rowIndex }) => {
  if (rowIndex % 2 === 0) {
    return "even";
  } else if (rowIndex % 2 !== 0) {
    return "odd";
  }
  return "";
};
// 分页
const handleCurrentChange = (value) => {
  // console.log(value);
  currentPage.value = value;
  getList();
};

onBeforeMount(async () => {
  api.value = store.state.user.api;
  getList();
  semesterList(); // 学期
  window.addEventListener("resize", function () {
    if (scoreEcharts.value) {
      scoreEcharts.value.resize();
    }
  });
});
onMounted(() => {});
onUnmounted(() => {
  // scoreEcharts.value.dispose();
});
</script>

<style scoped lang="scss">
.content-box {
  min-width: 1000px;
  width: calc(100vw - 260px);
  height: calc(100vh - 105px);
  margin: 20px auto;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);
  .pageIndex {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .left {
    // width: calc(100wh - 40px);
    display: flex;
    align-items: center;
    height: 60px;
    margin: 0 30px;
    border-bottom: 1px solid #ccc;
    color: rgb(0, 0, 0);
    font-size: 18px;
    font-weight: 600;

    span {
      display: block;
      height: 60px;
      line-height: 60px;
    }

    .is_active {
      color: rgba(111, 182, 184, 1);
    }
  }
  .scroll {
    // height: calc(100% - 61px);
    flex: 1;
    overflow: auto;
    .footer {
      width: 96%;
      height: calc(100% - 70px);
      margin: 0 auto 16px;

      .el-table--fit {
        height: 100%;

        :deep(.el-table__header-wrapper) {
          background-color: #000;
          font-size: 14px;
        }

        :deep(.el-table__row) {
          height: 50px;
          font-size: 14px;
          // color: #000;

          &:hover {
            td {
              background-color: rgba(223, 236, 254, 1);
            }
          }
        }

        :deep(.el-table__row td) {
          padding: 0;
          .normal {
            cursor: pointer;
            color: rgba(0, 97, 255, 1);
          }
        }

        .el-button--primary {
          margin-left: 5px;
        }

        :deep(.el-table__body .even) {
          background-color: #fff;
        }

        :deep(.el-table__body .odd) {
          background-color: rgba(240, 243, 247, 1);
        }

        :deep(.edit) {
          display: flex;
          align-items: center;
          justify-content: center;
          color: rgba(111, 182, 184, 1);
        }

        :deep(.look) {
          padding: 0 10px;
          cursor: pointer;
          color: rgba(30, 125, 251, 1);
        }

        .del {
          padding: 0 10px;
          color: rgba(212, 48, 48, 1);
          cursor: pointer;
        }

        // :deep(.look):hover {
        //   color: red;
        // }
        // :deep(.del):hover {
        //   color: red;
        // }
      }
    }
  }
  .middle {
    width: 96%;

    margin: 0 auto;
    color: #000;
    // border-bottom: 1px solid rgb(231, 231, 231);
    .filter {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      margin: 10px 0 0 0;

      .search {
        color: #fff;
      }

      .condition {
        display: flex;
        align-items: center;
        margin: 10px 30px 10px 0;
        .title {
          padding-right: 5px;
        }
        .sel {
          margin-right: 10px;
        }
        :deep(.el-input .el-input__inner) {
          font-size: 14px;
        }
      }
    }

    .gongneng {
      margin: 10px 0 20px 0;

      span {
        color: #fff;
      }
      .el-button {
        margin-right: 10px;
      }
    }

    :deep(.download) {
      display: flex;
      align-items: center;
      margin: 10px;
    }

    :deep(.download span) {
      font-size: 16px;
      margin-left: 20px;
    }
  }

  // 教师综合素质评价
  .teacherInfo {
    height: 100%;
    .left {
      // width: calc(100wh - 40px);
      display: flex;
      align-items: center;
      height: 60px;
      border-bottom: 1px solid #ccc;
      color: rgb(0, 0, 0);
      font-size: 18px;
      font-weight: 600;
      img {
        width: 18px;
        height: 18px;
        cursor: pointer;
        margin-right: 10px;
      }
      .add {
        margin-left: 20px !important;
        font-size: 20px !important;
        color: rgba(0, 0, 0, 1) !important;
      }
    }
    .scroll_score {
      width: calc(100% - 60px);
      height: calc(100% - 61px);
      margin: 0 auto;
      overflow: auto;
      .semester {
        .title {
          font-size: 20px;
          margin: 15px 0;
          text-align: center;
          color: rgba(0, 0, 0, 1);
        }
        .score {
          height: 141px;
          border-radius: 8px;
          background: rgba(240, 244, 250, 1);
          display: flex;
          align-items: center;
          justify-content: space-between;
          .score_left {
            display: flex;
            align-items: center;
            img {
              width: 80px;
              height: 80px;
              margin: 0 20px;
              border-radius: 50%;
              border: 1px solid rgba(0, 97, 255, 1);
            }
            .info {
              .info_name {
                font-size: 20px;
                color: #000;
              }
              .info_object {
                color: rgba(128, 128, 128, 1);
                font-size: 16px;
                margin-top: 5px;
              }
            }
          }
          .score_right {
            color: #000;
            margin-right: 30px;
            .num {
              display: inline-block;
              font-size: 60px;
              color: rgba(0, 97, 255, 1);
            }
          }
        }
      }
      .scoreList {
        margin: 10px 0;
        .title {
          display: flex;
          align-items: center;
          height: 60px;
          color: rgb(0, 0, 0);
          font-size: 20px;
          font-weight: 600;
          img {
            width: 29px;
            height: 20px;
            margin-right: 8px;
          }
          .goScore {
            margin-left: 20px;
          }
        }
        .table {
          width: 100%;
          border-radius: 4px;
          overflow: auto;
          display: flex;

          .items {
            &:last-child {
              border-right: 1px solid rgba(230, 230, 230, 1);
            }
            .txt {
              height: 40px;
              line-height: 40px;
              text-align: center;
              border-left: 1px solid rgba(230, 230, 230, 1);
              border-top: 1px solid rgba(230, 230, 230, 1);
              &.scoreItem {
                background-color: rgba(240, 243, 247, 1);
              }
              &:nth-child(2) {
                border-bottom: 1px solid rgba(230, 230, 230, 1);
              }
            }

            .items_li {
              display: flex;
              flex-wrap: nowrap;
              .lis {
                width: 120px;
              }
            }
          }
        }

        .table::-webkit-scrollbar-track {
          background-color: #daeeff;
        }

        .table::-webkit-scrollbar {
          background-color: rgba(0, 97, 255, 1);
          height: 3px;
          width: 2px;
        }
      }
      .score_footer {
        width: 100%;
        display: flex;
        .footer_left {
          width: 40%;
          .title {
            display: flex;
            align-items: center;
            height: 60px;
            color: rgb(0, 0, 0);
            font-size: 20px;
            font-weight: 600;
            img {
              width: 29px;
              height: 20px;
              margin-right: 8px;
            }
          }
          #scoreEcharts {
            width: 100%;
            height: 240px;
          }
        }
        .footer_right {
          width: 60%;
          .title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            .title_ranking {
              display: flex;
              align-items: center;
              height: 60px;
              color: rgb(0, 0, 0);
              font-size: 20px;
              font-weight: 600;
              img {
                width: 29px;
                height: 20px;
                margin-right: 8px;
              }
            }
          }

          .el-table--fit {
            height: 240px;
            :deep(.el-table__header-wrapper) {
              font-size: 14px;
              .cell {
                color: #000;
              }
            }

            :deep(.el-table__row) {
              height: 40px;
              font-size: 14px;
              color: #000;
              td {
                padding: 0;
              }
              &:hover {
                td {
                  background-color: rgba(223, 236, 254, 0.6);
                }
              }
              &:nth-child(1) {
                .el-table__cell:nth-child(1) {
                  color: #8e71c7;
                  font-weight: 600;
                }
              }
              &:nth-child(2) {
                .el-table__cell:nth-child(1) {
                  color: #13ce66;
                  font-weight: 600;
                }
              }
              &:nth-child(3) {
                .el-table__cell:nth-child(1) {
                  color: #f36868;
                  font-weight: 600;
                }
              }
            }
          }
        }
      }
    }
  }
  // 去评分按钮
  :deep(.scoreDialog) {
    //   height: 420px;
    border-radius: 11px;
    .el-dialog__header {
      border-radius: 11px 11px 0 0;
      background: rgba(237, 241, 245, 1);
      font-weight: 600;
      margin: 0;
      .el-dialog__headerbtn {
        outline: none;
      }
    }
    .el-dialog__body {
      padding: 20px 30px 20px 30px;
      .table {
        width: 100%;
        border-radius: 4px;
        overflow: auto;
        display: flex;
        &::-webkit-scrollbar-track {
          background-color: #daeeff;
          border-radius: 4px;
        }
        // 滚动条的滚动区域（轨道）
        &::-webkit-scrollbar {
          background-color: #242424;
          height: 5px;
          width: 4px;
          border-radius: 4px;
        }
        // 滚动条的可拖拽部分（滑块）
        &::-webkit-scrollbar-thumb {
          background: #57b2ff;
          border-radius: 4px;
        }
        .items {
          &:last-child {
            border-right: 1px solid rgba(230, 230, 230, 1);
          }
          .txt {
            height: 40px;
            line-height: 40px;
            text-align: center;
            border-left: 1px solid rgba(230, 230, 230, 1);
            border-top: 1px solid rgba(230, 230, 230, 1);
            &.scoreItem {
              background-color: rgba(240, 243, 247, 1);
            }
            &:nth-child(2) {
              border-bottom: 1px solid rgba(230, 230, 230, 1);
            }
            .el-input__wrapper {
              box-shadow: none;
              .el-input__inner {
                text-align: center;
              }
            }
          }

          .items_li {
            display: flex;
            flex-wrap: nowrap;
            .lis {
              width: 120px;
            }
          }
        }
      }
      .options {
        margin: 20px 30px 0 0;
        width: 100%;
        display: flex;
        flex-direction: row-reverse;

        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }
  // 评分项管弹窗
  :deep(.scoringItems) {
    overflow: hidden;
    border-radius: 11px;
    min-width: 1100px;
    .el-dialog__header {
      border-radius: 11px 11px 0 0;
      background: rgba(245, 249, 255, 1);
      font-weight: 600;
      height: 60px;
      padding: 0 20px;
      line-height: 60px;
      margin: 0;
      border-bottom: 1px solid rgba(230, 230, 230, 1);

      .el-dialog__headerbtn {
        outline: none;
      }
    }

    .el-dialog__body {
      padding: 0px 20px 10px 20px;
      .btn {
        margin: 15px 0;
        display: flex;
        flex-wrap: wrap;
        .semester {
          margin: 0 15px 0 0;
          border: 1px solid rgb(146, 145, 145);
          border-radius: 4px;
          padding: 5px 8px;
          cursor: pointer;
        }
        .semester_active {
          border: 1px solid rgb(30, 125, 251);
          color: rgb(30, 125, 251);
        }
      }
      .el-table--fit {
        height: calc(60vh);
        // height: 550px;
        // border: 1px solid #ebeef5;
        .el-table__body-wrapper {
          .el-table__row {
            height: 50px;
            font-size: 14px;
            td {
              border-right: 1px solid #ebeef5;
            }
            td:nth-child(1) {
              border-left: 1px solid #ebeef5;
            }
            .edit {
              display: flex;
              justify-content: center;
              .look {
                padding: 0 10px;
                cursor: pointer;
                color: rgba(30, 125, 251, 1);
              }
            }
            &:hover {
              td {
                // background-color: rgba(223, 236, 254, 1);
                background-color: transparent;
              }
            }
          }
        }
      }
      .option {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        margin: 20px 0;

        .queding {
          margin-left: 20px;
        }
      }
    }
  }
  :deep(.addItemDialog) {
    //   height: 420px;
    border-radius: 11px;
    .el-dialog__header {
      border-radius: 11px 11px 0 0;
      background: rgba(237, 241, 245, 1);
      font-weight: 600;
      margin: 0;
      .el-dialog__headerbtn {
        outline: none;
      }
    }
    .el-dialog__body {
      padding: 30px 30px 10px 30px;
      .el-form-item__content {
        width: 200px;
        .el-input-group__append {
          background-color: rgba(222, 234, 252, 1);
          color: rgba(0, 97, 255, 1);
          cursor: pointer;
          user-select: none;
        }
      }
      .el-form {
        .typeTitle {
          display: block;
          color: red;
          margin: 0 0 6px 100px;
        }
        .account {
          display: flex;
          justify-content: space-between;
          .el-form-item {
            .el-form-item__content {
              width: 300px;
            }
            .el-input {
              width: 300px;
            }
          }
        }
      }

      .options {
        margin: 50px 20px 20px 0;
        width: 100%;
        .el-form-item__content {
          display: flex;
          flex-direction: row-reverse;
        }

        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }

  .pageSize {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 30px;

    span {
      color: #000;
    }

    .el-pagination {
      // width: 1600px;
      :deep(.el-pagination__total) {
        color: #000;
      }

      :deep(.el-pagination__goto) {
        color: #000;
      }

      :deep(.el-pagination__classifier) {
        color: #000;
      }

      :deep(.el-input__wrapper) {
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        box-shadow: none;
      }

      :deep(.el-pager li) {
        margin: 0 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.el-pager li.is-active) {
        // background-color: rgba(0, 97, 255, 0.8);
        border: 1px solid rgba(0, 97, 255, 1);
        color: rgba(0, 97, 255, 1);
      }

      :deep(.btn-prev) {
        margin-right: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.btn-next) {
        margin-left: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }
    }
  }
}

.el-input {
  width: 192px;
}
</style>
