<!-- 选择试卷 -->
<template>
  <div class="page-container selectTestPaper-addPage">
    <div class="page-form-title-box">
      <el-form :model="queryParams" class="form-box" ref="queryForm"
               :inline="true" style="width:100%;">
        <el-form-item label="" prop="shareStatus">
          <el-select v-model="queryParams.queryParamsData1" placeholder="是否共享" style="width: 120px">
            <el-option label="共享" value="1"/>
            <el-option label="不共享" value="0"/>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="knowledgePointId">
          <el-cascader
            style="width: 180px"
            v-model="queryParams.knowledgePointId"
            :options="optionListC"
            :props="{
                emitPath:false,
                checkStrictly: true,
                value: 'id',
                label: 'knowledgePointName',
                children: 'children',
              }"
            :show-all-levels="false"
            filterable
            placeholder="知识点"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="" prop="disciplineTypeId">
          <el-select v-model="queryParams.disciplineTypeId" placeholder="专业类别" style="width: 140px">
            <el-option
              v-for="dict in optionListD"
              :key="dict.id"
              :label="dict.disciplineName"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="deptId">
          <el-cascader
            style="width: 180px"
            v-model="queryParams.deptId"
            :options="optionListB"
            :props="{
                    emitPath:false,
                    checkStrictly: true,
                    value: 'deptId',
                    label: 'deptName',
                    children: 'child',
                  }"
            :show-all-levels="false"
            filterable
            placeholder="来源"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="" prop="assemblyMode">
          <el-select v-model="queryParams.assemblyMode" placeholder="组卷方式" style="width: 140px">
            <el-option label="固定组卷" value="1"/>
            <el-option label="随机组卷" value="2"/>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="searchValue">
          <el-input
            maxLength="30"
            v-model="queryParams.searchValue"
            placeholder="搜索名称"
            style="width: 140px"
          />
        </el-form-item>
        <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
        <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
      </el-form>
    </div>
    <div class="page-content-box">
      <el-table class="table-box"  border :data="dataList">
        <el-table-column label="试卷名称" prop="paperName"  show-overflow-tooltip/>
        <el-table-column label="组卷方式" prop="assemblyMode" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{scope.row.assemblyMode==1?'固定组卷':'随机组卷'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="知识点" prop="knowledgePointNames" width="200" show-overflow-tooltip/>
        <el-table-column label="专业类别" prop="disciplineTypeName" width="200" show-overflow-tooltip/>
        <el-table-column label="是否共享" prop="shareStatus" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span style="padding:2px 10px;border:1px solid rgb(1, 131, 251);border-radius:4px;color: rgb(1, 131, 251);background-color:rgba(1, 131, 251,0.2)" v-if="scope.row.shareStatus==1">共享</span>
            <span style="padding:2px 10px;border:1px solid rgb(245, 154, 35);border-radius:4px;color: rgb(245, 154, 35);background-color:rgba(245, 154, 35,0.2)" v-if="scope.row.shareStatus==0">不共享</span>
          </template>
        </el-table-column>
        <el-table-column label="来源" prop="deptName" width="200" show-overflow-tooltip/>
        <el-table-column label="操作" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="table-button-box">
              <p class="table-button-null"></p>
              <p class="table-button-p"
                 @click="checkButton(scope.row)"
              >选择</p>
              <p class="table-button-null"></p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination :page-sizes="[20, 30, 40, 50]"
                  v-show="total>0"
                  :total="total"
                  :page.sync="queryParams.page"
                  :limit.sync="queryParams.pageSize"
                  @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
  import {
    examElPaperPage,examElDisciplineTypeList,
    examElKnowledgePointTreeList,systemDeptCurrentDept
  } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'addPage',
    props: {
      selectTestPaperPropsData: {}
    },
    data() {
      return {
        //下拉列表数据
        optionListB:[],
        optionListC:[],
        optionListD:[],
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          searchValue:'',
          shareStatus :null,
          deptId :null,
          knowledgePointId :null,
          assemblyMode :null,
          disciplineTypeId :null,
        },
        //列表数据
        dataList:[],
        //数据数量
        total:0,
      }
    },
    created() {

    },
    mounted() {
      this.getList();
      this.examElKnowledgePointTreeList();
      this.examElDisciplineTypeList();
      this.systemDeptCurrentDept();
    },
    methods: {
      // 提交按钮
      checkButton(row) {
        this.$parent.$parent.drawerOffButton({
          id:row.id,
          name:row.paperName,
          totalScore:row.totalScore,
          passScore:row.passScore,
          questionCount:row.questionCount,
        })
      },
      //查询按钮
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      //重置按钮
      resetQuery(){
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          searchValue:'',
          shareStatus :null,
          deptId :null,
          knowledgePointId :null,
          assemblyMode :null,
          disciplineTypeId :null,
        });
        this.getList();
      },
      //获取数据列表
      getList(){

        let obj = JSON.parse(JSON.stringify(this.queryParams))
        examElPaperPage(obj).then(response => {

          this.$set(this,'dataList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
      //知识点
      examElKnowledgePointTreeList(){
        examElKnowledgePointTreeList({}).then(response => {
          const list = response.data || [];
          this.formatTreeData(list);
          this.$set(this, 'optionListC', list);
        });
      },
      //查询全部专业类别
      examElDisciplineTypeList(){
        examElDisciplineTypeList({}).then(response => {
          this.$set(this,'optionListD',response.data);
        });
      },
      //学院列表
      systemDeptCurrentDept(){
        systemDeptCurrentDept({}).then(response => {
          const list = response.data || [];
          this.formatTreeData(list);
          this.$set(this,'optionListB',list);
        });
      },
    }
  }
</script>

<style scoped lang="scss">
  .selectTestPaper-addPage {
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
</style>
