123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662 |
- import { App, Button, Card, Form, Input, Modal, Select } from "antd";
- import React from "react";
- import { FANQIELINKTYPE, HUASHENGLINKTYPE, LINKTYPE, WENDINGLINKTYPE } from "./const";
- import { PlusOutlined, MinusCircleOutlined } from "@ant-design/icons";
- import { useAjax } from "@/Hook/useAjax";
- import { addCorpAutoLinkApi } from "../../API/bookLink";
- import PagePromoLinkCreateDTO from "./components/yuewen/pagePromoLinkCreateDTO";
- import BookPromoLinkCreateDTO from "./components/yuewen/bookPromoLinkCreateDTO";
- import RechargeActivityLinkDTO from "./components/yuewen/rechargeActivityLinkDTO";
- import GiftActivityLinkDTO from "./components/yuewen/giftActivityLinkDTO";
- import ConsumeActivityLinkDTO from "./components/yuewen/consumeActivityLinkDTO";
- import PagePromoLinkCreateDTOFanQie from "./components/fanqie/pagePromoLinkCreateDTO";
- import BookPromoLinkCreateDTOFanqie from "./components/fanqie/bookPromoLinkCreateDTO";
- import RechargeActivityLinkDTOFanqie from "./components/fanqie/rechargeActivityLinkDTO";
- import GiftActivityLinkDTOFanQie from "./components/fanqie/giftActivityLinkDTO";
- import ConsumeActivityLinkDTOFanQie from "./components/fanqie/consumeActivityLinkDTO";
- import BookPromoLinkCreateDTOHuaSheng from './components/huasheng/bookPromoLinkCreateDTO'
- import RechargeActivityLinkDTOHuaSheng from './components/huasheng/rechargeActivityLinkDTO'
- import GiftActivityLinkDTOHuaSheng from './components/huasheng/giftActivityLinkDTO'
- import BookPromoLinkCreateDTOWenDing from './components/wending/bookPromoLinkCreateDTO'
- import RechargeActivityLinkDTOWenDing from './components/wending/rechargeActivityLinkDTO'
- import dayJs from "dayjs";
- interface Props {
- mpList: { label: string, value: number }[]
- bookPlatForm: TASK_CREATE.BookPlatFormProps[]
- visible?: boolean;
- onChange?: () => void
- onClose?: () => void
- initialValues?: any
- }
- export const DispatchBookLink = React.createContext<BOOKLINK.DispatchBookLink | null>(null);
- /**
- * 书城链接生成
- * @param param0
- * @returns
- */
- const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChange, onClose, initialValues = { yueWenCreateLinkDTOList: [{}] } }) => {
- /********************************************/
- const { message } = App.useApp()
- const [form] = Form.useForm();
- const yueWenCreateLinkDTOList = Form.useWatch('yueWenCreateLinkDTOList', form)
- const fanQieCreateLinkDTOList = Form.useWatch('fanQieCreateLinkDTOList', form)
- const huaShengCreateLinkDTOList = Form.useWatch('huaShengCreateLinkDTOList', form)
- const wenDingCreateLinkDTOList = Form.useWatch('wenDingCreateLinkDTOList', form)
- const platform = Form.useWatch('platform', form)
- const mpAccountIds = Form.useWatch('mpAccountIds', form)
- const addCorpAutoLink = useAjax((params) => addCorpAutoLinkApi(params))
- /********************************************/
- const handleOk = () => {
- form.validateFields().then((values) => {
- console.log(values)
- let params: { [x: string]: any } = {}
- if (values?.platform === 'YUE_WEN') {
- params = {
- mpAccountIds: values.mpAccountIds,
- platform: values.platform,
- yueWenCreateLinkDTOList: values.yueWenCreateLinkDTOList.map(item => {
- const { linkType, pagePromoLinkCreateDTO, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, consumeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
- if (linkType === '1') {
- return { ...rest, pagePromoLinkCreateDTO, linkType }
- } else if (linkType === '2') {
- return { ...rest, bookPromoLinkCreateDTO, linkType }
- } else if (linkType === '3') {
- const { activityTime, display, isDayRepeat, rechargeCount, ...ralDto } = rechargeActivityLinkDTO
- return { ...rest, rechargeActivityLinkDTO: { ...ralDto, rechargeCount, isDayRepeat: rechargeCount == 1 ? isDayRepeat : false, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
- } else if (linkType === '4') {
- const { activityTime, display, ...calDto } = giftActivityLinkDTO
- return { ...rest, giftActivityLinkDTO: { ...calDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
- } else if (linkType === '5') {
- const { activityTime, display, ...galDto } = consumeActivityLinkDTO
- return { ...rest, consumeActivityLinkDTO: { ...galDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
- }
- })
- }
- } else if (values?.platform === 'FAN_QIE') {
- params = {
- mpAccountIds: values.mpAccountIds,
- platform: values.platform,
- fanQieCreateLinkDTOList: values.fanQieCreateLinkDTOList.map(item => {
- const { linkType, pagePromoLinkCreateDTO, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, consumeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
- if (linkType === '1') {
- return { ...rest, pagePromoLinkCreateDTO, linkType }
- } else if (linkType === '2') {
- return { ...rest, bookPromoLinkCreateDTO, linkType }
- } else if (linkType === '3') {
- const { activityTime, ...ralDto } = rechargeActivityLinkDTO
- return { ...rest, rechargeActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
- } else if (linkType === '4') {
- const { activityTime, ...calDto } = giftActivityLinkDTO
- return { ...rest, giftActivityLinkDTO: { ...calDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
- } else if (linkType === '5') {
- const { activityTime, ...galDto } = consumeActivityLinkDTO
- return { ...rest, consumeActivityLinkDTO: { ...galDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
- }
- })
- }
- } else if (values?.platform === 'HUA_SHENG') {
- params = {
- mpAccountIds: values.mpAccountIds,
- platform: values.platform,
- huaShengCreateLinkDTOList: values.huaShengCreateLinkDTOList.map(item => {
- const { linkType, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
- if (linkType === '1') {
- return { ...rest, bookPromoLinkCreateDTO, linkType }
- } else if (linkType === '2') {
- const { activityTime, display, rechargeAmount, giftAmount, ...ralDto } = rechargeActivityLinkDTO
- return { ...rest, rechargeActivityLinkDTO: { ...ralDto, productName: rechargeAmount + '-' + giftAmount, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
- } else if (linkType === '3') {
- const { activityTime, display, rechargeAmount, giftAmount, ...ralDto } = giftActivityLinkDTO
- return { ...rest, giftActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
- }
- })
- }
- } else if (values?.platform === 'WEN_DING') {
- params = {
- mpAccountIds: values.mpAccountIds,
- platform: values.platform,
- wenDingCreateLinkDTOList: values.wenDingCreateLinkDTOList.map(item => {
- const { linkType, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
- if (linkType === '1') {
- return { ...rest, bookPromoLinkCreateDTO, linkType }
- } else if (linkType === '2') {
- const { activityTime, ...ralDto } = rechargeActivityLinkDTO
- return { ...rest, rechargeActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
- }
- })
- }
- } else {
- message.error('当前书城占不支持')
- return
- }
- addCorpAutoLink.run(params).then(res => {
- if (res?.data) {
- message.success('添加成功')
- onChange?.()
- }
- })
- }).catch(() => {
- form.submit()
- });
- }
- return <Modal
- title={<strong>书城链接生成</strong>}
- open={visible}
- onCancel={onClose}
- onOk={handleOk}
- width={650}
- confirmLoading={addCorpAutoLink.loading}
- >
- <Form
- form={form}
- name="newBookLink"
- labelAlign='left'
- labelCol={{ span: 5 }}
- colon={false}
- scrollToFirstError={{
- behavior: 'smooth',
- block: 'center'
- }}
- onFinishFailed={({ errorFields }) => {
- message.error(errorFields?.[0]?.errors?.[0])
- }}
- onFinish={handleOk}
- initialValues={initialValues}
- >
- <Card title={<strong>基础信息配置</strong>} style={{ background: '#fff', marginBottom: 10 }}>
- <Form.Item label={<strong>书城</strong>} name="platform" rules={[{ required: true, message: '请选择书城!' }]}>
- <Select
- showSearch
- placeholder="书城"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={bookPlatForm.map(item => ({ value: item.platformKey, label: item.platformName }))}
- onChange={(e) => {
- if (e === 'YUE_WEN') {
- form.setFieldsValue({ yueWenCreateLinkDTOList: [{}] })
- } else if (e === 'FAN_QIE') {
- form.setFieldsValue({ fanQieCreateLinkDTOList: [{}] })
- } else if (e === 'HUA_SHENG') {
- form.setFieldsValue({ huaShengCreateLinkDTOList: [{}] })
- } else if (e === 'WEN_DING') {
- form.setFieldsValue({ wenDingCreateLinkDTOList: [{}] })
- }
- }}
- />
- </Form.Item>
- <Form.Item label={<strong>公众号</strong>} name="mpAccountIds" rules={[{ required: true, message: '请选择公众号!' }]}>
- <Select
- showSearch
- mode="multiple"
- allowClear
- placeholder="公众号"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- options={mpList}
- />
- </Form.Item>
- </Card>
- <DispatchBookLink.Provider value={{ form }}>
- {platform === 'YUE_WEN' ? <Form.List name="yueWenCreateLinkDTOList">
- {(fields, { add, remove }) => (
- <>
- {fields.map(({ key, name, ...restField }, index) => {
- const yueWenCreateLinkDTO = yueWenCreateLinkDTOList?.[index]
- return <Card
- title={<strong>链接信息配置{index + 1}</strong>}
- style={{ background: '#fff', marginBottom: 10 }}
- key={key}
- extra={yueWenCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
- <MinusCircleOutlined />
- </div> : undefined}
- >
- <Form.Item
- {...restField}
- name={[name, 'linkType']}
- label={<strong>链接类型</strong>}
- rules={[{ required: true, message: '请选择链接类型!' }]}
- >
- <Select
- showSearch
- placeholder="链接类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={Object.keys(LINKTYPE).map(key => ({ label: LINKTYPE[key], value: key }))}
- onChange={(e) => {
- if (e === '1') {
- setTimeout(() => {
- form.setFieldsValue({
- yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '1', pagePromoLinkCreateDTO: {} }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '2') {
- setTimeout(() => {
- form.setFieldsValue({
- yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '2', bookPromoLinkCreateDTO: { forceStyle: 1, isOpenBottom: false, forceChapter: 0 } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '3') {
- setTimeout(() => {
- form.setFieldsValue({
- yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '3', rechargeActivityLinkDTO: { rechargeCount: 1, timeIsShow: 1, isDayRepeat: 0 } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '4') {
- setTimeout(() => {
- form.setFieldsValue({
- yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '4', giftActivityLinkDTO: { expire: 7, resourceType: '1' } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '5') {
- setTimeout(() => {
- form.setFieldsValue({
- yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '5', consumeActivityLinkDTO: {} }
- }
- return item
- })
- })
- }, 0)
- }
- }}
- />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelName']}
- label={<strong>渠道名称</strong>}
- rules={[{ required: true, message: '请输入渠道名称!' }]}
- >
- <Input placeholder="请输入渠道名称" allowClear />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelType']}
- label={<strong>推广类型</strong>}
- rules={[{ required: true, message: '请选择推广类型!' }]}
- >
- <Select
- showSearch
- placeholder="推广类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={[{ label: '外部', value: '1' }, { label: '内部', value: '2' }]}
- />
- </Form.Item>
- {yueWenCreateLinkDTO?.linkType === '1' ? <PagePromoLinkCreateDTO restField={restField} name={name} /> :
- yueWenCreateLinkDTO?.linkType === '2' ? <BookPromoLinkCreateDTO restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} yueWenCreateLinkDTO={yueWenCreateLinkDTO} /> :
- yueWenCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTO restField={restField} name={name} itemData={yueWenCreateLinkDTO} /> :
- yueWenCreateLinkDTO?.linkType === '4' ? <GiftActivityLinkDTO restField={restField} name={name} /> :
- yueWenCreateLinkDTO?.linkType === '5' ? <ConsumeActivityLinkDTO restField={restField} name={name} /> :
- undefined}
- </Card>
- })}
- <Form.Item>
- <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
- 新增链接信息配置
- </Button>
- </Form.Item>
- </>
- )}
- </Form.List> : platform === "FAN_QIE" ? <Form.List name="fanQieCreateLinkDTOList">
- {(fields, { add, remove }) => (
- <>
- {fields.map(({ key, name, ...restField }, index) => {
- const fanQieCreateLinkDTO = fanQieCreateLinkDTOList?.[index]
- return <Card
- title={<strong>链接信息配置{index + 1}</strong>}
- style={{ background: '#fff', marginBottom: 10 }}
- key={key}
- extra={fanQieCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
- <MinusCircleOutlined />
- </div> : undefined}
- >
- <Form.Item
- {...restField}
- name={[name, 'linkType']}
- label={<strong>链接类型</strong>}
- rules={[{ required: true, message: '请选择链接类型!' }]}
- >
- <Select
- showSearch
- placeholder="链接类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={Object.keys(FANQIELINKTYPE).map(key => ({ label: FANQIELINKTYPE[key], value: key }))}
- onChange={(e) => {
- if (e === '1') {
- setTimeout(() => {
- form.setFieldsValue({
- fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '1', pagePromoLinkCreateDTO: {} }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '2') {
- setTimeout(() => {
- form.setFieldsValue({
- fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '2', bookPromoLinkCreateDTO: {} }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '3') {
- setTimeout(() => {
- form.setFieldsValue({
- fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '3', rechargeActivityLinkDTO: { rechargeCount: -1 } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '4') {
- setTimeout(() => {
- form.setFieldsValue({
- fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '4', giftActivityLinkDTO: { rechargeCount: 1 } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '5') {
- setTimeout(() => {
- form.setFieldsValue({
- fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '5', consumeActivityLinkDTO: { rechargeCount: 1, activityFrequencies: 2 } }
- }
- return item
- })
- })
- }, 0)
- }
- }}
- />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelName']}
- label={<strong>渠道名称</strong>}
- rules={[{ required: true, message: '请输入渠道名称!' }]}
- >
- <Input placeholder="请输入渠道名称" allowClear />
- </Form.Item>
- {fanQieCreateLinkDTO?.linkType === '1' ? <PagePromoLinkCreateDTOFanQie restField={restField} name={name} /> :
- fanQieCreateLinkDTO?.linkType === '2' ? <BookPromoLinkCreateDTOFanqie restField={restField} name={name} platform={platform} /> :
- fanQieCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTOFanqie restField={restField} name={name} /> :
- fanQieCreateLinkDTO?.linkType === '4' ? <GiftActivityLinkDTOFanQie restField={restField} name={name} vipDuration={fanQieCreateLinkDTO?.giftActivityLinkDTO?.vipDuration} /> :
- fanQieCreateLinkDTO?.linkType === '5' ? <ConsumeActivityLinkDTOFanQie restField={restField} name={name} /> :
- undefined}
- </Card>
- })}
- <Form.Item>
- <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
- 新增链接信息配置
- </Button>
- </Form.Item>
- </>
- )}
- </Form.List> : platform === 'HUA_SHENG' ? <Form.List name="huaShengCreateLinkDTOList">
- {(fields, { add, remove }) => (
- <>
- {fields.map(({ key, name, ...restField }, index) => {
- const huaShengCreateLinkDTO = huaShengCreateLinkDTOList?.[index]
- return <Card
- title={<strong>链接信息配置{index + 1}</strong>}
- style={{ background: '#fff', marginBottom: 10 }}
- key={key}
- extra={huaShengCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
- <MinusCircleOutlined />
- </div> : undefined}
- >
- <Form.Item
- {...restField}
- name={[name, 'linkType']}
- label={<strong>链接类型</strong>}
- rules={[{ required: true, message: '请选择链接类型!' }]}
- >
- <Select
- showSearch
- placeholder="链接类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={Object.keys(HUASHENGLINKTYPE).map(key => ({ label: HUASHENGLINKTYPE[key], value: key }))}
- onChange={(e) => {
- if (e === '1') {
- setTimeout(() => {
- form.setFieldsValue({
- huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '1', bookPromoLinkCreateDTO: { cost: 0 } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '2') {
- setTimeout(() => {
- form.setFieldsValue({
- huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '2', rechargeActivityLinkDTO: { status: 'normal', chargeType: 0, userType: 1, charge: 0, commonType: 0, display: ['stack', 'read_footer_text'] } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '3') {
- setTimeout(() => {
- form.setFieldsValue({
- huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName } = item
- return { channelName, linkType: '3', giftActivityLinkDTO: { status: 'normal', freeAmount: 50, userType: 1, charge: 0, commonType: 0, display: ['stack', 'read_footer_text'] } }
- }
- return item
- })
- })
- }, 0)
- }
- }}
- />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelName']}
- label={<strong>渠道名称</strong>}
- rules={[{ required: true, message: '请输入渠道名称!' }]}
- >
- <Input placeholder="请输入渠道名称" allowClear />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelType']}
- label={<strong>推广类型</strong>}
- rules={[{ required: huaShengCreateLinkDTO?.linkType == 1 ? true : false, message: '请选择推广类型!' }]}
- >
- <Select
- showSearch
- placeholder="推广类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={[{ label: '外部', value: '1' }, { label: '内部', value: '2' }]}
- />
- </Form.Item>
- {huaShengCreateLinkDTO?.linkType === '1' ? <BookPromoLinkCreateDTOHuaSheng restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} huaShengCreateLinkDTO={huaShengCreateLinkDTO} /> :
- huaShengCreateLinkDTO?.linkType === '2' ? <RechargeActivityLinkDTOHuaSheng restField={restField} name={name} itemData={huaShengCreateLinkDTO} /> :
- huaShengCreateLinkDTO?.linkType === '3' ? <GiftActivityLinkDTOHuaSheng restField={restField} name={name} itemData={huaShengCreateLinkDTO} /> :
- undefined}
- </Card>
- })}
- <Form.Item>
- <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
- 新增链接信息配置
- </Button>
- </Form.Item>
- </>
- )}
- </Form.List> : platform === 'WEN_DING' ? <Form.List name="wenDingCreateLinkDTOList">
- {(fields, { add, remove }) => (
- <>
- {fields.map(({ key, name, ...restField }, index) => {
- const wenDingCreateLinkDTO = wenDingCreateLinkDTOList?.[index]
- return <Card
- title={<strong>链接信息配置{index + 1}</strong>}
- style={{ background: '#fff', marginBottom: 10 }}
- key={key}
- extra={wenDingCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
- <MinusCircleOutlined />
- </div> : undefined}
- >
- <Form.Item
- {...restField}
- name={[name, 'linkType']}
- label={<strong>链接类型</strong>}
- rules={[{ required: true, message: '请选择链接类型!' }]}
- >
- <Select
- showSearch
- placeholder="链接类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={Object.keys(WENDINGLINKTYPE).map(key => ({ label: WENDINGLINKTYPE[key], value: key }))}
- onChange={(e) => {
- if (e === '1') {
- setTimeout(() => {
- form.setFieldsValue({
- wenDingCreateLinkDTOList: wenDingCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '1', bookPromoLinkCreateDTO: { qrcodeOpenStatus: 0, linkClassify: '3' } }
- }
- return item
- })
- })
- }, 0)
- } else if (e === '2') {
- setTimeout(() => {
- form.setFieldsValue({
- wenDingCreateLinkDTOList: wenDingCreateLinkDTOList.map((item, i) => {
- if (index === i) {
- const { channelName, channelType } = item
- return { channelName, channelType, linkType: '2', rechargeActivityLinkDTO: { userGroup: 0, hideCountDown: 0 } }
- }
- return item
- })
- })
- }, 0)
- }
- }}
- />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelName']}
- label={<strong>渠道名称</strong>}
- rules={[{ required: true, message: '请输入渠道名称!' }]}
- >
- <Input placeholder="请输入渠道名称" allowClear />
- </Form.Item>
- <Form.Item
- {...restField}
- name={[name, 'channelType']}
- label={<strong>推广类型</strong>}
- rules={[{ required: true, message: '请选择推广类型!' }]}
- >
- <Select
- showSearch
- placeholder="推广类型"
- filterOption={(input, option) =>
- ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
- }
- allowClear
- options={[{ label: '内推', value: 0 }, { label: '派单', value: 1 }]}
- />
- </Form.Item>
- {wenDingCreateLinkDTO?.linkType === '1' ? <BookPromoLinkCreateDTOWenDing restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} wenDingCreateLinkDTO={wenDingCreateLinkDTO} /> :
- wenDingCreateLinkDTO?.linkType === '2' ? <RechargeActivityLinkDTOWenDing restField={restField} name={name} /> :
- undefined}
- </Card>
- })}
- <Form.Item>
- <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
- 新增链接信息配置
- </Button>
- </Form.Item>
- </>
- )}
- </Form.List> : undefined}
- </DispatchBookLink.Provider>
- </Form>
- </Modal>
- };
- export default React.memo(ModalBookLink);
|