import { Input, Typography } from "antd";
import { AnyObject } from "antd/es/_util/type"
import { ColumnsType } from "antd/es/table"
import { businessPlanData, TIME_TYPE, welcomeContentData } from "./const";
import FilterUser from "@/pages/weComTask/components/filterUser";
import ShowContentTable from "./components/massSending/showContentTable";
import WelcomeShowTable from "./components/welcome/welcomeShowTable";
import FriendsShowTable from "./components/friends/friendsShowTable";
import SelectBookLinkButton from "../../bookLink/SelectBookLinkButton";
const { Title, Text, Paragraph } = Typography;

export const userInheritColumns = (setContent: (data: TASK_CREATE.SetContentProps) => void): ColumnsType<AnyObject> => {

    return [
        {
            title: '账号',
            dataIndex: 'corpUserGroupName',
            key: 'corpUserGroupName',
            width: 150,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>{value}({record?.corpUserList?.[0]?.corpName})</Title>
                    <Paragraph style={{ margin: 0 }}>客服号：{record?.corpUserList?.map(i => i.name).join('、')}</Paragraph>
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '继承信息',
            dataIndex: 'taskName',
            key: 'taskName',
            width: 130,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>标题：{value}</Title>
                    {record?.bizType && <Paragraph style={{ margin: 0 }}>业务类型：{record?.bizType || '<空>'}</Paragraph>}
                    {record?.platform && <Paragraph style={{ margin: 0 }}>书城：{record?.platform || '<空>'}</Paragraph>}
                    {record?.templateProductId && <Paragraph style={{ margin: 0 }}>适用产品：{record?.templateProductId || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '策略信息',
            dataIndex: 'strategyData',
            key: 'strategyData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>策略{record.strategyIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>名称：{value?.strategyName || '<空>'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>执行类型：{TIME_TYPE[value?.timeRepeatType]}</Paragraph>
                    {value?.sendDay && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendDay}</Paragraph>}
                    {value?.startTime && <Paragraph style={{ margin: 0 }}>执行日期：{value?.startTime}~{value?.endTime ? value?.endTime : '长期执行'}</Paragraph>}
                    {value?.sendTime && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendTime}</Paragraph>}
                    {value?.repeatArray && <Paragraph style={{ margin: 0 }}>执行天数：{value?.repeatArray.join('、')}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.strategyRowSpan }
            }
        },
        {
            title: '继承对象',
            dataIndex: 'inheritData',
            key: 'inheritData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>转移对象{record.inheritIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>类型：{value?.transferType === 'all' ? '全部' : '指定'}</Paragraph>
                    {value?.transferType === 'specify' && <FilterUser isSHow value={value?.transferUserDto} configType='USER_GROUP' />}
                </>
            },
        },
        {
            title: '继承后文本内容',
            dataIndex: 'transferSuccessMsg',
            key: 'transferSuccessMsg',
            width: 200,
            render(_, record) {
                return <Text>{record?.inheritData?.transferSuccessMsg || '<空>'}</Text>
            },
        },
        {
            title: '接替客户企微号',
            dataIndex: 'externalUser',
            key: 'externalUserCorpUserName',
            width: 100,
            render(_, record) {
                return <Input.TextArea
                    placeholder="请输入接替客户企微号"
                    allowClear
                    onChange={e => setContent({
                        msg: { corpUserName: e.target.value },
                        index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.inheritIndex - 1],
                        type: 'userInherit'
                    })}
                />
            },
        },
        {
            title: '接替客户企微号ID',
            dataIndex: 'externalUser',
            key: 'externalUserCorpUserId',
            width: 100,
            render(_, record) {
                return <Input.TextArea
                    placeholder="请输入接替客户企微号ID"
                    allowClear
                    onChange={e => setContent({
                        msg: { corpUserId: e.target.value },
                        index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.inheritIndex - 1],
                        type: 'userInherit'
                    })}
                />
            },
        }
    ]

}

/** 群发 */
export const massSendingColumns = (setContent: (data: TASK_CREATE.SetContentProps) => void, bookPlatForm: TASK_CREATE.BookPlatFormProps[], previewContent: { groupMsgContent?: any[], welcomeMsgContent?: any[], externalUserTransferContent?: any[] }): ColumnsType<AnyObject> => {
    return [
        {
            title: '账号',
            dataIndex: 'corpUserGroupName',
            key: 'corpUserGroupName',
            width: 150,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>{value}</Title>
                    <Paragraph style={{ margin: 0 }}>公众号ID：{record?.corpUserList?.[0]?.mpAccountId || '--'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>客服号：{record?.corpUserList?.map(i => i.name).join('、')}</Paragraph>
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '群发信息',
            dataIndex: 'groupSendName',
            key: 'groupSendName',
            width: 130,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>标题：{value}</Title>
                    {record?.bizType && <Paragraph style={{ margin: 0 }}>业务类型：{record?.bizType || '<空>'}</Paragraph>}
                    {record?.platform && <Paragraph style={{ margin: 0 }}>书城：{record?.platform || '<空>'}</Paragraph>}
                    {record?.templateProductId && <Paragraph style={{ margin: 0 }}>适用产品：{record?.templateProductId || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '策略信息',
            dataIndex: 'strategyData',
            key: 'strategyData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>策略{record.strategyIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>名称：{value?.strategyName || '<空>'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>执行类型：{TIME_TYPE[value?.timeRepeatType]}</Paragraph>
                    {value?.sendDay && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendDay}</Paragraph>}
                    {value?.startTime && <Paragraph style={{ margin: 0 }}>执行日期：{value?.startTime}~{value?.endTime ? value?.endTime : '长期执行'}</Paragraph>}
                    {value?.sendTime && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendTime}</Paragraph>}
                    {value?.repeatArray && <Paragraph style={{ margin: 0 }}>执行天数：{value?.repeatArray.join('、')}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.strategyRowSpan }
            }
        },
        {
            title: '发送对象',
            dataIndex: 'sendData',
            key: 'sendData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>发送对象{record.sendDataIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>内容发送模式：{welcomeContentData?.find(i => i.value === record?.sendMode)?.label}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>类型：{value?.externalUserType === 'all' ? '全部' : '指定'}</Paragraph>
                    {value?.externalUserType === 'specify' && <FilterUser isSHow value={value?.externalUserFilter} configType='USER_GROUP' />}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.sendDataRowSpan }
            }
        },
        {
            title: '发送内容',
            dataIndex: 'content',
            key: 'content',
            width: 200,
            render(_, record) {
                return <>
                    <ShowContentTable
                        data={record?.content}
                        name={<><span>内容{record.contentIndex}：</span><span dangerouslySetInnerHTML={{ __html: record.contentReactNode?.map((item) => item).join('、') }}></span></>}
                    />
                </>
            },
        },
        {
            title: '图文链接',
            dataIndex: 'linkUrl',
            key: 'linkUrl',
            width: 250,
            render(_, record) {
                return record?.linkData?.length > 0 ? <div style={{ display: 'flex', gap: 4, alignItems: 'flex-end' }}>
                    <Input.TextArea
                        placeholder="请输入链接"
                        allowClear
                        value={previewContent?.groupMsgContent?.[record.corpUsergroupIndex]?.[record.strategyIndex - 1]?.[record.sendDataIndex - 1]?.[record.contentIndex - 1]?.linkUrl}
                        onChange={e => {
                            setContent({
                                msg: { linkUrl: e.target.value },
                                index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.sendDataIndex - 1, record.contentIndex - 1],
                                type: 'massSending'
                            })
                        }}
                    />
                    <SelectBookLinkButton
                        bookPlatForm={bookPlatForm}
                        mpAccountId={record.corpUserList?.[0]?.mpAccountId}
                        linkData={record.linkData}
                        onChange={(linkStr, miniprogramAppid, miniprogramPage) => {
                            const msg: { [x: string]: string } = { linkUrl: linkStr }
                            if (miniprogramAppid && miniprogramPage && record?.miniProgramData?.length > 0 && !previewContent?.groupMsgContent?.[record.corpUsergroupIndex]?.[record.strategyIndex - 1]?.[record.sendDataIndex - 1]?.[record.contentIndex - 1]?.miniprogramAppid && !previewContent?.groupMsgContent?.[record.corpUsergroupIndex]?.[record.strategyIndex - 1]?.[record.sendDataIndex - 1]?.[record.contentIndex - 1]?.miniprogramPage) {
                                msg.miniprogramAppid = miniprogramAppid
                                msg.miniprogramPage = miniprogramPage
                            }
                            setContent({
                                msg,
                                index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.sendDataIndex - 1, record.contentIndex - 1],
                                type: 'massSending'
                            })
                        }}
                    />
                </div> : '--'
            },
        },
        {
            title: '小程序APPID',
            dataIndex: 'miniprogramAppid',
            key: 'miniprogramAppid',
            width: 200,
            render(_, record) {
                return record?.miniProgramData?.length > 0 ? <Input.TextArea
                    placeholder="请输入小程序APPID"
                    allowClear
                    value={previewContent?.groupMsgContent?.[record.corpUsergroupIndex]?.[record.strategyIndex - 1]?.[record.sendDataIndex - 1]?.[record.contentIndex - 1]?.miniprogramAppid}
                    onChange={e => setContent({
                        msg: { miniprogramAppid: e.target.value },
                        index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.sendDataIndex - 1, record.contentIndex - 1],
                        type: 'massSending'
                    })}
                /> : '--'
            },
        },
        {
            title: '小程序路径',
            dataIndex: 'miniprogramPage',
            key: 'miniprogramPage',
            width: 250,
            render(_, record) {
                return record?.miniProgramData?.length > 0 ? <div style={{ display: 'flex', gap: 4, alignItems: 'flex-end' }}>
                    <Input.TextArea
                        placeholder="请输入小程序路径"
                        allowClear
                        value={previewContent?.groupMsgContent?.[record.corpUsergroupIndex]?.[record.strategyIndex - 1]?.[record.sendDataIndex - 1]?.[record.contentIndex - 1]?.miniprogramPage}
                        onChange={e => setContent({
                            msg: { miniprogramPage: e.target.value },
                            index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.sendDataIndex - 1, record.contentIndex - 1],
                            type: 'massSending'
                        })}
                    />
                    <SelectBookLinkButton
                        bookPlatForm={bookPlatForm}
                        mpAccountId={record.corpUserList?.[0]?.mpAccountId}
                        linkData={[{
                            msgType: "TASK_CONTENT_LINK",
                            link: {
                                title: record.miniProgramData?.[0]?.miniprogram?.title,
                                picUrl: record.miniProgramData?.[0]?.miniprogram?.picUrl,
                                desc: ''
                            }
                        }]}
                        onChange={(_, miniprogramAppid, miniprogramPage) => {
                            const msg: { [x: string]: string } = {}
                            if (miniprogramAppid && miniprogramPage) {
                                msg.miniprogramAppid = miniprogramAppid
                                msg.miniprogramPage = miniprogramPage
                                setContent({
                                    msg,
                                    index: [record.corpUsergroupIndex, record.strategyIndex - 1, record.sendDataIndex - 1, record.contentIndex - 1],
                                    type: 'massSending'
                                })
                            }
                        }}
                    />
                </div> : '--'
            }
        }
    ]
}



export const highMassSendingColumns = (): ColumnsType<AnyObject> => {
    return [
        {
            title: '账号',
            dataIndex: 'corpUserName',
            key: 'corpUserName',
            width: 150,
            render(value, record) {
                return <Text>{value}（{record.corpUserId}）</Text>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '群发信息',
            dataIndex: 'groupSendName',
            key: 'groupSendName',
            width: 130,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>标题：{value}</Title>
                    {record?.bizType && <Paragraph style={{ margin: 0 }}>业务类型：{record?.bizType || '<空>'}</Paragraph>}
                    {record?.platform && <Paragraph style={{ margin: 0 }}>书城：{record?.platform || '<空>'}</Paragraph>}
                    {record?.templateProductId && <Paragraph style={{ margin: 0 }}>适用产品：{record?.templateProductId || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '策略信息',
            dataIndex: 'strategyData',
            key: 'strategyData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>策略{record.strategyIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>名称：{value?.strategyName || '<空>'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>执行类型：{TIME_TYPE[value?.timeRepeatType]}</Paragraph>
                    {value?.sendDay && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendDay}</Paragraph>}
                    {value?.startTime && <Paragraph style={{ margin: 0 }}>执行日期：{value?.startTime}~{value?.endTime ? value?.endTime : '长期执行'}</Paragraph>}
                    {value?.sendTime && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendTime}</Paragraph>}
                    {value?.repeatArray && <Paragraph style={{ margin: 0 }}>执行天数：{value?.repeatArray.join('、')}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.strategyRowSpan }
            }
        },
        {
            title: '发送对象',
            dataIndex: 'sendData',
            key: 'sendData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>发送对象{record.sendDataIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>内容发送模式：{welcomeContentData?.find(i => i.value === record?.sendMode)?.label}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>类型：{value?.externalUserType === 'all' ? '全部' : '指定'}</Paragraph>
                    {value?.externalUserType === 'specify' && <FilterUser isSHow value={value?.externalUserFilter} configType='GROUP_GROUP' />}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.sendDataRowSpan }
            }
        },
        {
            title: '群发外部联系人',
            dataIndex: 'externalUser',
            key: 'externalUser',
            width: 200,
            render(value) {
                return <>
                    <Title ellipsis level={5} style={{ margin: 0 }}>消息发送号外部联系人</Title>
                    <Paragraph ellipsis={{ tooltip: true }} style={{ margin: 0 }}>{value?.externalUserId}（{value?.name}）</Paragraph>
                    <Title ellipsis level={5} style={{ margin: 0 }}>群聊所在主体</Title>
                    <Paragraph ellipsis={{ tooltip: true }} style={{ margin: 0 }}>{value?.corpId}（{value?.corpName}）</Paragraph>
                </>
            },
        },
        {
            title: '发送内容',
            dataIndex: 'content',
            key: 'content',
            width: 200,
            render(_, record) {
                return <WelcomeShowTable
                    name={<><span>内容{record.contentIndex}：</span><span dangerouslySetInnerHTML={{ __html: record.contentReactNode?.map((item) => item).join('、') }}></span></>}
                    data={record?.content}
                />
            },
        },
        {
            title: '图文链接',
            dataIndex: 'linkUrl',
            key: 'linkUrl',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.groupMsgContent?.linkUrl ? 'bold' : 'normal' }}>{record?.groupMsgContent?.linkUrl || '--'}</Paragraph>
            },
        },
        {
            title: '小程序APPID',
            dataIndex: 'miniprogramAppid',
            key: 'miniprogramAppid',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.groupMsgContent?.miniprogramAppid ? 'bold' : 'normal' }}>{record?.groupMsgContent?.miniprogramAppid || '--'}</Paragraph>
            },
        },
        {
            title: '小程序路径',
            dataIndex: 'miniprogramPage',
            key: 'miniprogramPage',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.groupMsgContent?.miniprogramPage ? 'bold' : 'normal' }}>{record?.groupMsgContent?.miniprogramPage || '--'}</Paragraph>
            },
        }
    ]
}


export const welcomeColumns = (bookPlatForm: { platformName: string, id: number, platformKey: string }[], bookList: { id: number, bookName: string, platformId: number }[], setContent: (data: TASK_CREATE.SetContentProps) => void, previewContent: { groupMsgContent?: any[], welcomeMsgContent?: any[], externalUserTransferContent?: any[] }): ColumnsType<AnyObject> => {
    return [
        {
            title: '账号',
            dataIndex: 'corpUserGroupName',
            key: 'corpUserGroupName',
            width: 150,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>{value}({record?.corpUserList?.[0]?.corpName})</Title>
                    <Paragraph style={{ margin: 0 }}>公众号ID：{record?.corpUserList?.[0]?.mpAccountId || '--'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>客服号：{record?.corpUserList?.map(i => i.name).join('、')}</Paragraph>
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.rowSpan }
            }
        },
        {
            title: '欢迎语信息',
            dataIndex: 'welcomeName',
            key: 'welcomeName',
            width: 130,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>标题：{value}</Title>
                    {record?.bizType && <Paragraph style={{ margin: 0 }}>业务类型：{record?.bizType || '<空>'}</Paragraph>}
                    {record?.platform && <Paragraph style={{ margin: 0 }}>书城：{record?.platform || '<空>'}</Paragraph>}
                    {record?.templateProductId && <Paragraph style={{ margin: 0 }}>适用产品：{record?.templateProductId || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.rowSpan }
            }
        },
        {
            title: '智能标签',
            dataIndex: 'welcomeMsgTagDTO',
            key: 'welcomeMsgTagDTO',
            width: 200,
            render(value) {
                return <>
                    {value?.business && <Paragraph style={{ margin: 0 }}>业务（来源渠道）：{businessPlanData.find(i => i.value === value.business)?.label || '<空>'}</Paragraph>}
                    {value?.bookCity && <Paragraph style={{ margin: 0 }}>书城（来源渠道）：{bookPlatForm.find(i => i.id === value.bookCity)?.platformName || '<空>'}</Paragraph>}
                    {value?.product && <Paragraph style={{ margin: 0 }}>产品（来源渠道）：{bookList.find(i => i.id === value.product)?.bookName || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.rowSpan }
            }
        },
        {
            title: '内容组发送模式',
            dataIndex: 'sendMode',
            key: 'sendMode',
            width: 100,
            align: 'center',
            render(value) {
                return <Paragraph style={{ margin: 0 }}>{welcomeContentData?.find(i => i.value === value)?.label}</Paragraph>
            },
            onCell: (record) => {
                return { rowSpan: record.rowSpan }
            }
        },
        {
            title: '欢迎语发送内容',
            dataIndex: 'sendData',
            key: 'sendData',
            width: 200,
            render(value, record) {
                return <WelcomeShowTable
                    name={<><span>内容{record.contentIndex}：</span><span dangerouslySetInnerHTML={{ __html: record.contentReactNode?.map((item) => item).join('、') }}></span></>}
                    data={value}
                />
            },
        },
        {
            title: '图文链接',
            dataIndex: 'linkUrl',
            key: 'linkUrl',
            width: 250,
            render(_, record) {
                return record?.linkData?.length > 0 ? <div style={{ display: 'flex', gap: 4, alignItems: 'flex-end' }}>
                    <Input.TextArea
                        placeholder="请输入链接"
                        allowClear
                        value={previewContent?.welcomeMsgContent?.[record.corpUsergroupIndex]?.[record.contentIndex - 1]?.linkUrl}
                        onChange={e => {
                            setContent({
                                msg: { linkUrl: e.target.value },
                                index: [record.corpUsergroupIndex, record.contentIndex - 1],
                                type: 'welcome'
                            })
                        }}
                    />
                    <SelectBookLinkButton
                        bookPlatForm={bookPlatForm}
                        mpAccountId={record.corpUserList?.[0]?.mpAccountId}
                        linkData={record.linkData.map(item => ({
                            msgType: "TASK_CONTENT_LINK",
                            link: {
                                title: item.linkTitle,
                                picUrl: item.linkPicurl,
                                desc: item.linkDesc
                            }
                        }))}
                        onChange={(linkStr, miniprogramAppid, miniprogramPage) => {
                            const msg: { [x: string]: string } = { linkUrl: linkStr }
                            if (miniprogramAppid && miniprogramPage && record?.miniProgramData?.length > 0 && !previewContent?.welcomeMsgContent?.[record.corpUsergroupIndex]?.[record.contentIndex - 1]?.miniprogramAppid && !previewContent?.welcomeMsgContent?.[record.corpUsergroupIndex]?.[record.contentIndex - 1]?.miniprogramPage) {
                                msg.miniprogramAppid = miniprogramAppid
                                msg.miniprogramPage = miniprogramPage
                            }
                            setContent({
                                msg,
                                index: [record.corpUsergroupIndex, record.contentIndex - 1],
                                type: 'welcome'
                            })
                        }}
                    />
                </div> : '--'
            },
        },
        {
            title: '小程序APPID',
            dataIndex: 'miniprogramAppid',
            key: 'miniprogramAppid',
            width: 200,
            render(_, record) {
                return record?.miniProgramData?.length > 0 ? <Input.TextArea
                    placeholder="请输入小程序APPID"
                    allowClear
                    value={previewContent?.welcomeMsgContent?.[record.corpUsergroupIndex]?.[record.contentIndex - 1]?.miniprogramAppid}
                    onChange={e => setContent({
                        msg: { miniprogramAppid: e.target.value },
                        index: [record.corpUsergroupIndex, record.contentIndex - 1],
                        type: 'welcome'
                    })}
                /> : '--'
            },
        },
        {
            title: '小程序路径',
            dataIndex: 'miniprogramPage',
            key: 'miniprogramPage',
            width: 250,
            render(_, record) {
                return record?.miniProgramData?.length > 0 ? <div style={{ display: 'flex', gap: 4, alignItems: 'flex-end' }}>
                    <Input.TextArea
                        placeholder="请输入小程序路径"
                        allowClear
                        value={previewContent?.welcomeMsgContent?.[record.corpUsergroupIndex]?.[record.contentIndex - 1]?.miniprogramPage}
                        onChange={e => setContent({
                            msg: { miniprogramPage: e.target.value },
                            index: [record.corpUsergroupIndex, record.contentIndex - 1],
                            type: 'welcome'
                        })}
                    />
                    <SelectBookLinkButton
                        bookPlatForm={bookPlatForm}
                        mpAccountId={record.corpUserList?.[0]?.mpAccountId}
                        linkData={[{
                            msgType: "TASK_CONTENT_LINK",
                            link: {
                                title: record.miniProgramData?.[0]?.miniprogramTitle,
                                picUrl: record.miniProgramData?.[0]?.miniprogramPicurl,
                                desc: ''
                            }
                        }]}
                        onChange={(_, miniprogramAppid, miniprogramPage) => {
                            const msg: { [x: string]: string } = {}
                            if (miniprogramAppid && miniprogramPage) {
                                msg.miniprogramAppid = miniprogramAppid
                                msg.miniprogramPage = miniprogramPage
                                setContent({
                                    msg,
                                    index: [record.corpUsergroupIndex, record.contentIndex - 1],
                                    type: 'welcome'
                                })
                            }
                        }}
                    />
                </div> : '--'
            }
        }
    ]
}


export const friendsColumns = (): ColumnsType<AnyObject> => {
    return [
        {
            title: '账号',
            dataIndex: 'corpUserName',
            key: 'corpUserName',
            width: 150,
            render(value, record) {
                return <Text>{value}（{record.corpUserId}）</Text>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '朋友圈信息',
            dataIndex: 'momentSendName',
            key: 'momentSendName',
            width: 130,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>标题：{value}</Title>
                    {record?.bizType && <Paragraph style={{ margin: 0 }}>业务类型：{record?.bizType || '<空>'}</Paragraph>}
                    {record?.platform && <Paragraph style={{ margin: 0 }}>书城：{record?.platform || '<空>'}</Paragraph>}
                    {record?.templateProductId && <Paragraph style={{ margin: 0 }}>适用产品：{record?.templateProductId || '<空>'}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.userRowSpan }
            }
        },
        {
            title: '策略信息',
            dataIndex: 'strategyData',
            key: 'strategyData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>策略{record.strategyIndex + 1}</Title>
                    <Paragraph style={{ margin: 0 }}>名称：{value?.strategyName || '<空>'}</Paragraph>
                    <Paragraph style={{ margin: 0 }}>执行类型：{TIME_TYPE[value?.timeRepeatType]}</Paragraph>
                    {value?.sendDay && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendDay}</Paragraph>}
                    {value?.startTime && <Paragraph style={{ margin: 0 }}>执行日期：{value?.startTime}~{value?.endTime ? value?.endTime : '长期执行'}</Paragraph>}
                    {value?.sendTime && <Paragraph style={{ margin: 0 }}>执行时间：{value?.sendTime}</Paragraph>}
                    {value?.repeatArray && <Paragraph style={{ margin: 0 }}>执行天数：{value?.repeatArray.join('、')}</Paragraph>}
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.strategyRowSpan }
            }
        },
        {
            title: '发送对象',
            dataIndex: 'sendData',
            key: 'sendData',
            width: 200,
            render(value, record) {
                return <>
                    <Title level={5} style={{ margin: 0 }}>发送对象{record.sendDataIndex}</Title>
                    <Paragraph style={{ margin: 0 }}>内容发送模式：{welcomeContentData?.find(i => i.value === record?.sendMode)?.label}</Paragraph>
                    <Paragraph style={{ margin: 0 }} ellipsis={{ rows: 3, tooltip: true }}>企微标签：{value?.length > 0 ? value?.map(i => i.title).join('、') : '全部'}</Paragraph>
                </>
            },
            onCell: (record) => {
                return { rowSpan: record.strategyRowSpan }
            }
        },
        {
            title: '发送内容',
            dataIndex: 'content',
            key: 'content',
            width: 200,
            render(_, record) {
                return <>
                    <FriendsShowTable
                        data={record?.content}
                        name={<><span>内容{record.contentIndex + 1}：</span><span dangerouslySetInnerHTML={{ __html: record.contentReactNode?.map((item) => item).join('、') }}></span></>}
                    />
                </>
            },
        },
        {
            title: '图文链接',
            dataIndex: 'linkUrl',
            key: 'linkUrl',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.friendsContent?.linkUrl ? 'bold' : 'normal' }}>{record?.friendsContent?.linkUrl || '--'}</Paragraph>
            },
        },
        {
            title: '小程序APPID',
            dataIndex: 'miniprogramAppid',
            key: 'miniprogramAppid',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.friendsContent?.miniprogramAppid ? 'bold' : 'normal' }}>{record?.friendsContent?.miniprogramAppid || '--'}</Paragraph>
            },
        },
        {
            title: '小程序路径',
            dataIndex: 'miniprogramPage',
            key: 'miniprogramPage',
            width: 200,
            render(_, record) {
                return <Paragraph style={{ margin: 0, color: '#000', fontWeight: !!record?.friendsContent?.miniprogramPage ? 'bold' : 'normal' }}>{record?.friendsContent?.miniprogramPage || '--'}</Paragraph>
            },
        }
    ]
}