import { Table, Select, Form, Button, Space, InputNumber, Modal } from 'antd'; import { useState } from 'react'; // 模拟接口调用函数 const addAgeRangeApi = async (start: number, end: number | null) => { // 这里替换为实际的接口调用 console.log(`调用接口添加年龄范围: start=${start}, end=${end}`); }; const addScoreStandardApi = async (score: number, standards: (number | null)[]) => { // 这里替换为实际的接口调用 console.log(`调用接口添加分数标准: score=${score}, standards=${standards}`); }; export default function AssessmentStandardPage() { const [form] = Form.useForm(); const [ageRanges, setAgeRanges] = useState<{ start: number; end: number; label: string; }[]>([ { start: 18, end: 24, label: '18-24岁' }, { start: 25, end: 34, label: '25-34岁' }, { start: 35, end: 44, label: '35-44岁' }, { start: 45, end: null, label: '45岁以上' }, ]); const [isAgeModalVisible, setIsAgeModalVisible] = useState(false); const [isScoreModalVisible, setIsScoreModalVisible] = useState(false); const columns = [ { title: '分数', dataIndex: 'score', key: 'score', width: 100, }, ...ageRanges.map((range, index) => ({ title: range.label, dataIndex: `standard_${index}`, key: `standard_${index}`, render: (_: any, record: any) => ( handleStandardChange(record.score, index, value)} /> ), })), ]; const handleStandardChange = (score: number, ageIndex: number, value: number | null) => { // 处理标准值变化 }; const showAgeModal = () => { setIsAgeModalVisible(true); }; const handleAgeOk = async (values: any) => { const { start, end } = values; await addAgeRangeApi(start, end); const newRange = { start, end, label: end ? `${start}-${end}岁` : `${start}岁以上`, }; setAgeRanges([...ageRanges, newRange]); setIsAgeModalVisible(false); }; const handleAgeCancel = () => { setIsAgeModalVisible(false); }; const showScoreModal = () => { setIsScoreModalVisible(true); }; const handleScoreOk = async (values: any) => { const { score, standards } = values; await addScoreStandardApi(score, standards); // 这里可以更新表格的数据源 setIsScoreModalVisible(false); }; const handleScoreCancel = () => { setIsScoreModalVisible(false); }; return (

考核标准管理