<template>
  <div>
    <el-form :model="searchForm" inline @submit.prevent>
      <el-form-item>
        <el-input
          v-model="searchForm.nameOrPhone"
          placeholder="输入学员姓名/手机号"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-input v-model="searchForm.question" placeholder="输入题目" @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery"> 搜索 </el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="tableList"
      highlight-current-row
      max-height="calc(100vh - 320px)"
    >
      <el-table-column type="index" width="55" align="center" />
      <el-table-column label="题目" prop="question" />
      <el-table-column label="图片" prop="img" />
      <el-table-column label="选项" prop="option" />
      <el-table-column label="正确答案" prop="answer" />
      <el-table-column label="收藏人" prop="name" />
      <el-table-column label="手机号" prop="phone" />
      <el-table-column label="收藏时间" prop="yourAnswer" />
    </el-table>

    <pagination
      style="margin-bottom: 0"
      v-show="total > 0"
      :total="total"
      v-model:page="searchForm.pageNo"
      v-model:limit="searchForm.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup>
const searchForm = ref({
  question: '',
  nameOrPhone: '',
  pageNo: 1,
  pageSize: 100
})

const loading = ref(false)
const total = ref(0)
const tableList = ref([])

onMounted(() => {
  handleQuery()
})
function getList() {
  loading.value = true
  tableList.value = [
    {
      id: 1,
      question: '1+1=？',
      answer: 'B',
      yourAnswer: 'B',
      status: '1',
      createTime: ''
    }
  ]
  total.value = 1
  loading.value = false
}

function handleQuery() {
  searchForm.value.pageNo = 1
  getList()
}
</script>

<style lang="scss" scoped></style>
