<style>
  .examForm .q-table__bottom {
    min-height: 10px;
  }

</style>
<template>
  <div class="page-content examForm">
    <q-table :pagination="pageMsg" :loading="loading" no-data-label="暂无相关数据" flat
      class="sticky-column-table sticky-right-column-table" separator="none" :data="dataList" :columns="columns"
      row-key="name">
      <template v-slot:top>
        <div class="col-2 q-table__title">考试管理</div>
        <q-space />
      </template>
      <template v-slot:body-cell-StartTime="props">
        <q-td :props="props">
          {{ props.row.StartTime }} -- {{ props.row.EndTime }}
        </q-td>
      </template>
      <template v-slot:body-cell-optioned="props">
        <q-td :props="props">
          <!--v-if="props.row.IsEdit==1"-->
          <q-btn flat size="xs"  color="accent" style="font-weight: 400" label="修改" @click="publishExam(props.row)" />
          <q-btn-dropdown flat size="xs" color="dark" label="更多" style="margin-left: 10px">
            <q-list>
              <q-item clickable v-close-popup @click="submitExamAudit(props.row)"
                v-if="props.row.ExamineStatus==0||props.row.ExamineStatus==3||props.row.ExamineStatus==4">
                <q-item-section>
                  <q-item-label>{{props.row.ExamineStatus==0?'提交审核':"重新提交审核"}}</q-item-label>
                </q-item-section>
              </q-item>
              <q-item clickable v-close-popup @click="seeExamineeList(props.row)">
                <q-item-section>
                  <q-item-label>考生管理</q-item-label>
                </q-item-section>
              </q-item>
              <q-item clickable v-close-popup @click="deleteExamPublish(props.row)" v-if="props.row.ExamineStatus!=2">
                <q-item-section>
                  <q-item-label>删除</q-item-label>
                </q-item-section>
              </q-item>
            </q-list>
          </q-btn-dropdown>
        </q-td>
      </template>
      <template v-slot:bottom>
        <div></div>
      </template>
    </q-table>
  </div>
</template>
<script>
  import {
    submitExamApply,
    deletePublishExam
  } from "../../api/teacher/index";
  export default {
    meta: {
      title: "考试管理"
    },
    props: {
      dataList: {
        type: Array,
        default: null
      },
      loading: {
        type: Boolean,
        default: null
      }
    },
    data() {
      return {
        columns: [{
            name: "Id",
            label: "编号",
            field: "Id",
            align: "left",
          },
          {
            name: "PaperName",
            label: "试卷名称",
            field: "PaperName",
            align: "left",
          },
          {
            name: "CreateByName",
            label: "创建人",
            field: "CreateByName",
            align: "left",
          },
          {
            name: "StudentCount",
            label: "考生人数",
            field: "StudentCount",
            align: "left",
          },
          {
            name: "StartTime",
            label: "考试时间",
            field: "StartTime",
            align: "left",
          },
          {
            name: "TestStatusStr",
            label: "考试时长",
            field: "TestStatusStr",
            align: "left",
          },
          {
            name: "ExamTimes",
            label: "考试状态",
            field: "ExamTimes",
            align: "left",
          },
          {
            name: "ReviewerName",
            label: "审核人",
            field: "ReviewerName",
            align: "left",
          },
          {
            name: "ExamineStatusStr",
            label: "状态",
            field: "ExamineStatusStr",
            align: "left",
          },
          {
            name: "optioned",
            label: "操作",
            field: "Id",
          },
        ],
        pageMsg: {
          rowsPerPage: 10,
        },
      }
    },
    created() {},
    mounted() {},
    methods: {
      //删除考卷
      deleteExamPublish(item) {
        var delMsg = {
          Id: item.Id
        };
        var tipMsg = "是否要删除【" + item.PaperName + "】试卷?删除后将无法恢复!";
        this.$q.dialog({
          title: '提示信息',
          message: tipMsg,
          cancel: true,
          persistent: true,
          ok: "确定",
          cancel: "取消",
        }).onOk(() => {
          deletePublishExam(delMsg).then(res => {
            if (res.Code == 1) {
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: '操作成功!',
                position: 'top'
              })
              this.$emit('success');
            }
          });
        })
      },
      //提交申请
      submitExamAudit(item) {
        var msg = {
          Id: item.Id
        };
        submitExamApply(msg).then(res => {
          if (res.Code == 1) {
            this.$q.notify({
              icon: 'iconfont icon-chenggong',
              color: 'accent',
              timeout: 2000,
              message: '操作成功!',
              position: 'top'
            })
            this.$emit('success');
          }
        })
      },
      //修改考试相关
      publishExam(item) {
        this.OpenNewUrl("/exam/paperPublish", {
          Id: item.Id,
        });
      },
      //查看考生列表
      seeExamineeList(item) {
        this.OpenNewUrl("/exam/examineeManager", {
          Id: item.Id,
        });
      },
    }
  }

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

</style>
