<!-- 刷题练习 -->
<template>
  <div class="app-container practiceQuestions">
    <div class="page-container practiceQuestionsPage" v-if="pageType === 1">
      <p class="pageTitle">刷题练习</p>
      <div class="max-big-box">
        <div class="left-box scrollbar-box">
          <p @click="leftCheckButton(index)"
             v-for="(item,index) in letDataList" :key="index"
             class="left-for-p" :class="index==leftDataIndex?'leftCheck':''">
            {{item.name}}
          </p>
        </div>
        <div class="right-box">
          <div class="page-form-title-box">
            <el-form :model="queryParams" class="form-box" ref="queryForm"
                     :inline="true" style="width:100%;">
              <div class="table-top-button-box">
                <div>
                  <p :class="shareStatus === ''?'check-table-button':''" @click="tableTypeButton('')">全部</p>
                  <p :class="shareStatus === 1?'check-table-button':''" @click="tableTypeButton(1)">未开始</p>
                  <p :class="shareStatus === 2?'check-table-button':''" @click="tableTypeButton(2)">练习中</p>
                  <p :class="shareStatus === 3?'check-table-button':''" @click="tableTypeButton(3)">已学完</p>
                </div>
              </div>
              <el-form-item label="" prop="queryParamsData1">
                <el-cascader
                  v-model="queryParams.queryParamsData1"
                  :options="optionListB"
                  :props="{
                emitPath:false,
                checkStrictly: true,
                value: 'id',
                label: 'knowledgePointName',
                children: 'children',
              }"
                  style="width: 180px"
                  :show-all-levels="false"
                  filterable
                  placeholder="知识点"
                ></el-cascader>
              </el-form-item>
              <el-form-item label="" prop="queryParamsData2">
                <el-input
                  maxLength="30"
                  v-model="queryParams.queryParamsData2"
                  placeholder="搜索名称"
                  style="width: 200px"
                />
              </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">
            <div class="for-max-big-box scrollbar-box">
              <div class="for-big-box" v-for="(item,index) in dataList" :key="index">
                <p class="title-p">{{item.data1}}{{item.data2?' - '+item.data2:''}}</p>
                <div class="text-box">
                  <div class="text-min-box">
                    <p class="el-icon-time"></p>
                    <p>{{item.data3}}</p>
                  </div>
                  <p class="text-p">练习进度：{{item.data4}} / {{item.data5}}</p>
                  <p class="text-p">正确数：{{item.data6}} 丨 错题数：{{item.data7}} 丨 正确率：{{item.data8}}%</p>
                </div>
                <p class="position-time">{{item.data9}}</p>
                <p class="position-p" v-if="item.data11" @click="tableButton(1,item)">历史错题</p>
                <el-progress
                  class="num-p" type="circle"
                  :stroke-width="4"
                  :width="60" :percentage="item.data10">
                </el-progress>
              </div>
            </div>
            <pagination :page-sizes="[20, 30, 40, 50]"
                        style="margin-right:20px;"
                        v-show="total>0"
                        :total="total"
                        :page.sync="queryParams.page"
                        :limit.sync="queryParams.pageSize"
                        @pagination="getList"
            />
          </div>
        </div>
      </div>
    </div>
    <historyOfIncorrectQuestions :propsData="propsData" v-if="pageType === 2"></historyOfIncorrectQuestions>
  </div>
</template>
<script>
  //import { getDicts } from "@/api/commonality/noPermission";
  //import { systemUserSelect } from "@/api/commonality/permission";
  //import { getInfo } from "@/api/basicsModules/index";
  //import addPage from "./addPage.vue";
  import { examElKnowledgePointTreeList, } from "@/api/safetyEducationExaminationNew/index";
  import historyOfIncorrectQuestions from "@/views/safetyEducationExaminationNew/components/historyOfIncorrectQuestions.vue";
  export default {
    name: 'index',
    components: {
      historyOfIncorrectQuestions,
    },
    data() {
      return {
        //页面状态
        pageType: 1,
        letDataList:[
          {name:'全部知识点',id:'1'},{name:'全部知识点',id:'2'},
          {name:'全部知识点',id:'3'},{name:'全部知识点',id:'4'},
          {name:'全部知识点',id:'5'},{name:'全部知识点',id:'6'},
          {name:'全部知识点',id:'7'},{name:'全部知识点',id:'8'},
          {name:'全部知识点',id:'9'},{name:'全部知识点',id:'10'},
          {name:'全部知识点',id:'11'},{name:'全部知识点',id:'12'},
          {name:'全部知识点',id:'13'},{name:'全部知识点',id:'14'},
        ],
        leftDataIndex:0,
        //下拉列表数据
        optionListB: [],
        //查询条件
        shareStatus:'',
        queryParams: {
          page: 1,
          pageSize: 20,
          queryParamsData1: '',
          queryParamsData2: null
        },
        //列表数据
        dataList: [
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'100',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:100,data11:true},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:true},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:false},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:true},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:true},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:false},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:false},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:true},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:false},
          {data1:'知识点',data2:'二级知识点',data3:'2026-09-1 9:30:33',data4:'33',data5:'369',data6:'3',data7:'3',data8:'69',data9:'2026-09-1 9:30:33',data10:33,data11:false},
        ],
        //数据数量
        total: 0,
        propsData:{},
      }
    },
    created() {

    },
    mounted() {
      //this.getList();
      this.examElKnowledgePointTreeList();
    },
    methods: {
      //左侧列表切换
      leftCheckButton(index){
        if(this.leftDataIndex != index){
          this.$set(this,'leftDataIndex',index);
        }
      },
      //切换按钮
      tableTypeButton(val){
        if(this.shareStatus != val){
          this.$set(this,'shareStatus',val);
          this.handleQuery();
        }
      },
      //查询按钮
      handleQuery() {
        this.$set(this.queryParams, 'page', 1)
        this.getList()
      },
      //重置按钮
      resetQuery() {
        this.$set(this, 'dateRange', [])
        this.$set(this, 'queryParams', {
          page: 1,
          pageSize: 20,
          queryParamsData1: '',
          queryParamsData2: null
        })
        this.getList()
      },
      //获取数据列表
      getList() {
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        if (this.dateRange[0]) {
          obj.startTime = this.dateRange[0] + 'T00:00:00'
          obj.endTime = this.dateRange[1] + 'T23:59:59'
        } else {
          obj.startTime = ''
          obj.endTime = ''
        }
        getListFunction(obj).then(response => {
          this.$set(this, 'dataList', response.data.records)
          this.$set(this, 'total', response.data.total)
        })
      },
      //操作按钮
      tableButton(type, row) {
        let self = this
        if (type == 1) {
          //历史错题
          this.$set(this, 'pageType', 2)
          this.$set(this, 'propsData', {})
        } else if (type == 6) {
          //返回并刷新
          this.$set(this, 'pageType', 1)
          this.getList()
        }
      },
      examElKnowledgePointTreeList(){
        examElKnowledgePointTreeList({}).then(response => {
          const list = response.data || [];
          this.formatTreeData(list);
          this.$set(this, 'optionListB', list);
        });
      },
    }
  }
</script>
<style scoped lang="scss">
  .practiceQuestions {
    .practiceQuestionsPage {
      .pageTitle{
        height:60px;
        line-height:60px;
        padding:0 20px;
        border-bottom:1px solid #dedede;
      }
      .max-big-box{
        display: flex;
        overflow: hidden;
        .left-box{
          width:200px;
          border-right:1px solid #dedede;
          padding:20px 0 ;
          .left-for-p{
            margin:5px 0;
            padding:0 20px;
            text-align: center;
            border-right:4px solid #ffffff;
            cursor: pointer;
            font-weight:700;
            font-size:16px;
            line-height:40px;
          }
          .left-for-p:hover{
            background-color: #0183fa;
            color: #ffffff;
          }
          .leftCheck{
            color: #0183fa;
            border-right:4px solid #0183fa;
          }
        }
        .right-box{
          flex:1;
          display: flex;
          flex-direction: column;
          overflow: hidden;
          .top-max-button-box{
            display: flex;
            margin:20px 0 0 20px;
            p{
              width:120px;
              line-height:40px;
              border-radius:4px;
              color:#333;
              border:1px solid #333;
              text-align: center;
              margin-right:20px;
              cursor: pointer;
            }
            .top-check-button{
              border:1px solid #0183fa;
              background-color: #0183fa;
              color:#fff;
            }
          }
          .table-top-button-box{
            display: inline-block;
            vertical-align: top;
            margin-right:10px;
            div{
              display: flex;
              p{
                border:1px solid #DCDFE6;
                width:80px;
                text-align: center;
                height:40px;
                line-height:40px;
                cursor: pointer;
                font-size:14px;
              }
              p:nth-child(1){
                border-top-left-radius:4px;
                border-bottom-left-radius:4px;
              }
              p:nth-child(2){
                border-left:none;
                border-right:none;
              }
              p:nth-child(3){
                border-left:none;
                border-right:none;
              }
              p:nth-child(4){
                border-top-right-radius:4px;
                border-bottom-right-radius:4px;
              }
              .check-table-button{
                border:1px solid #0183fa;
                background-color: #0183fa;
                color:#fff;
              }
            }
          }
          .page-content-box{
            padding:20px 0;
          }
          .for-max-big-box{
            flex:1;
            .for-big-box{
              cursor: pointer;
              display: inline-block;
              width:660px;
              margin:0 0 20px 20px;
              border-radius:10px;
              overflow: hidden;
              box-shadow: 4px 4px 4px 4px rgba(0,0,0,0.1);
              position: relative;
              border:1px solid rgba(222,222,222,0.4);
              background-color: rgba(222,222,222,0.2);
              .title-p{
                margin:20px;
                font-size:16px;
                font-weight:700;
              }
              .text-box{
                margin:0 20px 20px 20px;
                background-color: rgba(1,131,250,0.1);
                overflow: hidden;
                border-radius:10px;
                padding:10px 20px;
                .text-min-box{
                  line-height: 40px;
                  color:#0183fa;
                  display: flex;
                  p:nth-child(1){
                    font-size:24px;
                    line-height: 40px;
                    margin-right:6px;
                  }
                  p:nth-child(2){
                    font-size:16px;
                    font-weight:700;
                  }
                }
                .text-p{
                  font-size:14px;
                  color:#666;
                  line-height:30px;
                  font-weight:700;
                }
              }
              .position-p{
                position: absolute;
                right:20px;
                top:20px;
                color:#0183fa;
                font-weight:700;
              }
              .position-time{
                position: absolute;
                right:40px;
                bottom:29px;
                font-size:14px;
                color:#666;
                line-height:30px;
                font-weight:700;
              }
              .num-p{
                position: absolute;
                right:40px;
                bottom:65px;
              }
              .num-p ::v-deep .el-progress__text {
                margin-left:0!important;
                font-size:12px!important;
              }
              .num-p ::v-deep svg path:first-child {
                stroke: #cccccc !important; /* 修改为红色 */
              }
            }
          }
        }
      }
    }
  }
</style>
