<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="CODE">
              <el-input
                v-model="searchForm.CODE"
                placeholder="请输入班级编码"
              />
            </el-form-item>
          </el-col>
          <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 label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="NAME" label="班级名称" />
        <el-table-column prop="CODE" label="班级编码" width="150" />
        <el-table-column
          prop="TRAININGTYPE_NAME"
          label="培训类型"
          width="200"
        />
        <el-table-column prop="POSTTYPE_NAME" label="岗位类型" width="150" />
        <el-table-column prop="START_TIME" label="培训开始时间" width="150" />
        <el-table-column prop="END_TIME" label="培训结束时间" width="150" />
        <el-table-column prop="STUDENT_NUM" label="学员人员数" width="100" />
        <el-table-column label="任务状态" width="100">
          <template #default="{ row }">
            <template v-if="row.STATE === '1'"> 未申请 </template>
            <template v-if="row.STATE === '4'"> 待开班 </template>
            <template v-if="row.STATE === '5'"> 培训中 </template>
            <template v-if="row.STATE === '6'"> 培训结束 </template>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template #default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/archives_management/student/index/studentList',
                  query: {
                    CLASS_ID: row.CLASS_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 { getClassForHealthList } from "@/request/training_archive_management.js";
import { useRouter } from "vue-router";

const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getClassForHealthList, {
    otherParams: { TRAINTYPE_ID: "c70bf859512241579a8a30fc5d1ae153" },
  });
</script>

<style scoped></style>
