import { Popconfirm, Space } from "antd"
import React from "react"

const callbackTableConfig = (edit: (str: string) => void, del: (id: string) => void): any => {
    return [
        {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            align: 'center',
            width: 50,
            ellipsis: true
        },
        {
            title: '公众号appId',
            dataIndex: 'mpAppId',
            key: 'mpAppId',
            align: 'center',
            width: 170,
            ellipsis: true
        },
        {
            title: '公众号名称',
            dataIndex: 'mpAppName',
            key: 'mpAppName',
            align: 'center',
            width: 120,
            ellipsis: true
        },
        {
            title: '创建时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            ellipsis: true,
        },
        {
            title: '创建者',
            dataIndex: 'createByName',
            key: 'createByName',
            align: 'center',
            ellipsis: true,
        },
        {
            title: '更新时间',
            dataIndex: 'updateTime',
            key: 'updateTime',
            align: 'center',
            ellipsis: true,
        },
        {
            title: '更新者',
            dataIndex: 'updateByName',
            key: 'updateByName',
            align: 'center',
            ellipsis: true,
        },
        {
            title: '金额限制',
            dataIndex: 'amountLimit',
            key: 'amountLimit',
            align: 'center',
            ellipsis: true,
            render:(a:any)=>{
                return a|| '/'
            }
        },
        {
            title: '回传量',
            dataIndex: 'callBackCount',
            key: 'callBackCount',
            align: 'center',
            ellipsis: true,
            render:(a:any)=>{
                return a|| '/'
            }
        },
        {
            title: '漏单量',
            dataIndex: 'callBackSkip',
            key: 'callBackSkip',
            align: 'center',
            ellipsis: true,
            render:(a:any)=>{
                return a|| '/'
            }
        },
        {
            title: '回传类型',
            dataIndex: 'callBackType',
            key: 'callBackType',
            align: 'center',
            ellipsis: true,
            render: (a: any) => {
                let arr = ['不回传', '首单全量回传', '按比例回传']
                return arr[a]
            }
        },
        {
            title: '是否仅首充',
            dataIndex: 'onlyFirstOrder',
            key: 'onlyFirstOrder',
            align: 'center',
            ellipsis: true,
            render: (a: any) => {
                let arr = ['否','是']
                return arr[a]
            }
        },
        {
            title: '时间限制',
            dataIndex: 'regLimitType',
            key: 'regLimitType',
            align: 'center',
            ellipsis: true,
            width:180,
            render: (a: any,b:any) => {
                let arr = ['关注当天','关注后']
                return  arr[a] ? <span>{arr[a]}<span style={{color:'red'}}>{b?.regAfterHour ? b?.regAfterHour:'自然日内'}</span>{b?.regAfterHour ? '小时内':''}</span>:null
            }
        },
        {
            title: '操作',
            dataIndex: 'action',
            key: 'action',
            align: 'center',
            width: 120,
            render: (a: any, b: any) => {
                return <Space>
                    <a onClick={() => { edit(b) }}>编辑</a>
                    <Popconfirm
                        title={`确定要删除此条配置吗？`}
                        onConfirm={() => { del(b?.id) }}
                        okText="Yes"
                        cancelText="No"
                    >
                        <a >删除</a>
                    </Popconfirm>

                </Space>
            }
        }
    ]
}
export default callbackTableConfig