<template>
    <el-form ref="queryRef" :model="queryParams" :rules="rules" label-width="68px" inline>
        <el-form-item label="批次" prop="batchId">
            <el-select v-model="queryParams.batchId" clearable @change="handleQuery" style="width: 172px">
                <el-option v-for="b in batchList" :label="b.name" :value="b.batchId"/>
            </el-select>
        </el-form-item>
        <el-form-item label="班级" prop="classId">
            <el-select v-model="queryParams.classId" clearable @change="handleQuery" style="width: 172px">
                <el-option v-for="c in classList" :label="c.className" :value="c.classId"/>
            </el-select>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>
    <Table :data="list" :columns="columns" :actions="actions" @get-list="getList" @action="handleAction" />
    <el-drawer v-model="drawer" title="班级详情" size="1000px">
        <class-detail v-if="drawer" :state="queryParams.state" exact-mode />
    </el-drawer>
</template>

<script setup name="ListExactIntelligent">

import consts from "@/utils/consts.js";
import {useProvidePaperBatchCondition} from "@/views/dz/papers/hooks/usePaperBatchCondition.js";
import {useProvidePaperList} from "@/views/dz/papers/hooks/usePaperList.js";
import Table from "@/components/Table/index.vue"
import ClassDetail from "@/views/dz/papers/components/plugs/class-detail.vue";

const options = {
    queryDefine: {
        batchId: '',
        classId: ''
    }
}
const columns = [
    {label: '组卷类型', prop: 'buildType'},
    {label: '班级', prop: 'className'},
    {label: '批次', prop: 'batchName'},
    {label: '班级人数', prop: 'total'},
    ...consts.config.exactColumns
]
const actions = [
    {label: '查看详情', key: 'detail', permission: ['']}
]

const type = consts.enums.buildType.ExactIntelligent
const classList = ref([])
const {batchList} = useProvidePaperBatchCondition(type)
const {queryParams, rules, handleQuery, resetQuery, list, total, getList} = useProvidePaperList(options)
const drawer = ref(false)

const handleAction = function (action, row) {
    switch (action.key) {
        case "detail":
            drawer.value = true
            break;
        default:
            throw new Error(`Action key '${action.key}' not support.`)
            break
    }
}
</script>

<style scoped>

</style>