部分功能迭代

This commit is contained in:
2025-12-21 16:49:37 +08:00
parent b5262fc13a
commit 2454e6d23a
11 changed files with 641 additions and 29 deletions

View File

@@ -152,7 +152,7 @@ export const UserTaskPage: React.FC = () => {
)
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
render: (record: ExamTask) => {
const now = new Date();

View File

@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Table, Button, Input, Space, message, Popconfirm, Modal, Form, InputNumber, Card, Checkbox, Progress, Row, Col } from 'antd';
import { PlusOutlined, EditOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons';
import api from '../../services/api';
import { getCategoryColorHex } from '../../lib/categoryColors';
interface Question {
id: string;
@@ -240,12 +241,11 @@ const ExamSubjectPage = () => {
key: 'timeLimitMinutes',
render: (minutes: number) => `${minutes} 分钟`,
},
{
title: '题型分布',
{title: '题型分布',
dataIndex: 'typeRatios',
key: 'typeRatios',
render: (ratios: Record<string, number>) => (
<div>
<div className="p-3 bg-white rounded-lg border border-gray-200 shadow-sm">
<div className="w-full bg-gray-200 rounded-full h-4 flex mb-3 overflow-hidden">
{ratios && Object.entries(ratios).map(([type, ratio]) => {
const typeConfig = questionTypes.find(t => t.key === type);
@@ -279,33 +279,30 @@ const ExamSubjectPage = () => {
</div>
),
},
{
title: '题目类别分布',
{title: '题目类别分布',
dataIndex: 'categoryRatios',
key: 'categoryRatios',
render: (ratios: Record<string, number>) => {
// 生成不同的颜色数组
const colors = ['#1890ff', '#52c41a', '#faad14', '#ff4d4f', '#722ed1', '#eb2f96', '#fa8c16', '#a0d911'];
return (
<div>
<div className="p-3 bg-white rounded-lg border border-gray-200 shadow-sm">
<div className="w-full bg-gray-200 rounded-full h-4 flex mb-3 overflow-hidden">
{ratios && Object.entries(ratios).map(([category, ratio], index) => (
{ratios && Object.entries(ratios).map(([category, ratio]) => (
<div
key={category}
className="h-full"
style={{
width: `${ratio}%`,
backgroundColor: colors[index % colors.length]
backgroundColor: getCategoryColorHex(category)
}}
></div>
))}
</div>
<div className="space-y-1">
{ratios && Object.entries(ratios).map(([category, ratio], index) => (
{ratios && Object.entries(ratios).map(([category, ratio]) => (
<div key={category} className="flex items-center text-sm">
<span
className="inline-block w-3 h-3 mr-2 rounded-full"
style={{ backgroundColor: colors[index % colors.length] }}
style={{ backgroundColor: getCategoryColorHex(category) }}
></span>
<span className="flex-1">{category}</span>
<span className="font-medium">{ratio}%</span>
@@ -316,19 +313,28 @@ const ExamSubjectPage = () => {
);
},
},
{
title: '创建时间',
{title: '创建时间',
dataIndex: 'createdAt',
key: 'createdAt',
render: (text: string) => new Date(text).toLocaleString(),
render: (text: string) => {
const date = new Date(text);
return (
<div>
<div>{date.toLocaleDateString()}</div>
<div className="text-sm text-gray-500">{date.toLocaleTimeString()}</div>
</div>
);
},
},
{
title: '操作',
{title: '操作',
key: 'action',
width: 100,
align: 'left',
render: (_: any, record: ExamSubject) => (
<Space>
<div className="space-y-2">
<Button
type="text"
size="small"
icon={<EditOutlined />}
onClick={() => handleEdit(record)}
>
@@ -336,6 +342,7 @@ const ExamSubjectPage = () => {
</Button>
<Button
type="text"
size="small"
icon={<EyeOutlined />}
onClick={() => handleBrowseQuestions(record)}
>
@@ -347,11 +354,11 @@ const ExamSubjectPage = () => {
okText="确定"
cancelText="取消"
>
<Button type="text" danger icon={<DeleteOutlined />}>
<Button type="text" danger size="small" icon={<DeleteOutlined />}>
</Button>
</Popconfirm>
</Space>
</div>
),
},
];

View File

@@ -303,7 +303,7 @@ const ExamTaskPage = () => {
render: (text: string) => dayjs(text).format('YYYY-MM-DD HH:mm'),
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
width: 120,
render: (_: any, record: ExamTask) => (

View File

@@ -1,8 +1,9 @@
import React, { useState, useEffect } from 'react';
import { Table, Button, Input, Space, message, Popconfirm, Modal, Form } from 'antd';
import { Table, Button, Input, Space, message, Popconfirm, Modal, Form, Tag } from 'antd';
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { useLocation } from 'react-router-dom';
import api from '../../services/api';
import { getCategoryColorHex } from '../../lib/categoryColors';
interface QuestionCategory {
id: string;
@@ -84,6 +85,13 @@ const QuestionCategoryPage = () => {
title: '类别名称',
dataIndex: 'name',
key: 'name',
render: (name: string) => (
<div className="flex items-center">
<Tag color={getCategoryColorHex(name)} className="mr-2">
{name}
</Tag>
</div>
),
},
{
title: '创建时间',
@@ -92,7 +100,7 @@ const QuestionCategoryPage = () => {
render: (text: string) => new Date(text).toLocaleString(),
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
render: (_: any, record: QuestionCategory) => (
<Space>

View File

@@ -32,6 +32,7 @@ import {
import * as XLSX from 'xlsx';
import { questionAPI } from '../../services/api';
import { questionTypeMap, questionTypeColors } from '../../utils/validation';
import { getCategoryColorHex } from '../../lib/categoryColors';
const { Option } = Select;
const { TextArea } = Input;
@@ -403,7 +404,10 @@ const QuestionManagePage = () => {
dataIndex: 'category',
key: 'category',
width: 120,
render: (category: string) => <span>{category || '通用'}</span>,
render: (category: string) => {
const cat = category || '通用';
return <Tag color={getCategoryColorHex(cat)}>{cat}</Tag>;
},
},
{
title: '分值',
@@ -420,7 +424,7 @@ const QuestionManagePage = () => {
render: (date: string) => new Date(date).toLocaleDateString(),
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
width: 120,
render: (_: any, record: Question) => (

View File

@@ -119,7 +119,7 @@ const UserGroupManage = () => {
render: (text: string) => dayjs(text).format('YYYY-MM-DD HH:mm'),
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
render: (_: any, record: UserGroup) => (
<Space>

View File

@@ -347,7 +347,7 @@ const UserManagePage = () => {
render: (text: string) => new Date(text).toLocaleString(),
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
render: (_: any, record: User) => (
<Space>

View File

@@ -81,7 +81,7 @@ const UserRecordsPage = ({ userId }: { userId: string }) => {
},
},
{
title: '操作',
title: <div style={{ textAlign: 'center' }}></div>,
key: 'action',
render: (_: any, record: Record) => (
<Button type="link" onClick={() => handleViewDetail(record.id)}>