<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="100px"
        @submit.prevent="fnResetPagination"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="姓名" prop="KEYWORDS">
              <el-input
                v-model="searchForm.KEYWORDS"
                placeholder="请输入姓名"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPagination">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        ref="tableRef"
        v-model:pagination="pagination"
        :data="list"
        @get-data="fnGetData"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="USERNAME" label="用户名" width="200" />
        <el-table-column prop="NAME" label="姓名" width="200" />
        <el-table-column prop="CLASS_COUNT" label="班级数" width="200" />
        <el-table-column prop="COMPLETE_COUNT" label="完成班级数" width="200" />
        <el-table-column prop="CLIENT" label="是否补充" width="200">
          <template #default="{ row }">
            <template
              v-if="
                row.ARCHIVES_AWARD_PUN_LOG_ID || row.ARCHIVES_SPECIAL_WORK_ID
              "
              >是</template
            >
            <template v-else>否</template>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/archives_management/user/class',
                  query: {
                    USER_ID: row.USER_ID,
                  },
                })
              "
            >
              班级详情
            </el-button>
          </template>
        </el-table-column>
      </layout-table>
    </layout-card>
  </div>
</template>

<script setup>
import { serialNumber } from "@/assets/js/utils.js";
import useListData from "@/assets/js/useListData.js";
import { ref } from "vue";

import { getStudentsList } from "@/request/training_archive_management.js";
import router from "@/router/index.js";

const tableRef = ref(null);
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getStudentsList);
</script>

<style scoped></style>
