<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="70px"
    >
      <el-form-item label="教师姓名" prop="pgdx">
        <el-select
          v-model="queryParams.pgdx"
          clearable
          size="small"
          placeholder="请选择教师"
        >
          <el-option
            v-for="dict in userOptions"
            :key="dict.userId"
            :label="dict.nickName"
            :value="dict.userId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="评估时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          class="my-date-picker"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </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-table v-loading="loading" border :default-sort = "{prop: 'bjpjf', order: 'descending'}" :data="dayflowassessmentList">
      <el-table-column label="评估对象" align="center" prop="pgdxxm" fixed />
      <el-table-column label="最终扣分" align="center" prop="bjpjf" sortable width="110"/>
      <el-table-column label="早间接待" align="center" prop="zjjdpjf" sortable width="110"/>
      <el-table-column label="用餐" align="center" prop="ycpjf" sortable width="80"/>
      <el-table-column label="早间坐圈" align="center" prop="zjzqpjf" sortable width="110"/>
      <el-table-column label="分组教学" align="center" prop="fzjxpjf" sortable width="110"/>
      <el-table-column label="点心时间" align="center" prop="dxsjpjf" sortable width="110"/>
      <el-table-column label="如厕洗手饮水" align="center" prop="rcxsyspjf" sortable width="130"/>
      <el-table-column label="活动过渡" align="center" prop="hdgdpjf" sortable width="110"/>
      <el-table-column label="户外活动" align="center" prop="hwhdpjf" sortable width="110"/>
      <el-table-column label="午睡" align="center" prop="wspjf" sortable width="80"/>
      <el-table-column label="离园再见" align="center" prop="lyzjpjf" sortable width="110"/>
      <el-table-column label="安全" align="center" prop="aqpjf" sortable width="80"/>
      <el-table-column label="自由活动" align="center" prop="zyhdpjf" sortable width="110"/>
      <el-table-column
        label="规则与纪律约束"
        align="center"
        prop="gzyjlyspjf" sortable width="140"
      />
      <el-table-column label="微型课程" align="center" prop="wxkcpjf" sortable width="110"/>
      <el-table-column label="潜课程" align="center" prop="qkcpjf" sortable width="100"/>
    </el-table>

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

    <div class="chart-wrapper">
      <line-chart :queryParams="queryParams" v-if="isRouterAlive" />
    </div>
  </div>
</template>

<script>
import LineChart from "../../dashboard/LineChartTeacherDayFlowAvg";
import { listDayflowassessmentTeacherAvg } from "@/api/benyi/dayflowassessment";
import { listClass } from "@/api/system/class";
import { listUser } from "@/api/system/user";
import { listDetail, getDetail } from "@/api/benyi/dayflow/dayflowmanger";

export default {
  name: "DayflowassessmentTeacherDayFlowAvg",
  components: {
    LineChart,
  },
  data() {
    return {
      //是否重新加载组件
      isRouterAlive: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 幼儿园一日流程评估表格数据
      dayflowassessmentList: [],
      // 班级
      classOptions: [],
      // 学年学期
      xnxqOptions: [],
      // 日期范围
      dateRange: [],
      // 所有教师
      userOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        planid: undefined,
        deptId: undefined,
        classid: undefined,
        bzbh: undefined,
        bzxm: undefined,
        pbbh: undefined,
        pbxm: undefined,
        zlbh: undefined,
        zlxm: undefined,
        xnxq: undefined,
        bzid: undefined,
        kfz: undefined,
        bzmf: undefined,
        zzdf: undefined,
        kfcs: undefined,
        pgdx: undefined,
        classdf: undefined,
        createUserid: undefined,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
    this.getClassList();
    this.getUserList();
    // 获取学年学期
    this.getDicts("sys_xnxq").then((response) => {
      this.xnxqOptions = response.data;
    });
  },
  methods: {
    /** 查询幼儿园一日流程评估列表 */
    getList() {
      this.loading = true;
      listDayflowassessmentTeacherAvg(
        this.addDateRange(this.queryParams, this.dateRange)
      ).then((response) => {
        this.dayflowassessmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 获取班级列表
    getClassList() {
      listClass(null).then((response) => {
        this.classOptions = response.rows;
      });
    },
    // 班级字典翻译
    classFormat(row, column) {
      var actions = [];
      var datas = this.classOptions;
      Object.keys(datas).map((key) => {
        if (datas[key].bjbh == "" + row.classid) {
          actions.push(datas[key].bjmc);
          return false;
        }
      });
      return actions.join("");
    },
    /** 查询用户列表 */
    getUserList() {
      listUser(null).then((response) => {
        this.userOptions = response.rows;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.isRouterAlive = false;
      this.$nextTick(() => (this.isRouterAlive = true));
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
