<template>
  <div class="app-container" v-loading.fullscreen.lock="fullLoading">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
       <el-form-item label="学院" prop="deptId">
        <el-select v-model="queryParams.deptId" filterable clearable placeholder="请选择学院">
          <el-option v-for="item in deptList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="辅导员姓名" prop="teacherName">
        <el-input v-model="queryParams.teacherName" placeholder="请输入辅导员姓名" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="工号" prop="employeeId">
        <el-input v-model="queryParams.employeeId" placeholder="请输入工号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="学年" prop="stuYearId">
        <el-select v-model="queryParams.stuYearId" placeholder="请选择学年" clearable @keyup.enter.native="handleQuery">
          <el-option v-for="year in yearList" :key="year.id" :label="year.stuYearName" :value="year.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini"   @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="teacherStatusList">
      <el-table-column label="学院" align="center" prop="deptName" width="150" />
      <el-table-column label="辅导员姓名" align="center" prop="teacherName" width="120" />
      <el-table-column label="工号" align="center" prop="employeeId" width="120" />
      <el-table-column label="学年" align="center" prop="stuYearName" width="120" />
      <el-table-column label="是否完成综合测评" align="center" prop="isCompleted" width="150">
        <template slot-scope="scope">
          <el-tag :type="scope.row.isCompleted ? 'success' : 'danger'">
            {{ scope.row.isCompleted ? '已完成' : '未完成' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="待办事项数量" align="center" prop="todoCount" width="120" />
      <el-table-column label="成绩导入状态" align="center" prop="scoreImported" width="120">
        <template slot-scope="scope">
          <el-tag :type="scope.row.scoreImported ? 'success' : 'warning'">
            {{ scope.row.scoreImported ? '已导入' : '未导入' }}
          </el-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column label="备注" align="center" prop="remarks" /> -->
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { getTeacherEvaluationStatus, exportTeacherEvaluationStatus, getDeptNameList } from "@/api/stuCQS/teacher-evaluation-status";
import { getDeptName } from "@/api/system/dept";
import { listAllYear } from "@/api/stuCQS/basedata/year";
import { fullLoading } from "@/api/helpFunc";

export default {
  name: "TeacherEvaluationStatus",
  data() {
    return {
      fullLoading: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 辅导员评价状态表格数据
      teacherStatusList: [],
      // 学院列表
      deptList: [],
      // 学年列表
      yearList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        deptId: null,
        teacherName: null,
        employeeId: null,
        stuYearId: null
      }
    };
  },
  created() {
    this.getList();
    this.getDeptList();
    this.getYearList();
    this.listDept();
  },
  methods: {
     async listDept() {
      let res = await getDeptName();
      this.deptList = [...res.data];
    },
    /** 查询辅导员评价状态列表 */
    async getList() {
      this.loading = true;
      try {
        const response = await getTeacherEvaluationStatus(this.queryParams);
        this.teacherStatusList = response.rows;
        this.total = response.total;
      } catch (error) {
        this.$modal.msgError("查询失败");
      } finally {
        this.loading = false;
      }
    },
    /** 获取学年列表 */
    async getYearList() {
      try {
        const response = await listAllYear();
        if (response.code === 200) {
          this.yearList = response.data;
        }
      } catch (error) {
        console.error("获取学年列表失败", error);
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    async handleExport() {
      this.download('comprehensive/teacherEvaluationStatus/export', {
        ...this.queryParams
      }, `teacherEvaluationStatus_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style scoped>
.app-container {
  padding: 20px;
  color: #333;
}

.el-table {
  color: #333;
}

.el-form-item label {
  color: #333;
}

.el-input input {
  color: #333;
}

.el-select .el-input input {
  color: #333;
}
</style>