<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.id"
                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-select
              v-model="searchInput.appraisal"
              class="sel"
              placeholder="请选择测评等级"
            >
              <el-option label="全部" value="1" />
              <el-option label="优等" value="2" />
              <el-option label="良" value="2" />
            </el-select>
          </div>
          <el-button
            type="primary"
            color="rgba(0, 97, 255, 1)"
            plain
            @click="scoreItemClick"
            >评分项管理</el-button
          >
        </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="importExcel"
              plain
              >导出</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
              width="80"
              align="center"
              type="index"
              label="序号"
            />
            <el-table-column
              align="center"
              prop="term"
              width="200"
              label="学期"
            />
            <!-- <el-table-column align="center" prop="name" label="教师姓名">
              <template #default="scope">
                <span class="normal" @click="teacherInfoClick(scope.row)"
                  >教师姓名</span
                >
              </template>
            </el-table-column> -->
            <el-table-column align="center" prop="gradeName" label="年级" />
            <el-table-column align="center" prop="className" label="班级" />
            <el-table-column align="center" prop="name" label="姓名" />
            <el-table-column
              align="center"
              prop="scoreLevel"
              label="测评等级"
            />
            <el-table-column align="center" label="操作">
              <template #default="scope">
                <div class="edit">
                  <div class="look" @click="teacherInfoClick(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">{{ studentInfo.term }}</div>
          <div class="score">
            <div class="score_left">
              <img src="" alt="" />
              <div class="info">
                <div class="info_name">
                  <span class="name">{{ studentInfo.name }}</span>
                  <span class="class">
                    / {{ studentInfo.gradeName
                    }}{{ studentInfo.className }}</span
                  >
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="scoreList">
          <div class="changeInfo">
            <span
              @click="infoClick(1)"
              :class="studentIndex == 1 ? 'sel_info' : ''"
              >综合测评</span
            >
            <span
              @click="infoClick(2)"
              :class="studentIndex == 2 ? 'sel_info' : ''"
              >教师评语</span
            >
          </div>
          <!-- 综合测评
          <div class="synthesis" v-if="studentIndex == 1">
            <div class="score_footer">
              <div class="footer_left">
                <div id="scoreEcharts"></div>
              </div>
              <div class="footer_right">
                <div class="title">
                  <el-button
                    color="rgba(0, 97, 255, 1)"
                    type="primary"
                    class="btn"
                    plain
                    @click="objectClick"
                    >学科管理</el-button
                  >
                  <el-button
                    color="rgba(0, 97, 255, 1)"
                    type="primary"
                    class="btn"
                    plain
                    @click="criterionClick"
                    >评分标准</el-button
                  >
                </div>
                <el-table
                  :row-class-name="tableRowClassName"
                  :data="studentInfoScore"
                  :span-method="objectSpanMethod"
                  :header-cell-style="{
                    background: 'rgba(240, 243, 247, 1)',
                    height: '50px',
                  }"
                >
                  <el-table-column
                    align="center"
                    prop="subjectName"
                    label="学科"
                  />
                  <el-table-column
                    align="center"
                    prop="scoreLevel"
                    label="等级"
                  />
                  <el-table-column
                    align="center"
                    prop="scoreNum"
                    label="成绩"
                  />
                  <el-table-column align="center" prop="status" label="操作">
                    <template #default="scope">
                      <div
                        @click="goScore"
                        style="cursor: pointer; color: rgba(0, 97, 255, 1)"
                      >
                        评分
                      </div>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </div>
          教师评语
          <div class="synthesis" v-if="studentIndex == 2">
            <div class="teacher_footer">
              <div class="info">
                <div class="info_img">
                  <img src="" alt="" />
                </div>
                <div class="info_content">
                  <div class="info_name">班主任</div>
                  <div class="info_time">2023.09.08 09:20:20</div>
                </div>
              </div>
              <div class="comment">
                <el-input
                  v-model.trim="traComment"
                  maxlength="1000"
                  placeholder="请老师输入评语"
                  show-word-limit
                  @change="confirmEditGoScore"
                  type="textarea"
                />
              </div>
            </div>
          </div> -->
        </div>
      </div>
    </div>

    <!-- 评分项管理 -->
    <el-dialog
      class="scoreItemDialog"
      v-model="scoreItemVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="评分项管理"
      align-center
      width="1000"
      :before-close="cancelScoreItem"
    >
      <div class="selObject">
        <el-button
          type="primary"
          color="rgba(0, 97, 255, 1)"
          plain
          @click="criterionClick"
          >增加</el-button
        >
      </div>
      <el-table
        :row-class-name="tableRowClassName"
        :data="scoreItemData.list"
        :header-cell-style="{
          background: 'rgba(240, 243, 247, 1)',
          height: '50px',
        }"
      >
        <el-table-column width="80" align="center" type="index" label="序号" />
        <el-table-column width="160" align="center" prop="grade" label="年级" />
        <el-table-column width="230" align="center" prop="term" label="学期" />
        <el-table-column
          width="230"
          align="center"
          prop="createTime"
          label="创建时间"
        />
        <el-table-column align="center" prop="status" label="操作">
          <template #default="{ index, row }">
            <div class="option">
              <div class="edit" @click="editScoreScope(index, row)">编辑</div>
              <div class="edit" @click="delScoreScope(index, row)">删除</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <!-- 评分项管理按钮 -->
    <el-dialog
      class="criterionDialog"
      v-model="criterionVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="评分项管理"
      align-center
      width="825"
      :before-close="cancelCriterion"
    >
      <div class="criterion">
        <el-form
          ref="assessRef"
          :model="assessRuleForm"
          :rules="assessRules"
          label-width="90px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="right"
          status-icon
        >
          <el-form-item label="考核年级 :" prop="grade">
            <el-select
              v-model="assessRuleForm.grade"
              :reserve-keyword="false"
              placeholder="请选择考核年级"
              style="width: 400px"
            >
              <el-option :label="i.name" :value="i.id" v-for="i in gradeData" />
            </el-select>
          </el-form-item>
          <el-form-item label="学期 :" prop="term">
            <el-select
              v-model="assessRuleForm.term"
              placeholder="请选择学期"
              style="width: 400px"
            >
              <el-option
                :label="i.name"
                :value="i.id"
                v-for="i in assessTerm"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="考试类型 :" prop="type">
            <el-select
              v-model="assessRuleForm.type"
              placeholder="请选择考试类型"
              multiple
              style="width: 400px"
            >
              <el-option
                :label="i.name"
                :value="i.id"
                v-for="i in assessType"
              />
            </el-select>
            <span style="margin-left: 10px; font-size: 12px">多选</span>
          </el-form-item>
          <div class="selObject">
            <ul>
              <li class="sel">平均成绩</li>
            </ul>
          </div>
          <el-table
            :row-class-name="tableRowClassName"
            :data="scoreScope.list"
            :header-cell-style="{
              background: 'rgba(240, 243, 247, 1)',
              height: '50px',
            }"
          >
            <el-table-column
              width="160"
              align="center"
              type="index"
              label="序号"
            />
            <el-table-column
              width="208"
              align="center"
              prop="status"
              label="等级"
            >
              <template #default="{ row, index }">
                <el-input
                  :clearable="true"
                  @clear="searchBtn"
                  v-model.trim="row.status"
                  class="grade_right"
                  placeholder="请输入等级"
                  style="width: 180px"
                  v-if="row.flag"
                />
                <span v-else>{{ row.level }}</span>
              </template>
            </el-table-column>
            <el-table-column
              width="230"
              align="center"
              prop="score"
              label="分值区间"
            >
              <template #default="{ row, index }">
                <div class="grade" v-if="row.flag">
                  <el-input
                    :clearable="true"
                    @clear="searchBtn"
                    v-model.trim="row.scoreB"
                    class="grade_left"
                    placeholder="最低区间"
                    style="width: 90px"
                  />
                  <span class="line">-</span>
                  <el-input
                    :clearable="true"
                    @clear="searchBtn"
                    v-model.trim="row.scoreT"
                    class="grade_right"
                    placeholder="最高区间"
                    style="width: 90px"
                  />
                </div>
                <span v-else>{{ row.scoreRange }}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="status" label="操作">
              <template #default="{ index, row }">
                <div class="edit" @click="editScoreScope(index, row)">编辑</div>
              </template>
            </el-table-column>
          </el-table>
          <el-form-item class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="confirmEditCriterion(editCriterionRef)"
            >
              确认
            </el-button>
            <el-button @click="cancelEditCriterion">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>

    <!-- 学科管理按钮 -->
    <el-dialog
      class="objectDialog"
      v-model="objectVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="学科管理"
      align-center
      width="825"
      :before-close="cancelObject"
    >
      <div class="criterion">
        <div class="selObject">
          <!-- <span class="warning">注：只能选择6个维度进行展示</span> -->
          <el-button
            color="rgba(0, 97, 255, 1)"
            class="queding"
            type="primary"
            plain
            @click="addObject"
          >
            新增学科
          </el-button>
        </div>
        <el-table
          :row-class-name="tableRowClassName"
          :data="objectData.list"
          :header-cell-style="{
            background: 'rgba(240, 243, 247, 1)',
            height: '50px',
          }"
        >
          <el-table-column
            width="160"
            align="center"
            type="index"
            label="序号"
          />
          <el-table-column
            width="160"
            align="center"
            prop="name"
            label="学科"
          />
          <el-table-column
            width="208"
            align="center"
            prop="status"
            label="是否展示"
          >
            <template #default="{ row, index }">
              <el-radio-group
                @change="changeObjectShow($event, row)"
                v-model="row.shows"
              >
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
              <!-- <el-checkbox v-model="row.flag" label="1" size="large" />
    <el-checkbox v-model="row.flag" label="2" size="large" /> -->
            </template>
          </el-table-column>

          <el-table-column align="center" prop="status" label="操作">
            <template #default="{ index, row }">
              <el-popconfirm
                width="220"
                confirm-button-text="确认"
                cancel-button-text="取消"
                :icon="InfoFilled"
                icon-color="#f89626"
                title="是否删除此房型?"
                @confirm="delObject(row)"
                @cancel="cancelEvent"
              >
                <template #reference>
                  <div class="edit">删除</div>
                </template>
              </el-popconfirm>
              <!-- <div class="edit" @click="delObject(row)">删除</div> -->
            </template>
          </el-table-column>
        </el-table>

        <!-- <video class="tvhou" width="400" height="250" 
    controls="controls" autoplay="autoplay" 
    x-webkit-airplay="true" x5-video-player-fullscreen="true" 
    preload="auto" playsinline="true" webkit-playsinline 
    x5-video-player-typ="h5"> 
    <source type="application/x-mpegURL" src="http://192.168.161.72:83/openUrl/E1Wp0UU/playback.m3u8?beginTime=20231228T172400&endTime=20231228T172500"> 
</video>  -->
      </div>
      <div class="options">
        <!-- <el-button
          color="rgba(41, 109, 227, 1)"
          class="queding"
          type="primary"
          @click="confirmObject"
        >
          确认
        </el-button> -->
        <!-- <el-button @click="cancelObject">取消</el-button> -->
      </div>
    </el-dialog>

    <!-- 添加项弹窗 -->
    <el-dialog
      class="addItemDialog"
      v-model="addObjectVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="新增学科"
      align-center
      width="550"
      :before-close="cancelAddObject"
    >
      <el-form
        ref="addObjectRef"
        :model="addObjectRuleForm"
        :rules="addObjectRules"
        label-width="100px"
        class="demo-ruleForm"
        :size="formSize"
        label-position="right"
        status-icon
      >
        <el-form-item label="学科 :" prop="object">
          <el-input
            v-model.trim="addObjectRuleForm.object"
            placeholder="请输入学科名称"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="是否展示 :" prop="shows">
          <el-radio-group v-model="addObjectRuleForm.shows">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item class="options">
          <el-button
            color="rgba(41, 109, 227, 1)"
            class="queding"
            type="primary"
            @click="confirmAddObject(addObjectRef)"
          >
            确认
          </el-button>
          <el-button @click="cancelAddObject">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 去评分按钮 -->
    <el-dialog
      class="objectDialog"
      v-model="goScoreVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="评分"
      align-center
      width="825"
      :before-close="cancelGoScore"
    >
      <div class="criterion">
        <div class="selObject">
          <!-- <span class="warning">注：只能选择6个维度进行展示</span> -->
          <el-button
            color="rgba(0, 97, 255, 1)"
            class="queding"
            type="primary"
            plain
            @click="goScoreAddObject"
          >
            新增科目
          </el-button>
        </div>
        <el-table
          :row-class-name="tableRowClassName"
          :data="goScoreData.list"
          :header-cell-style="{
            background: 'rgba(240, 243, 247, 1)',
            height: '50px',
          }"
        >
          <el-table-column
            width="160"
            align="center"
            type="index"
            label="序号"
          />
          <el-table-column
            width="160"
            align="center"
            prop="subjectName"
            label="学科"
          />
          <el-table-column
            width="208"
            align="center"
            prop="scoreNum"
            label="分数"
          >
            <!-- <template #default="{ row, index }"> </template> -->
          </el-table-column>

          <el-table-column align="center" prop="status" label="操作">
            <template #default="{ index, row }">
              <div class="edit">
                <div class="btn" @click="editGoScore(row)">编辑</div>
                <el-popconfirm
                  width="220"
                  confirm-button-text="确认"
                  cancel-button-text="取消"
                  :icon="InfoFilled"
                  icon-color="#f89626"
                  title="是否删除此科目?"
                  @confirm="delGoScore(row)"
                  @cancel="cancelEvent"
                >
                  <template #reference>
                    <div class="btn">删除</div>
                  </template>
                </el-popconfirm>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- <div class="options">
        <el-button
          color="rgba(41, 109, 227, 1)"
          class="queding"
          type="primary"
          @click="confirmObject"
        >
          确认
        </el-button>
        <el-button @click="cancelObject">取消</el-button>
      </div> -->
    </el-dialog>

    <!-- 去评分编辑弹窗 -->
    <el-dialog
      class="addItemDialog"
      v-model="editGoScoreVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :title="editGoScoreTitle"
      align-center
      width="550"
      :before-close="cancelEditGoScore"
    >
      <el-form
        ref="editGoScoreRef"
        :model="editGoScoreRuleForm"
        :rules="editGoScoreRules"
        label-width="100px"
        class="demo-ruleForm"
        :size="formSize"
        label-position="right"
        status-icon
      >
        <el-form-item label="学科 :" prop="subjectName">
          <el-select
            v-model="editGoScoreRuleForm.subjectName"
            class="sel"
            :disabled="editGoScoreTitle == '编辑分数' ? true : false"
            placeholder="请选择学科"
            style="width: 300px"
            :clearable="true"
          >
            <el-option
              :label="i.name"
              :value="i.name"
              v-for="i in objectData.list"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="分数 :" prop="scoreNum">
          <el-input
            v-model.trim="editGoScoreRuleForm.scoreNum"
            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="confirmEditGoScore(addObjectRef)"
          >
            确认
          </el-button>
          <el-button @click="cancelEditGoScore">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 编辑评分等级 -->
    <el-dialog
      class="addItemDialog"
      v-model="editCriterionVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      title="编辑评分等级"
      align-center
      width="550"
      :before-close="cancelEditCriterion"
    >
      <el-form
        ref="editCriterionRef"
        :model="editCriterionRuleForm"
        :rules="editCriterionRules"
        label-width="100px"
        class="demo-ruleForm"
        :size="formSize"
        label-position="right"
        status-icon
      >
        <el-form-item label="等级 :" prop="level">
          <el-input
            v-model.trim="editCriterionRuleForm.level"
            placeholder="请输入等级名称"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="最小分 :" prop="scoreMin">
          <el-input
            v-model.trim="editCriterionRuleForm.scoreMin"
            placeholder="请输入最小分"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="最大分 :" prop="scoreMax">
          <el-input
            v-model.trim="editCriterionRuleForm.scoreMax"
            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="confirmEditCriterion(editCriterionRef)"
          >
            确认
          </el-button>
          <el-button @click="cancelEditCriterion">取消</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: [
    {
      type: "2019-2020秋季学期（下学期）",
      name: "消息平台",
      link: "2020152",
      status: 1,
      describe: "消息平台",
    },
  ],
});

const searchInput = reactive({
  keyWord: "",
  semester: "", // 学期
  grade: "", // 年级
  class: "", // 班级
  appraisal: "", // 测评等级
}); // 搜索按钮数据

const currentPage = ref(1); // 当前页
const pageSize = ref(10);
const total = ref(5); // 当前总数
const selectData = reactive({
  list: [
    { a: 1, b: 2, c: 1, d: 1, e: 1, f: 1, g: 1, h: 1, i: 1, j: 1, k: 1, l: 1 },
  ],
}); // 表格勾选的数据
const semesterData = ref(); //学期下拉数据
const gradeData = ref(); //年级下拉数据
const classsData = ref(); //班级下拉数据
const subjectData = ref(); //学科下拉数据
const examTypeData = ref(); //考试类型数据

// 评分项管理 弹窗 (-------------------------------------------------)
const scoreItemVisible = ref(false);
const scoreItemData = reactive({
  list: [
    {
      grade: "七年级",
      semester: "2023年春季",
      createTime: "2023-04-11 12:20:10",
    },
  ],
});
// 评分项管理中的 新增页面 （------------------------------------------------）
// 考核年级数据上面已设置
const assessTerm = ref([]); // 考核学期数据
const assessType = ref([]); // 考核考试类型数据
const assessRef = ref();
const assessRuleForm = reactive({
  grade: "", // 考核年级
  term: "", // 考核学期
  type: "", // 考核考试类型
  id: "",
});
// 表单验证
const assessRules = reactive({
  grade: [{ required: true, message: "考核年级不能为空", trigger: "blur" }],
  term: [{ required: true, message: "学期不能为空", trigger: "blur" }],
  type: [{ required: true, message: "考试类型不能为空", trigger: "blur" }],
});

// 学生综合素质评价/详情 页面 (----------------------------------------------------)
const pageIndex = ref(1); // 切换到详情页面
const scoreEcharts = ref(); // 评分对比统计图
const studentIndex = ref(1); // 学生详情页面中 综合测评 /教师评语切换
const traComment = ref(); // 教师评语
const studentInfo = ref(); // 学生信息
const studentInfoScore = ref(); // 学生得分（右边表格
const studentObjectList = ref([]); // 学生总学科 （左边雷达图数据种类
const studentObjectListScore = ref([]); // 学生各科分数 （左边雷达图数据分数

// 评分标准按钮 (\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\)
const criterionVisible = ref(false);
const objectIndex = ref(0);
const objectList = reactive({
  list: ["历史"],
});
// 总学科评分表格数据
const allScoreData = reactive({ list: [] });
// 评分表格数据
const scoreScope = reactive({
  list: [
    {
      status: "A",
      scoreT: "80",
      scoreB: "90",
      flag: false,
    },
  ],
});
const criterionTerm = ref(); // 评分学期
// 编辑评分等级（---------------------------）
const editCriterionVisible = ref(false); // 编辑评分等级弹窗
const editCriterionRef = ref();
const editCriterionRuleForm = reactive({
  level: "", // 等级
  scoreMax: "",
  scoreMin: "",
  id: "",
});
const validateScoreMin = (rule, value, callback) => {
  if (/^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/.test(value)) {
    callback();
  } else {
    callback(new Error("请输入正确的分值"));
  }
};
const validateScoreMax = (rule, value, callback) => {
  if (/^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/.test(value)) {
    callback();
  } else {
    callback(new Error("请输入正确的分值"));
  }
};
// 表单验证
const editCriterionRules = reactive({
  level: [{ required: true, message: "等级不能为空", trigger: "blur" }],
  scoreMax: [
    { required: true, message: "最大分不能为空", trigger: "blur" },
    { validator: validateScoreMax, trigger: "blur" },
  ],
  scoreMin: [
    { required: true, message: "最小分不能为空", trigger: "blur" },
    { validator: validateScoreMin, trigger: "blur" },
  ],
});

// 去评分弹窗（——-------------------------------------------）-
const goScoreVisible = ref(false); // 去评分弹窗

// 去评分数据
const goScoreData = reactive({
  list: [
    {
      object: "数学",
      flag: 1,
    },
  ],
});
// 去评分中编辑按钮 （-----------------------）
const editGoScoreVisible = ref(false);
const editGoScoreRef = ref();
const editGoScoreTitle = ref();
const editGoScoreRuleForm = reactive({
  subjectName: "", // 学科
  scoreNum: "", // 分数
  id: "",
});
const goScoreRules = (rule, value, callback) => {
  if (/^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/.test(value)) {
    callback();
  } else {
    callback(new Error("请输入正确的分值"));
  }
};

// 表单验证
const editGoScoreRules = reactive({
  subjectName: [{ required: true, message: "学科不能为空", trigger: "blur" }],
  scoreNum: [
    { required: true, message: "", trigger: "blur" },
    { validator: goScoreRules, trigger: "blur" },
  ],
});

// 学科管理按钮  (--------------------------------------------------------)
const objectVisible = ref(false); // 学科管理弹窗

// 学科管理数据
const objectData = reactive({
  list: [
    {
      object: "数学",
      flag: 1,
    },
  ],
});
const addObjectTerm = ref(); // 添加学科时默认的学期

//新增学科弹窗 (--------------------------------------)
const addObjectVisible = ref(false); // 新增学科弹窗
const addObjectRef = ref();
const addObjectRuleForm = reactive({
  object: "", // 学科
  shows: 0,
  id: "",
});

// 表单验证
const addObjectRules = reactive({
  object: [{ required: true, message: "学科不能为空", trigger: "blur" }],
});

// 学生列表
const getList = async () => {
  loading.value = true;
  let params = {
    currentPage: currentPage.value,
    pageCount: pageSize.value,
  };
  let data = {
    name: searchInput.keyWord,
    term: searchInput.semester,
    gradeName: searchInput.grade.split("-")[0],
    className: searchInput.class,
    scoreLevel: searchInput.appraisal,
  };
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/queryEvaluateStudent",
    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) {
    loading.value = false;
    tableData.list = JSON.parse(eds.decryptDes(res.data.data)).list;
    total.value = JSON.parse(eds.decryptDes(res.data.data)).totalCount;
    // 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,
    });
  }
};
// 获取学期下拉
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,
    JSON.parse(eds.decryptDes(semester.data.data)),
    "学期下拉数据"
  );
  semesterData.value = JSON.parse(eds.decryptDes(semester.data.data));
};

// 年级数据下拉、、学科下拉、考试类型下拉
const classDataList = async () => {
  semesterList();
  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));
  // classInfoList()// 班级下拉数据
  // let subject = await axios({
  //   method: "get",
  //   url: api.value + "/wanzai/api/smartScore/querySubjects",
  //   headers: {
  //     // token: sessionStorage.getItem("token"),
  //     // user_head: sessionStorage.getItem("userhead"),
  //   },
  //   // params: data,
  // });
  // console.log(
  //   subject,
  //   JSON.parse(eds.decryptDes(subject.data.data)),
  //   "学科下拉数据"
  // );
  // subjectData.value = JSON.parse(eds.decryptDes(subject.data.data));
  // let examType = await axios({
  //   method: "get",
  //   url: api.value + "/wanzai/api/smartScore/queryExamTypes",
  //   headers: {
  //     // token: sessionStorage.getItem("token"),
  //     // user_head: sessionStorage.getItem("userhead"),
  //   },
  //   // params: data,
  // });
  // console.log(
  //   examType,
  //   JSON.parse(eds.decryptDes(examType.data.data)),
  //   "考试类型下拉数据"
  // );
  // examTypeData.value = JSON.parse(eds.decryptDes(examType.data.data));
};

// 改变年级选择
const yearClassChange = async (value) => {
  console.log(value);
  let arr = value.split("-");
  if (value) {
    classInfoList(arr[1]);
  } else {
    classsData.value = [];
    searchInput.class = "";
  }
  getList();
};

// 班级数据下拉
const classInfoList = async (value) => {
  let data = {
    gradeId: value,
  };
  let classs = await axios({
    method: "get",
    url: api.value + "/wanzai/api/smartClass/querySmartClasss",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(
    classs,
    JSON.parse(eds.decryptDes(classs.data.data)),
    "班级下拉数据"
  );
  classsData.value = JSON.parse(eds.decryptDes(classs.data.data));
};

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

const handleSelectionChange = () => {};

// 评分项管理（-----------------------------------------------）
const scoreItemClick = () => {
  scoreItemVisible.value = true;
  scoreItemList();
};
// 评分项管理数据
const scoreItemList = async () => {
  let data = new FormData();
  data.append("currentPage", 1);
  data.append("pageCount", 200);
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent2/queryTemplatePage",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  // console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "学生信息分页");
  console.log(res, "学生信息分页");
  if (res.data.code == 200) {
    scoreItemData.list = res.data.data.list;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
const cancelScoreItem = () => {
  scoreItemVisible.value = false;
};

//导出功能 (-------------------------------------------------)
const importExcel = async () => {
  // if (searchInput.createTime == null) {
  //   searchInput.createTime = "";
  // }
  // let data = new FormData();
  // data.set("car_number", searchInput.carnumber);
  // data.set("create_time", searchInput.createTime);
  // let res = await axios({
  //   method: "post",
  //   url: api.value + "/carBook/cinfotoExcel.action",
  //   headers: {
  //     token: sessionStorage.getItem("token"),
  //   },
  //   data: data,
  // });
  // // console.log(res, "导出账号");
  // if (res.data.code == 200) {
  //   // const elt = document.createElement("a");
  //   // elt.setAttribute(
  //   //   "href",
  //   //   "https://chtech.ncjti.edu.cn/carstop" + res.data.downurl
  //   // );
  //   // elt.setAttribute("download", "file.png");
  //   // elt.style.display = "none";
  //   // document.body.appendChild(elt);
  //   // elt.click();
  //   var downloadPath = "https://chtech.ncjti.edu.cn/carstop" + res.data.downurl;
  //   console.log("获得地址数据:", downloadPath);
  //   var downloadLink = document.createElement("a");
  //   downloadLink.style.display = "none"; // 使其隐藏
  //   downloadLink.href = downloadPath;
  //   downloadLink.download = "";
  //   downloadLink.click();
  //   document.body.appendChild(downloadLink);
  //   document.body.removeChild(downloadLink);
  //   ElMessage({
  //     type: "success",
  //     showClose: true,
  //     message: res.data.message,
  //     center: true,
  //   });
  // } else {
  //   ElMessage({
  //     type: "error",
  //     showClose: true,
  //     message: res.data.message,
  //     center: true,
  //   });
  // }
};

// 点击查看详情 （---------------------------------------------）
const teacherInfoClick = async (row) => {
  pageIndex.value = 2;
  studentInfo.value = row;

  var formData = new FormData(); // 创建一个formData对象
  formData.append("id", row.id);
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/queryDetailScore",
    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) {
    studentInfoScore.value = JSON.parse(
      eds.decryptDes(res.data.data)
    ).scoreList; // 学生评分信息
    traComment.value = JSON.parse(eds.decryptDes(res.data.data)).scoreComment; // 教师评语
    studentObjectList.value = [];
    studentObjectListScore.value = [];
    studentInfoScore.value.forEach((item) => {
      studentObjectList.value.push({ name: item.subjectName, max: "120" });
      studentObjectListScore.value.push(item.scoreNum);
    });
    nextTick(() => {
      scoreEchart();
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 切换 综合测评 /教师评语
const infoClick = (flag) => {
  studentIndex.value = flag;
  if (flag == 1) {
    nextTick(() => {
      scoreEchart();
    });
  }
};
// 合并表格
const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 3) {
    if (rowIndex == 0) {
      return {
        rowspan: studentInfoScore.value.length,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};
// 取消查看老师详情
const teacherInfoConcel = () => {
  pageIndex.value = 1;
};
// 综合评测雷达图
const scoreEchart = () => {
  scoreEcharts.value = markRaw(
    echarts.init(document.getElementById("scoreEcharts"))
  );
  scoreEcharts.value.setOption({
    // backgroundColor: "#0A2E5D",
    tooltip: {},

    radar: {
      radius: "50%", //大小
      nameGap: 30, // 图中工艺等字距离图的距离
      center: ["50%", "50%"], // 图的位置
      name: {
        textStyle: {
          color: "rgba(0,0,0, 1)",
          fontSize: 16,
        },
        formatter: function (name) {
          return name;
        },
      },
      // indicator: [ { name: "语文", max: "120" },],
      indicator: studentObjectList.value,
      axisLine: {
        lineStyle: {
          color: "rgba(152, 161, 177, 0.3)",
        },
        show: true,
        symbolSize: [20, 15],
        symbol: ["none", "arrow"],
        symbolOffset: [0, 15],
      },
      splitArea: {
        show: false,
        areaStyle: {
          color: "rgba(255,0,0,0)", // 图表背景的颜色
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          width: 2,
          color: "rgba(152, 161, 177, 0.3)", // 设置网格的颜色
        },
      },
    },

    series: [
      {
        name: "综合测评分析",
        type: "radar",
        symbol: "angle",
        itemStyle: {
          normal: {
            areaStyle: { type: "default" },
          },
        },
        data: [
          {
            symbol: "circle",
            symbolSize: 0,
            value: studentObjectListScore.value,
            // areaStyle: { color: "rgba(64, 205, 241, 0.2)" },
            // itemStyle: {
            //   normal: {
            //     borderWidth: 1,
            //     color: "RGBA(255,255,255,1)",
            //     borderColor: "rgba(146, 225, 255, 1)",
            //   },
            // },
            lineStyle: {
              color: "rgba(0, 97, 255, 0.5)",
              width: 2,
            },
            areaStyle: {
              // 单项区域填充样式
              color: {
                type: "linear",
                x: 0, //右
                y: 0, //下
                x2: 1, //左
                y2: 1, //上
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 173, 252, 1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 130, 252, 1)",
                  },
                ],
                global: false,
              },
              opacity: 0.5, // 区域透明度
            },
          },
        ],
      },
    ],
  });
};
// 去评分按钮(----------------------------------------------)
const goScore = async () => {
  goScoreVisible.value = true;
  scoreInfo();
};
// 查看学生信息得分
const scoreInfo = async () => {
  var formData = new FormData(); // 创建一个formData对象
  formData.append("id", studentInfo.value.id);
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/queryDetailScore",
    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) {
    goScoreData.list = JSON.parse(eds.decryptDes(res.data.data)).scoreList; // 学生评分信息
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

const cancelGoScore = () => {
  goScoreVisible.value = false;
};
// 去评分中编辑按钮 (-----------------------------------------)
const editGoScore = (row) => {
  editGoScoreTitle.value = "编辑分数";
  editGoScoreVisible.value = true;
  editGoScoreRuleForm.subjectName = row.subjectName;
  editGoScoreRuleForm.scoreNum = row.scoreNum;
  editGoScoreRuleForm.id = row.id;
};
// 去评分中新增科目
const goScoreAddObject = () => {
  editGoScoreTitle.value = "新增分数";
  editGoScoreVisible.value = true;
  editGoScoreRuleForm.subjectName = "";
  editGoScoreRuleForm.scoreNum = "";
  editGoScoreRuleForm.id = "";
  objectDataList(); // 下拉项学科管理数据
  nextTick(() => {
    editGoScoreRef.value.resetFields();
  });
};
// 去评分编辑中的 增删改操作
const confirmEditGoScore = async () => {
  if (editGoScoreTitle.value == "编辑分数") {
    goScoreData.list.forEach((item) => {
      if (item.id == editGoScoreRuleForm.id) {
        item.scoreNum = editGoScoreRuleForm.scoreNum;
      }
    });
  } else if (editGoScoreTitle.value == "新增分数") {
    let flag = goScoreData.list.some((item) => {
      return item.subjectName == editGoScoreRuleForm.subjectName;
    });
    if (flag) {
      ElMessage({
        type: "warning",
        showClose: true,
        message: "重复新增学科",
        center: true,
      });
      return false;
    } else {
      let arritem = {
        id: null, // 新增为null
        subjectName: editGoScoreRuleForm.subjectName,
        scoreNum: editGoScoreRuleForm.scoreNum,
        deleted: 0,
      };
      goScoreData.list.push(arritem);
    }
  } else {
    // 教师修改评语时触发
    goScoreData.list = studentInfoScore.value;
  }
  let data = {
    id: studentInfo.value.id, // 学生信息ID
    scoreComment: traComment.value,
    scoreList: goScoreData.list,
  };
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/evaluateScore",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  console.log(res, "评分编辑增删改");
  if (res.data.code == 200) {
    editGoScoreVisible.value = false;
    scoreInfo(); // 更新去评分中的数据
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
const cancelEditGoScore = () => {
  editGoScoreVisible.value = false;
  editGoScoreRuleForm.subjectName = "";
  editGoScoreRuleForm.scoreNum = "";
  editGoScoreRuleForm.id = "";
  editGoScoreRef.value.resetFields();
};

// 去评分中删除按钮 (-----------------------------------------)
const delGoScore = async (row) => {
  goScoreData.list.forEach((item) => {
    if (item.id == row.id) {
      item.deleted = 1;
    }
  });
  confirmEditGoScore();
};

// 点击详情里面的评分标准按钮 （----------------------------------------------------------------）
const criterionClick = () => {
  criterionVisible.value = true;
  objectIndex.value = 0;
  criterionDataList(objectIndex.value); // 评分标准数据
};
// 评分标准数据
const criterionDataList = async (value) => {
  objectIndex.value = value;
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/querySubjectRule",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
  });
  console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "评分标准数据");
  if (res.data.code == 200) {
    objectList.list = [];
    JSON.parse(eds.decryptDes(res.data.data)).smartSubjectRuleInLists.forEach(
      (item) => {
        objectList.list.push(item.subjectName);
      }
    );
    allScoreData.list = JSON.parse(
      eds.decryptDes(res.data.data)
    ).smartSubjectRuleInLists;
    scoreScope.list = allScoreData.list[objectIndex.value].subjectRuleList;
    criterionTerm.value = JSON.parse(
      eds.decryptDes(res.data.data)
    ).smartSubjectRuleInLists[0].term;
    console.log(scoreScope.list, "标准评分表格");
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 标准评分里面的学科
const objectSelClick = (item, index) => {
  objectIndex.value = index;
  scoreScope.list = allScoreData.list[index].subjectRuleList;
  console.log(scoreScope.list, "标准评分表格");
};
const cancelCriterion = () => {
  criterionVisible.value = false;
};

// 编辑评分等级（----------------------------------------）
const editScoreScope = (index, row) => {
  console.log(row, "编辑等级");
  editCriterionVisible.value = true;
  editCriterionRuleForm.level = row.level;
  editCriterionRuleForm.id = row.id;
  let arr = row.scoreRange.split("-");
  editCriterionRuleForm.scoreMin = arr[0];
  editCriterionRuleForm.scoreMax = arr[1];
};
const confirmEditCriterion = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
      // 判断添加的学科是否有重复

      // let flag = scoreScope.list.some((ind, item) => {
      //   if (editCriterionRuleFormIndex.value != ind) {
      //     return item.level == editCriterionRuleForm.level;
      //   }
      // });
      // console.log(flag, "判断编辑的等级是否有重复");
      // if (flag) {
      //   ElMessage({
      //     type: "warning",
      //     showClose: true,
      //     message: "重复添加学科",
      //     center: true,
      //   });
      // } else {
      //   console.log("没重复等级");

      // }
      // console.log(scoreScope.list);
      // }
      if (editCriterionRuleForm.scoreMin < editCriterionRuleForm.scoreMax) {
        scoreScope.list.forEach((item, index) => {
          if (item.id == editCriterionRuleForm.id) {
            item.level = editCriterionRuleForm.level;
            item.scoreRange = `${editCriterionRuleForm.scoreMin}-${editCriterionRuleForm.scoreMax}`;
          }
        });
        allScoreData.list[objectIndex.value].subjectRuleList = scoreScope.list;
        console.log(scoreScope.list, allScoreData.list);

        let data = { smartSubjectRuleInLists: allScoreData.list };
        let res = await axios({
          method: "post",
          url:
            api.value +
            "/wanzai/api/smartEvaluateStudent/operateSmartSubjectRule",
          headers: {
            // token: sessionStorage.getItem("token"),
            // user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "评分管理-新增/更新/删除");
        if (res.data.code == 200) {
          editCriterionVisible.value = false;
          criterionDataList(objectIndex.value); // 重新调用学科数据
          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: "warning",
          showClose: true,
          message: "最大分应大于最小分",
          center: true,
        });
      }
    }
  });
};
const cancelEditCriterion = () => {
  editCriterionVisible.value = false;
};

// 点击查看详情里面的学科管理 （---------------------------------------------------------------------）
const objectClick = async () => {
  objectVisible.value = true;
  objectDataList();
};
// 学科数据
const objectDataList = async () => {
  let res = await axios({
    method: "post",
    url: api.value + "/wanzai/api/smartEvaluateStudent/querySubjectManage",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
  });
  console.log(res, JSON.parse(eds.decryptDes(res.data.data)), "学科管理");
  if (res.data.code == 200) {
    objectData.list = JSON.parse(eds.decryptDes(res.data.data)).subjectList;
    addObjectTerm.value = JSON.parse(
      eds.decryptDes(res.data.data)
    ).subjectList[0].term;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

const confirmObject = () => {
  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;
          }
        }
      });
    }
  });
};
// 删除学科
const delObject = async (row) => {
  objectData.list.forEach((item) => {
    if (item.name == row.name) {
      item.deleted = 1;
    }
  });
  let data = { subjectList: objectData.list };
  let res = await axios({
    method: "post",
    url:
      api.value + "/wanzai/api/smartEvaluateStudent/operateSmartSubjectManage",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  console.log(res, "学科管理-新增/更新/删除");
  if (res.data.code == 200) {
    addObjectVisible.value = false;
    objectDataList(); // 重新调用学科数据
    ElMessage({
      type: "successs",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 是否展示学科
const changeObjectShow = async (val, row) => {
  let dataArr = JSON.parse(JSON.stringify(objectData.list));
  dataArr.forEach((item) => {
    if (item.name == row.name) {
      item.shows = val;
    }
  });
  let data = { subjectList: dataArr };
  let res = await axios({
    method: "post",
    url:
      api.value + "/wanzai/api/smartEvaluateStudent/operateSmartSubjectManage",
    headers: {
      // token: sessionStorage.getItem("token"),
      // user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  console.log(res, "学科管理-新增/更新/删除");
  if (res.data.code == 200) {
    addObjectVisible.value = false;
    objectDataList(); // 重新调用学科数据
    ElMessage({
      type: "successs",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    objectDataList();
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

const cancelObject = () => {
  objectVisible.value = false;
};

// 点击新增学科按钮 (===---------------------------------------)
const addObject = () => {
  addObjectVisible.value = true;
  addObjectRuleForm.object = "";
  addObjectRuleForm.shows = 0;
  // objectDataList();
  nextTick(() => {
    addObjectRef.value.resetFields();
  });
};
const confirmAddObject = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
      // 判断添加的学科是否有重复
      let flag = objectData.list.some((item) => {
        return item.name == addObjectRuleForm.object;
      });
      console.log(flag, "判断添加的学科是否有重复");
      if (flag) {
        ElMessage({
          type: "warning",
          showClose: true,
          message: "重复添加学科",
          center: true,
        });
      } else {
        let dataArr = JSON.parse(JSON.stringify(objectData.list));
        let arr = {
          id: null, // 新增ID为null，更新或删除ID为查询的值
          name: addObjectRuleForm.object,
          term: addObjectTerm.value, // 学期
          shows: addObjectRuleForm.shows, // 1显示,0不显示
          deleted: 0, // 未删除：0；删除：1
        };
        dataArr.push(arr);
        let data = { subjectList: dataArr };
        let res = await axios({
          method: "post",
          url:
            api.value +
            "/wanzai/api/smartEvaluateStudent/operateSmartSubjectManage",
          headers: {
            // token: sessionStorage.getItem("token"),
            // user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "学科管理-新增/更新/删除");
        if (res.data.code == 200) {
          addObjectVisible.value = false;
          objectDataList(); // 重新调用学科数据
          ElMessage({
            type: "successs",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    }
  });
};
const cancelAddObject = () => {
  addObjectVisible.value = false;
};

// 表格斑马纹颜色修改
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();
  classDataList();
  if (scoreEcharts.value) {
    window.addEventListener("resize", function () {
      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% - 175px);
    flex: 1;
    overflow: auto;
  }
  .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;
    }
  }
  .footer {
    width: 96%;
    height: calc(100% - 70px);
    margin: 10px auto;

    .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;
      // }
    }
  }

  // 教师综合素质评价
  .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;
          height: 60px;
          line-height: 60px;
          text-align: center;
          color: rgba(0, 0, 0, 1);
        }
        .score {
          height: 168px;
          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: 90px;
              height: 90px;
              margin: 0 20px;
              border-radius: 50%;
              border: 1px solid rgba(0, 97, 255, 1);
            }
            .info {
              .info_name {
                .name {
                  font-size: 20px;
                  color: #000;
                }
                .class {
                  font-size: 16px;
                  color: rgba(128, 128, 128, 1);
                }
              }
              .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 {
        height: calc(100% - 228px);

        .changeInfo {
          span {
            display: inline-block;
            margin-right: 20px;
            height: 58px;
            line-height: 58px;
            cursor: pointer;
          }
          .sel_info {
            color: rgba(0, 97, 255, 1);
            border-bottom: 2px solid rgba(0, 97, 255, 1);
          }
        }
        // 详情下面的切换样式
        .synthesis {
          display: flex;
          align-items: center;
          height: calc(100% - 60px);
          color: rgb(0, 0, 0);
          font-size: 20px;
          font-weight: 600;
          // 综合测评
          .score_footer {
            width: 100%;
            height: 100%;
            display: flex;
            .footer_left {
              width: 40%;
              height: 100%;
              #scoreEcharts {
                width: 100%;
                height: 100%;
              }
            }
            .footer_right {
              width: 60%;
              height: 100%;
              .title {
                display: flex;
                align-items: center;
                flex-direction: row-reverse;
                .btn {
                  margin: 15px 10px 25px 10px;
                }
                .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: calc(100% - 92px);
                :deep(.el-table__header-wrapper) {
                  font-size: 14px;
                  .cell {
                    color: #000;
                  }
                }

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

                  td {
                    padding: 0;
                    border-right: 1px solid rgba(230, 230, 230, 1);
                    &:nth-child(1) {
                      border-left: 1px solid rgba(230, 230, 230, 1);
                    }
                  }
                  &:hover {
                    td {
                      // background-color: rgba(223, 236, 254, 0.6);
                      background-color: transparent;
                    }
                  }
                }
              }
            }
          }
          // 教师评语
          .teacher_footer {
            width: 100%;
            height: 100%;
            .info {
              margin: 20px 0 25px;
              display: flex;

              .info_img {
                display: flex;
                align-items: center;
                img {
                  width: 50px;
                  height: 50px;
                  border-radius: 50%;
                  border: 1px solid rgba(0, 97, 255, 1);
                  margin: 0 16px 0 0;
                }
              }
              .info_content {
                .info_name {
                  font-weight: 400;
                  margin-bottom: 5px;
                }
                .info_time {
                  font-size: 12px;
                  font-weight: 400;
                }
              }
            }
            .comment {
              height: calc(100% - 118px);
              .el-textarea {
                height: 100%;
                :deep(.el-textarea__inner) {
                  height: 100%;
                }
              }
            }
          }
        }
      }
    }
  }

  // 评分项管理
  :deep(.scoreItemDialog) {
    height: 600px;
    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 {
      height: 100%;
      padding: 15px 30px;
      .selObject {
        margin-bottom: 10px;
      }
      .el-table--fit {
        height: calc(100% - 150px);
        .el-table__header-wrapper {
          font-size: 14px;
          .cell {
            color: #000;
          }
        }

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

          td {
            padding: 0;
            border-right: 1px solid rgba(230, 230, 230, 1);
            &:nth-child(1) {
              border-left: 1px solid rgba(230, 230, 230, 1);
            }
          }
          .option {
            display: flex;
            align-items: center;
            justify-content: center;
            .edit {
              color: rgba(0, 97, 255, 1);
              cursor: pointer;
              padding-right: 10px;
            }
          }
        }
      }
      .options {
        margin: 30px 20px 0 0;
        width: 100%;
        display: flex;
        flex-direction: row-reverse;

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

  // 去评分按钮
  :deep(.criterionDialog) {
    //   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: 15px 30px 30px 30px;
      .criterion {
        .selObject {
          ul {
            display: flex;
            list-style: none;
            padding: 0;
            li {
              width: 70px;
              height: 37px;
              text-align: center;
              line-height: 37px;
              padding: 0;
              margin-right: 10px;
              border-radius: 5px;
              background: rgba(242, 242, 242, 1);
              border: 1px solid rgba(204, 204, 204, 1);
              color: rgba(166, 166, 166, 1);
              cursor: pointer;
            }
            .sel {
              color: rgba(0, 97, 255, 1);
              background: rgba(235, 242, 255, 1);
              border: 1px solid rgba(0, 97, 255, 1);
            }
          }
        }
        .el-table--fit {
          height: calc(100% - 92px);
          .el-table__header-wrapper {
            font-size: 14px;
            .cell {
              color: #000;
            }
          }

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

            td {
              padding: 0;
              border-right: 1px solid rgba(230, 230, 230, 1);
              &:nth-child(1) {
                border-left: 1px solid rgba(230, 230, 230, 1);
              }
            }
            .edit {
              color: rgba(0, 97, 255, 1);
              cursor: pointer;
            }
            .grade {
              display: flex;
              justify-content: center;
              .el-input {
                .el-input__wrapper {
                  box-shadow: none;
                }
              }
              .grade_left {
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
                border-left: 1px solid #dcdfe6;
                border-top-left-radius: 4px;
                border-bottom-left-radius: 4px;
              }
              .line {
                display: block;
                height: 32px;
                line-height: 32px;
                padding: 0 8px;
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
              }
              .grade_right {
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
                border-right: 1px solid #dcdfe6;
                border-top-right-radius: 4px;
                border-bottom-right-radius: 4px;
              }
            }
            &:hover {
              td {
                // background-color: rgba(223, 236, 254, 0.6);
                background-color: transparent;
              }
            }
          }
        }
      }
      .options {
        margin: 30px 20px 0 0;
        width: 100%;
        display: flex;
        flex-direction: row-reverse;
        .el-form-item__content {
          flex: none;
        }
        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }

  // 学科管理按钮
  :deep(.objectDialog) {
    //   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: 0 30px 30px 30px;
      .criterion {
        .selObject {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 15px 0;
          .warning {
            color: rgba(212, 48, 48, 1);
            font-size: 12px;
          }
        }
        .el-table--fit {
          height: 400px;
          .el-table__header-wrapper {
            font-size: 14px;
            .cell {
              color: #000;
            }
          }

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

            td {
              padding: 0;
              border-right: 1px solid rgba(230, 230, 230, 1);
              &:nth-child(1) {
                border-left: 1px solid rgba(230, 230, 230, 1);
              }
            }
            .edit {
              color: rgba(0, 97, 255, 1);
              cursor: pointer;
              display: flex;
              align-items: center;
              justify-content: center;
              .btn {
                margin: 0 10px;
              }
            }
            .grade {
              display: flex;
              justify-content: center;
              .el-input {
                .el-input__wrapper {
                  box-shadow: none;
                }
              }
              .grade_left {
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
                border-left: 1px solid #dcdfe6;
                border-top-left-radius: 4px;
                border-bottom-left-radius: 4px;
              }
              .line {
                display: block;
                height: 32px;
                line-height: 32px;
                padding: 0 8px;
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
              }
              .grade_right {
                border-top: 1px solid #dcdfe6;
                border-bottom: 1px solid #dcdfe6;
                border-right: 1px solid #dcdfe6;
                border-top-right-radius: 4px;
                border-bottom-right-radius: 4px;
              }
            }
            &:hover {
              td {
                // background-color: rgba(223, 236, 254, 0.6);
                background-color: transparent;
              }
            }
          }
        }
      }
      .options {
        margin: 30px 20px 0 0;
        width: 100%;
        display: flex;
        flex-direction: row-reverse;

        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }
  :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>
