<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="100px"
        @submit.prevent="fnResetPaginationTransfer"
      >
        <el-row>
          <el-col :span="5">
            <el-form-item label="试卷名称" prop="KEYWORDS">
              <el-input v-model="searchForm.KEYWORDS" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="创建时间" prop="dates">
              <el-date-picker
                v-model="searchForm.dates"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="满分" prop="EXAMSCORE">
              <el-input v-model="searchForm.EXAMSCORE" />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="合格分数" prop="PASSSCORE">
              <el-input v-model="searchForm.PASSSCORE" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPaginationTransfer">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        v-model:pagination="pagination"
        :data="list"
        @get-data="fnGetDataTransfer"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column
          label="试卷名称"
          prop="EXAMNAME"
          show-overflow-tooltip
        />
        <el-table-column label="上传时间" prop="CREATTIME" width="150" />
        <el-table-column label="满分" prop="EXAMSCORE" width="150" />
        <el-table-column label="合格分数" prop="PASSSCORE" width="150" />
        <el-table-column label="试卷状态" width="150">
          <template #default="{ row }">
            {{ row.ISSELL === "0" ? "下架" : "上架" }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="80">
          <template #default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/training_resource_management/exam_paper_management/view',
                  query: { STAGEEXAMPAPERINPUT_ID: row.STAGEEXAMPAPERINPUT_ID },
                })
              "
            >
              查看
            </el-button>
          </template>
        </el-table-column>
      </layout-table>
    </layout-card>
  </div>
</template>

<script setup>
import useListData from "@/assets/js/useListData.js";
import { getExamPaperManagementList } from "@/request/training_resource_management.js";
import { serialNumber } from "@/assets/js/utils.js";
import { useRouter } from "vue-router";

const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getExamPaperManagementList);
const fnGetDataTransfer = () => {
  fnGetData({
    STARTTIME: searchForm.value.dates?.[0],
    ENDTIME: searchForm.value.dates?.[1],
  });
};
const fnResetPaginationTransfer = () => {
  fnResetPagination({
    STARTTIME: searchForm.value.dates?.[0],
    ENDTIME: searchForm.value.dates?.[1],
  });
};
</script>

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