import { Popconfirm, Space, TableProps } from "antd";
import React from "react";
import PreviewImg from "./PreviewImg";

export const Columns = (del: (id: number) => void): TableProps<any>['columns'] => {

    const columns: TableProps<any>['columns'] = [
        {
            title: '创建人',
            dataIndex: 'putUserName',
            key: 'putUserName',
            width: 60,
            align: 'center'
        },
        {
            title: '描述',
            dataIndex: 'strategyKey',
            key: 'strategyKey',
            width: 140,
            ellipsis: true,
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            ellipsis: true,
            width: 135
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            fixed: 'right',
            width: 120,
            align: 'center',
            render: (_, b) => {
                return <Space>
                    <PreviewImg strategyValue={JSON.parse(b.strategyValue)} />
                    <Popconfirm
                        title="是否删除?"
                        onConfirm={() => del(b?.id)}
                    >
                        <a style={{ color: 'red' }}>删除</a>
                    </Popconfirm>
                </Space>
            }
        }
    ];

    return columns
}