import React, { useState, useEffect } from 'react';
import { Table, Button, Modal, Form, Input, Select, InputNumber, Space, Card, message, Popconfirm } from 'antd';
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { useSelector, useDispatch } from 'react-redux';
import { setPointTypes, addPointType, updatePointType, deletePointType } from '../../store/slices/pointsSlice';
const { Option } = Select;
const PointTypeManagement = () => {
const [form] = Form.useForm();
const [modalVisible, setModalVisible] = useState(false);
const [editingRecord, setEditingRecord] = useState(null);
const [loading, setLoading] = useState(false);
const dispatch = useDispatch();
const { pointTypes } = useSelector((state) => state.points);
// 模拟数据
const mockPointTypes = [
{
id: 1,
name: '活动参与',
code: 'ACTIVITY_PARTICIPATION',
description: '参与志愿者活动获得的积分',
points: 10,
type: '增加',
status: '启用',
createTime: '2024-01-01 10:00:00',
},
{
id: 2,
name: '服务时长',
code: 'SERVICE_HOURS',
description: '根据服务时长获得的积分',
points: 5,
type: '增加',
status: '启用',
createTime: '2024-01-01 10:00:00',
},
{
id: 3,
name: '特殊贡献',
code: 'SPECIAL_CONTRIBUTION',
description: '特殊贡献或突出表现获得的积分',
points: 20,
type: '增加',
status: '启用',
createTime: '2024-01-01 10:00:00',
},
{
id: 4,
name: '违规扣分',
code: 'VIOLATION_DEDUCTION',
description: '违反规定扣除的积分',
points: 10,
type: '扣减',
status: '启用',
createTime: '2024-01-01 10:00:00',
},
];
useEffect(() => {
// 模拟加载数据
dispatch(setPointTypes(mockPointTypes));
}, [dispatch]);
const columns = [
{
title: '类型名称',
dataIndex: 'name',
key: 'name',
},
{
title: '类型代码',
dataIndex: 'code',
key: 'code',
},
{
title: '描述',
dataIndex: 'description',
key: 'description',
ellipsis: true,
},
{
title: '积分值',
dataIndex: 'points',
key: 'points',
render: (points, record) => (
{record.type === '增加' ? '+' : '-'}{points}
),
},
{
title: '类型',
dataIndex: 'type',
key: 'type',
render: (type) => (
{type}
),
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
render: (status) => (
{status}
),
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: '操作',
key: 'action',
render: (_, record) => (
管理志愿者积分类型,设置不同类型的积分规则