import React, { useRef, useState, useEffect } from 'react';
import { Radio, Modal, Form, Input, Button, Select, InputNumber, DatePicker, Drawer } from 'antd';
import { GetIntegralRecord } from '../service';
import ProTable from '@ant-design/pro-table';
const IntegralRecord = (props) => {

    const actionRef = useRef();

    const columns = [
        {
            title: '主键',
            dataIndex: 'id',
            tip: '规则名称是唯一的key',
            hideInSearch: true,
            hideInTable: true,
        },
        {
            title: '变更前',
            dataIndex: 'beforeChange',
            valueType: 'textarea',
            search: false,
            
        }, {
            title: '变更类型',
            dataIndex: 'type',
            valueEnum: {
                1: { text: '增加',status:'Success'},
                2: { text: '减少',status: 'Error'},
              },
        }, {
            title: '变更积分',
            dataIndex: 'integral',
            valueType: 'textarea',
            search: false,
        }, {
            title: '变更后',
            dataIndex: 'afterChange',
            valueType: 'textarea',
            search: false,
        }, {
            title: '变更时间',
            dataIndex: 'createAt',
            valueType: 'dateTime',
        }];

    return (
        <Drawer title="积分记录"
            //取消
            onClose={() => {
                props.onClose();
            }}
            width={720}
            visible={props.integralRecordVisible}
            placement="right"
            //关闭时销毁 Modal 里的子元素
            destroyOnClose>

            <ProTable
                actionRef={actionRef}
                rowKey="id"
                request={async (params) => {
                    var queryData = [];
                    var total = 0;
                    params.memberId = props.memberId;
                    await GetIntegralRecord(JSON.stringify(params)).then((re) => {
                        queryData = re.data.data;
                        total = re.data.total;
                    });
                    return {
                        data: queryData,
                        success: true,
                        total: total,
                    };
                }}
                columns={columns}
                pagination={{ defaultPageSize: 10 }}
            />
        </Drawer>);
};

export default IntegralRecord;
