<style>
  .makeup .el-input__inner {
    border: none !important;
    background: transparent !important;
  }

</style>
<template>
  <div class="page-body makeup">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-input @change="refreshPage" clearable standout="bg-primary text-white" v-model="msg.GuestName" label="学员名称"
            @clear="refreshPage" maxlength="20" />
        </div>
        <div class="col-3">
          <q-input @change="refreshPage" clearable standout="bg-primary text-white" v-model="msg.ClassName" label="班级"
            @clear="refreshPage" maxlength="20" />
        </div>
        <div class="col-3">
          <q-input @change="refreshPage" clearable standout="bg-primary text-white" v-model="msg.CourseName" label="课程"
            @clear="refreshPage" maxlength="20" />
        </div>
        <div class="col-3">
          <q-select @input="refreshPage" standout="bg-primary text-white" v-model="msg.MakeUpStatus" clearable
            option-value="Id" option-label="Name" :options="statusList" emit-value map-options label="处理结果" />
        </div>
        <div class="col-3">
          <div class="col-3 Sysuser_Date">
            <q-field filled>
               <template v-slot:control>
                <el-date-picker v-model="msg.StartDate" type="date" placeholder="开始日期" value-format="yyyy-MM-dd"
                  size="small" style="width:47%;" @change="refreshPage" clear-icon="iconfont icon-guanbi">
                </el-date-picker>至
                <el-date-picker v-model="msg.EndDate" type="date" placeholder="结束日期" value-format="yyyy-MM-dd"
                  size="small" style="width:47%;" @change="refreshPage" clear-icon="iconfont icon-guanbi">
                </el-date-picker>
              </template>
            </q-field>
          </div>
        </div>
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat
        class="sticky-column-table sticky-right-column-table" separator="none" :data="data" :columns="columns"
        row-key="name">
        <template v-slot:top="props">
          <div class="col-2 q-table__title">补课管理</div>
          <q-space />
          <div class="page-option">
          </div>
        </template>
        <template v-slot:body-cell-TeacherName="props">
          <q-td auto-width :props="props">
            <span style="color:#3FC4FF;">{{props.row.TeacherName}}</span>
          </q-td>
        </template>
        <template v-slot:body-cell-ClassDate="props">
          <q-td auto-width :props="props">
            {{props.row.ClassDate}} {{props.row.StartTime}}-{{props.row.EndTime}}
          </q-td>
        </template>
        <!--处理状态-->
        <template v-slot:body-cell-MakeUpStatusStr="props">
          <q-td>
            <span>{{props.row.MakeUpStatusStr}}</span>&nbsp;
            <template v-if="props.row.MakeUpStatus!=1">
              <br /> <span v-if="props.row.DealByName && props.row.DealByName!=''">操作人:{{props.row.DealByName}}</span>
              <br /><span v-if="props.row.DealTime && props.row.DealTime!=''">操作时间{{props.row.DealTime}}</span>
            </template>
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
            :input="true" @input="changePage" />
        </template>
        <template v-slot:body-cell-optioned="props">
          <q-td :props="props">
            <q-btn  flat size="xs" icon="edit" color="accent" style="font-weight:400"
              :label="props.row.MakeUpStatus == 1?'处理':'修改'" @click="isShowEdit=true,getClickItem(props.row)">
              <q-popup-proxy >
                <q-banner v-if="isShowEdit">
                  <div class="calenderDialog">
                    <div style="margin:10px 0 15px 0;">设置处理状态</div>
                    <q-select standout="bg-primary text-white" option-value="Id" option-label="Name"
                      v-model="statusMsg.MakeUpStatus" :options="statusList2" emit-value map-options label="是否可补课" />
                    <q-card-actions align="right" class="bg-white" style="margin-top:20px;">
                      <q-btn label="取消" flat color="grey-10" size="sm" @click="isShowEdit=false"
                        style="font-weight:400 !important" />
                      <q-btn label="确认" color="accent q-px-md" size="sm" style="font-weight:400 !important"
                        @click="setCheckStatus()" />
                    </q-card-actions>
                  </div>
                </q-banner>
              </q-popup-proxy>
            </q-btn>
          </q-td>
        </template>
      </q-table>
    </div>
  </div>
</template>
<script>
  import {
    queryAbsentPage,
    saveMakeUpStatus,
  } from '../../api/course/class';

  export default {
    meta: {
      title: "补课管理"
    },
    components: {

    },
    data() {
      return {
        columns: [{
            name: 'GuestName',
            label: '学员姓名',
            field: 'GuestName',
            align: 'left'
          },
          {
            name: 'ClassName',
            label: '班级',
            field: 'ClassName',
            align: 'left',
          },
          {
            name: 'CourseName',
            label: '课程',
            field: 'CourseName',
            align: 'left'
          },
          {
            name: 'TeacherName',
            label: '带班老师',
            field: 'TeacherName',
            align: 'left'
          },
          {
            name: 'RoomName',
            label: '教室名称',
            field: 'RoomName',
            align: 'left'
          },
          {
            name: 'ClassDate',
            label: '日期',
            field: 'ClassDate',
            align: 'left'
          },
          {
            name: 'GuestStateStr',
            label: '学员状态',
            field: 'GuestStateStr',
            align: 'left'
          },
          {
            name: 'MakeUpStatusStr',
            label: '处理结果',
            align: 'left',
            field: 'MakeUpStatusStr'
          },
          {
            name: 'TimeHour',
            label: '课时长度',
            align: 'left',
            field: 'TimeHour'
          },
          {
            name: 'optioned',
            label: '操作',
            field: 'CourseId'
          }
        ],
        data: [],
        loading: false,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          MakeUpStatus: -1, //(2-已处理，3-未处理)
          GuestName: "", //学员名称
          ClassName: "", //班级名称
          CourseName: "", //课程名称
          TeacherName: "", //老师名称
          RoomName: "", //教室名称
          StartDate: "", //开始日期
          EndDate: "", //结束日期
        },
        pageCount: 0,
        isShowEdit: false, //是否显示修改
        statusList: [{Id: -1,Name: '不限'},{Id: 1,Name: '未处理'}, { Id: 2,Name: '可补课'},{Id: 3,Name: "不可补课"}],
        statusList2: [ { Id: 2,Name: '可补课'},{Id: 3,Name: "不可补课"}],
        statusMsg: {
          Id: 0,
          MakeUpStatus: 2,
          ClassCheckId: 0,
          GuestId: 0,
        },
      }
    },
    created() {

    },
    mounted() {
      let nowDay = new Date();
      var year = nowDay.getFullYear(); //年
      var month = nowDay.getMonth() + 1; //月
      var day = nowDay.getDate(); //日
      var currentDay = year + '-' + month + '-' + day;
      this.msg.StartDate = currentDay
      this.getAbsentPage();
    },
    methods: {
      //翻页
      changePage(val) {
        this.msg.pageIndex = val;
        this.getAbsentPage()
      },
      //获取补课分页列表
      getAbsentPage() {
        this.loading = true;
        queryAbsentPage(this.msg).then(res => {
          this.loading = false;
          this.data = res.Data.PageData;
          this.pageCount = res.Data.PageCount;
        }).catch(() => {
          this.loading = false
        })
      },
      //刷新页面
      refreshPage() {
        this.msg.pageIndex = 1;
        this.getAbsentPage();
      },
      //获取点击项
      getClickItem(item) {
        this.statusMsg.ClassCheckId = item.ClassCheckId;
        this.statusMsg.GuestId = item.OrderGuestId;
        this.statusMsg.Id = item.Id;
        if(item.MakeUpStatus!=1){
          this.statusMsg.MakeUpStatus = item.MakeUpStatus

        }
      },
      clearMsg() {
        this.statusMsg.Id = 0;
        this.statusMsg.MakeUpStatus = 2;
        this.statusMsg.ClassCheckId = 0;
        this.statusMsg.GuestId = 0;
      },
      //设置处理状态
      setCheckStatus() {
        saveMakeUpStatus(this.statusMsg).then(res => {
          if (res.Code == 1) {
            this.isShowEdit = false;
            this.clearMsg();
            this.getAbsentPage()
          }
          this.$q.notify({
            icon: 'iconfont icon-chenggong',
            color: 'accent',
            timeout: 2000,
            message: res.Message,
            position: 'top'
          })
        });
      }
    }
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')

</style>
