import { SuperTable } from '@/components';
import BaseGradeController from '@/services/apis/BaseGradeController';
import { ActionType, PageContainer, ProColumns } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import { useRef } from 'react';

/** 年级列表 */
const GradeList: React.FC = () => {
    const actionRef = useRef<ActionType>();

    const { getDictValueEnum } = useModel('useDict');

    const columns: ProColumns<API.GradeOutput>[] = [
        {
            title: 'ID',
            dataIndex: 'id',
            width: 80,
            align: 'center',
        },
        {
            title: '学段',
            dataIndex: 'educationStage',
            valueEnum: getDictValueEnum('education_stage'),
            width: 96,
            align: 'center',
        },
        {
            title: '年级号',
            dataIndex: 'gradeNumber',
            width: 80,
            align: 'center',
        },
        {
            title: '全称',
            dataIndex: 'fullName',
            width: 144,
            align: 'center',
        },
        {
            title: '名称',
            dataIndex: 'name',
            width: 96,
            align: 'center',
        },
        {
            title: '简称',
            dataIndex: 'shortName',
            width: 96,
            align: 'center',
        },
        { title: '备注', dataIndex: 'remark' },
    ];

    return (
        <PageContainer title={false} childrenContentStyle={{ paddingTop: 0 }}>
            <SuperTable<API.GradeOutput>
                headerTitle="年级列表"
                actionRef={actionRef}
                columns={columns}
                pagination={false}
                search={false}
                request={async () => {
                    const data = await BaseGradeController.getAllList();
                    return { data, success: true };
                }}
            />
        </PageContainer>
    );
};

export default GradeList;
