<!-- 活动解析 -->
<template>
  <div>
    <!-- table 表格 -->
    <el-row :gutter="20" class="main-items" >

      <!--数据监控homeworkRecoveryList.list-->
      <el-col :span="20" class="main" :offset="2">

        <el-table
          :data="homeworkRecoveryList.list"
          :header-cell-class-name="tableheaderClassName"
          :header-cell-style="{
          'color': '#999999',
          'font-size': '16px'
           }"
          size="medium"
          stripe
        >
          <el-table-column
            label="上传时间"
            prop="createTime"
            header-align="center"
          >
          </el-table-column>
          <el-table-column
            prop="subject"
            label="科目"
            header-align="center"
          >
          </el-table-column>
           <el-table-column
            prop=""
            label="类型"
            header-align="center"
          > <template slot-scope="scope">
              <span >{{scope.row.type==8?'批改作业':'匹配知识点作业'}}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="studentName"
            label="学生"
            header-align="center"
          ></el-table-column>
          <el-table-column
            prop="uncorrectedCount"
            label="未批改张数"
            header-align="center">
          </el-table-column>
          <el-table-column
            prop=""
            label="是否有补拍"
            header-align="center"
          >
            <template slot-scope="scope">
              <span >{{scope.row.ownReplenish==1?'有':'否'}}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop=""
            label=""
            header-align="center"
            width="450"
          >
            <template slot-scope="scope">
                <span class="allocation" @click="isShow(scope.row.grade,scope.row.subject,scope.row.homeworkId,scope.row.type)">去分配</span>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页显示 -->
        <div class="pages" v-if="parseInt(homeworkRecoveryList.pages) > 0">
          <el-pagination
            background
            @size-change="handleSizeChange1"
            @current-change="pageChange1"
            :page-sizes="[10]"
            layout="total,prev, pager, next"
            :total= parseInt(homeworkRecoveryList.pages)
          ></el-pagination>
        </div>
      </el-col>

    </el-row>


    <!--弹框-->
    <!--所有未批改可分配老师列表弹框-->
    <div class="showModel" @click="allShowModel(2)" v-if="isPigai"></div>
    <div class="model" style="width:50%" v-if="isPigai">
      <div class="model-text" style="padding: 0 30px">
        <div class="model-manager">
          <div>作业可分配老师</div>
          <div>
            <img src="../../assets/img/del@2x.png" alt @click="allShowModel(2)">
          </div>
        </div>
        <div class="allocation-items" v-for="(v, k) in TeacherAllotList.list" :key="k" >
          <div class="model-items-left">
            <div class="model-items-left-top">
              <div style="float:left;">
                <img
                  :src="BASE_URL + v.imgUrl"
                  v-if="v.imgUrl"
                  alt
                  class="model-items-left-top-img"
                >
                <img
                  src="../../assets/img/user.jpg"
                  v-if="!v.imgUrl"
                  alt
                  class="model-items-left-top-img"
                >
                <div style="display: inline-block;text-align: left;">
                  <div style="font-size: 24px;margin-left: 10px">{{v.name}}</div>
                  <div class="model-items-left-top-number">等待张数：{{v.waitCount}}</div>
                </div>
              </div>
              <div style="margin-right:10px;float:right;">
                <el-button
                  @click="GOtoTeacherAllot(v)"
                  type="success"
                >分配</el-button>
              </div>
            </div>
          </div>
        </div>
        <div class="pages">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="pageChange"
            :page-sizes="[10]"
          layout="total, prev, pager, next"
            :total="parseInt(TeacherAllotList.pages)"
          ></el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import { mapGetters, mapActions } from "vuex";
 import { IMG_BASE_URL, APPOR_BASE_URL } from "@/config";
  export default {
    components: { },
    name: "actvResolveLabel",
    props: {},
    data() {
      return {
        BASE_URL:IMG_BASE_URL,
        selMonth:'',
        hiddenModel:false,
        isPigai:false,
        // homeworkRecoveryList:{
        //   list:[
        //     {
        //       createTime:1111,
        //       subject:'英语',
        //       studentName:4621,
        //       ownReplenish:888,
        //       uncorrectedCount:1,
        //       grade:'一年级',
        //       homeworkId:'1545623108745210'
        //     },
        //   ],
        // },
        filters: {
          actvNm: "",
          actvCrtUserId: "",
          actvType: "",
          actvSmallType: "",
          // 排序
          MaxtimeValue:'',
          oneMonth:'',
          pageNo: 1,
          pageSize: 10,
          count: 0,
          orderField: "",
          orderAD: ""
        },
        allotList:{
          pageNo: 1,
          pageSize: 10,
          count: 0,
          grade:'',
          subject:'',
          homeworkId:'',
          TeacherType:''
        }
      };
    },
    watch: {},
  // ,'homeworkRecoveryList'
    computed: {
      ...mapGetters(["getUser",'homeworkRecoveryList','TeacherAllotList'])
    },
    methods: {
      ...mapActions(["setUser"]),
      // 表格头部样式
      tableheaderClassName({ row, rowIndex }) {
        return "table-head-th";
      },
      //弹框
      isShow(str,t,id,type){
          this.isPigai = true;
          this.allotList.grade = str;
          this.allotList.subject = t;
          this.allotList.homeworkId = id
            this.allotList.TeacherType = type
          this.TeacherAllot()
      },
      //关闭弹框
      allShowModel(str) {
        let _this = this;
        if (str == 1){
          _this.hiddenModel = false;
        } else if (str == 2){
          _this.isPigai = false;
        }
      },
      //时间封装
      formatDate: function () {
        let date = new Date();
        let y = date.getFullYear();
        let MM = date.getMonth() + 1;
        MM = MM < 10 ? ('0' + MM) : MM;
        let d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        let h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        let m = date.getMinutes();
        m = m < 10 ? ('0' + m) : m;
        let s = date.getSeconds();
        s = s < 10 ? ('0' + s) : s;
        return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
      },
      //作业回收站列表
      async HomeworkRecoveryList() {
        this.$store.dispatch("HomeworkRecoveryList", {
          pageNo: this.filters.pageNo,
          pageSize: this.filters.pageSize,
          maxCreateTime: this.formatDate()
        });
      },
      // 可分配老师列表
      async TeacherAllot() {
        this.$store.dispatch("TeacherAllotList", {
          grade: this.allotList.grade,
          subject: this.allotList.subject,
          type:this.allotList.TeacherType,
          maxCreateTime: this.formatDate(),
          pageNo: this.allotList.pageNo,
          originTeacherId:"",
          pageSize: this.allotList.pageSize
        });
      },
      // 分配老师
      async GOtoTeacherAllot(v) {
        this.$store.dispatch("toTeacherAllot", {
          teacherId: v.teacherId,
            type:this.allotList.TeacherType,
           originTeacherId:"",
          homeworkId: this.allotList.homeworkId
        });
        this.isPigai = false
        this.$store.dispatch("GetRemindCountInfo", {});
      },
      // 分页
      pageChange(val) {
        this.allotList.pageNo = val;
        this.TeacherAllot();
      },
      pageChange1(val) {
        this.filters.pageNo = val;
        this.HomeworkRecoveryList();
      },
      changeDateSlot(dateSlot) {
        if (dateSlot) {
          this.filters.startDate = dateSlot[0];
          this.filters.endDate = dateSlot[1];
        } else {
          this.filters.startDate = null;
          this.filters.endDate = null;
        }
      },
      actvTypeChange(typeList) {
        switch (typeList.length) {
          case 1:
            this.filters.actvType = typeList[0];
            this.filters.actvSmallType = null;
            break;
          case 2:
            this.filters.actvType = null;
            this.filters.actvSmallType = typeList[1];
            break;
          default:
            this.filters.actvType = null;
            this.filters.actvSmallType = null;
            break;
        }
      },
      handleSizeChange(val) {
        this.allotList.pageSize = val;
        this.TeacherAllot();
      },
      handleSizeChange1(val) {
        this.filters.pageSize = val;
        this.HomeworkRecoveryList();
      },
      // 排序
      sortChange(sort) {
        this.filters.orderField = sort.prop;
        this.filters.orderAD = sort.order != null ? sort.order : "";
        this.itemListReshow();
      },
      clearSearch() {
        this.filters.actvNm = null;
        this.filters.actvCrtUserId = null;
        this.filters.actvType = null;
        this.filters.actvSmallType = null;
        this.filtersActvType = [];
        this.createDateSlot = null;
      },

    },
    mounted() {
      sessionStorage.setItem('tabIndex',3);
      this.HomeworkRecoveryList()
    }
  };
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>

  .main{
    background-color: #fff;
    margin-top: 16px;
    padding: 0 !important;
    border: 1px solid #E1E1E1;
    min-height: 980px;
  }

  el-table{
    color: #999999;
    font-size: 18px;
  }
  .main-items{
    color: #393939;
    text-align: center;
    line-height: 80px;
  }


  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }

  .showModel {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: #000000;
    opacity: 0.2;
    overflow: hidden;
    z-index: 1000;
    color: #fff;
  }
  .model {
    z-index: 10000;
    width: 60%;
    height: auto;
    position: fixed;
    top: 15%;
    left: 30%;
    margin: auto;
    background: #fff;
    border-radius: 10px;
    text-align: center;
  }

  .model-text {
    background: rgba(255, 255, 255, 1);
    border-radius: 10px;
    overflow: hidden;
  }

  .model-items-left {
    /* float:left; */
    width: 100%;
    color: #393939;
    font-size: 24px;
    height: 100px;
  }
  .model-items-left-top {
    display: flex;
    justify-content: space-between;
  }

  .model-items-left-top-img {
    width: 68px;
    height: 68px;
    border-radius: 8px;
    position: relative;
    bottom: 25px;
  }
  .model-items-left-top-number {
    color: #7e7e7e;
    font-size: 18px;
    margin-left: 10px;
  }

  .el-table .table-head-th{
    background-color:#F6F7FB;
    font-size: 16px !important;
    color: #393939;

  }
  .model-manager {
    display: flex;
    justify-content: space-between;
    margin: 30px;
    color: #393939;
    font-size: 24px;
  }
  .allocation-items{
    /* float:left; */
    width: 45%;
    display: inline-block;
    margin-right: 20px;
    margin-bottom:30px;
   
  }
  .allocation{
    color: #52CC60;
    font-size: 20px;
    text-decoration: underline;
    cursor: pointer;
  }
.el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color:#52cc60!important;
    color: #fff;
}
  .pages{
    margin: 15px 0;
  }
.el-table td, .el-table th {
    text-align: center!important;
}
</style>
