feat(admin): 考试成绩科目联想、单报读自动关联与考试名称自动生成
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import React, { useState } from 'react';
|
||||
import { App, Button, DatePicker, Form, Input, InputNumber, Modal, Select, Table } from 'antd';
|
||||
import { App, AutoComplete, Button, DatePicker, Form, Input, InputNumber, Modal, Select, Table } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import api from '../../api';
|
||||
import { message } from '../../ui/app-message';
|
||||
import { useApiMutation } from '../../hooks/useApiMutation';
|
||||
import { usePermission } from '../../hooks/usePermission';
|
||||
import PermissionButton from '../PermissionButton';
|
||||
import { EditableArchiveCell } from './EditableArchiveCell';
|
||||
import { EXAM_TYPE_OPTIONS, formatEnrollmentDisplayName, getClassTypeLabel } from './shared';
|
||||
import { EXAM_TYPE_OPTIONS, formatEnrollmentDisplayName, getClassTypeLabel, SUBJECT_OPTIONS } from './shared';
|
||||
import type { EnrollmentRecord, ExamScoreRecord, TabProps } from './shared';
|
||||
|
||||
const EXAM_SCORE_FIELDS = {
|
||||
@@ -189,6 +190,7 @@ export const ExamScoresTab: React.FC<
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
form.resetFields();
|
||||
if (enrollments.length === 1) form.setFieldValue('enrollmentId', enrollments[0].id);
|
||||
setModalOpen(true);
|
||||
}}
|
||||
style={{ marginBottom: 16 }}
|
||||
@@ -213,7 +215,20 @@ export const ExamScoresTab: React.FC<
|
||||
onCancel={() => setModalOpen(false)}
|
||||
confirmLoading={saving}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onValuesChange={(changed: Record<string, unknown>, all: Record<string, unknown>) => {
|
||||
if (!('examType' in changed) && !('examDate' in changed)) return;
|
||||
const examType = all.examType as string | undefined;
|
||||
const examDate = all.examDate as Dayjs | undefined;
|
||||
const examName = all.examName as string | undefined;
|
||||
if (examType && examDate && (!examName || examName.trim() === '')) {
|
||||
const label = EXAM_TYPE_OPTIONS.find((o) => o.value === examType)?.label;
|
||||
if (label) form.setFieldValue('examName', `${label} ${examDate.format('YYYY-MM-DD')}`);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Form.Item
|
||||
name="examType"
|
||||
label="考试类型"
|
||||
@@ -229,7 +244,7 @@ export const ExamScoresTab: React.FC<
|
||||
label="科目"
|
||||
rules={[{ required: true, message: '请输入科目' }]}
|
||||
>
|
||||
<Input placeholder="如:数学" />
|
||||
<AutoComplete options={SUBJECT_OPTIONS} placeholder="输入或选择科目" />
|
||||
</Form.Item>
|
||||
<Form.Item name="score" label="成绩" rules={[{ required: true, message: '请输入成绩' }]}>
|
||||
<InputNumber min={0} style={{ width: '100%' }} />
|
||||
|
||||
Reference in New Issue
Block a user