modalBooklink.tsx 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. import { App, Button, Card, Form, Input, Modal, Select } from "antd";
  2. import React from "react";
  3. import { FANQIELINKTYPE, HUASHENGLINKTYPE, LINKTYPE, WENDINGLINKTYPE } from "./const";
  4. import { PlusOutlined, MinusCircleOutlined } from "@ant-design/icons";
  5. import { useAjax } from "@/Hook/useAjax";
  6. import { addCorpAutoLinkApi } from "../../API/bookLink";
  7. import PagePromoLinkCreateDTO from "./components/yuewen/pagePromoLinkCreateDTO";
  8. import BookPromoLinkCreateDTO from "./components/yuewen/bookPromoLinkCreateDTO";
  9. import RechargeActivityLinkDTO from "./components/yuewen/rechargeActivityLinkDTO";
  10. import GiftActivityLinkDTO from "./components/yuewen/giftActivityLinkDTO";
  11. import ConsumeActivityLinkDTO from "./components/yuewen/consumeActivityLinkDTO";
  12. import PagePromoLinkCreateDTOFanQie from "./components/fanqie/pagePromoLinkCreateDTO";
  13. import BookPromoLinkCreateDTOFanqie from "./components/fanqie/bookPromoLinkCreateDTO";
  14. import RechargeActivityLinkDTOFanqie from "./components/fanqie/rechargeActivityLinkDTO";
  15. import GiftActivityLinkDTOFanQie from "./components/fanqie/giftActivityLinkDTO";
  16. import ConsumeActivityLinkDTOFanQie from "./components/fanqie/consumeActivityLinkDTO";
  17. import BookPromoLinkCreateDTOHuaSheng from './components/huasheng/bookPromoLinkCreateDTO'
  18. import RechargeActivityLinkDTOHuaSheng from './components/huasheng/rechargeActivityLinkDTO'
  19. import GiftActivityLinkDTOHuaSheng from './components/huasheng/giftActivityLinkDTO'
  20. import BookPromoLinkCreateDTOWenDing from './components/wending/bookPromoLinkCreateDTO'
  21. import RechargeActivityLinkDTOWenDing from './components/wending/rechargeActivityLinkDTO'
  22. import dayJs from "dayjs";
  23. interface Props {
  24. mpList: { label: string, value: number }[]
  25. bookPlatForm: TASK_CREATE.BookPlatFormProps[]
  26. visible?: boolean;
  27. onChange?: () => void
  28. onClose?: () => void
  29. initialValues?: any
  30. }
  31. export const DispatchBookLink = React.createContext<BOOKLINK.DispatchBookLink | null>(null);
  32. /**
  33. * 书城链接生成
  34. * @param param0
  35. * @returns
  36. */
  37. const ModalBookLink: React.FC<Props> = ({ mpList, bookPlatForm, visible, onChange, onClose, initialValues = { yueWenCreateLinkDTOList: [{}] } }) => {
  38. /********************************************/
  39. const { message } = App.useApp()
  40. const [form] = Form.useForm();
  41. const yueWenCreateLinkDTOList = Form.useWatch('yueWenCreateLinkDTOList', form)
  42. const fanQieCreateLinkDTOList = Form.useWatch('fanQieCreateLinkDTOList', form)
  43. const huaShengCreateLinkDTOList = Form.useWatch('huaShengCreateLinkDTOList', form)
  44. const wenDingCreateLinkDTOList = Form.useWatch('wenDingCreateLinkDTOList', form)
  45. const platform = Form.useWatch('platform', form)
  46. const mpAccountIds = Form.useWatch('mpAccountIds', form)
  47. const addCorpAutoLink = useAjax((params) => addCorpAutoLinkApi(params))
  48. /********************************************/
  49. const handleOk = () => {
  50. form.validateFields().then((values) => {
  51. console.log(values)
  52. let params: { [x: string]: any } = {}
  53. if (values?.platform === 'YUE_WEN') {
  54. params = {
  55. mpAccountIds: values.mpAccountIds,
  56. platform: values.platform,
  57. yueWenCreateLinkDTOList: values.yueWenCreateLinkDTOList.map(item => {
  58. const { linkType, pagePromoLinkCreateDTO, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, consumeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
  59. if (linkType === '1') {
  60. return { ...rest, pagePromoLinkCreateDTO, linkType }
  61. } else if (linkType === '2') {
  62. return { ...rest, bookPromoLinkCreateDTO, linkType }
  63. } else if (linkType === '3') {
  64. const { activityTime, display, isDayRepeat, rechargeCount, ...ralDto } = rechargeActivityLinkDTO
  65. 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 }
  66. } else if (linkType === '4') {
  67. const { activityTime, display, ...calDto } = giftActivityLinkDTO
  68. return { ...rest, giftActivityLinkDTO: { ...calDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
  69. } else if (linkType === '5') {
  70. const { activityTime, display, ...galDto } = consumeActivityLinkDTO
  71. return { ...rest, consumeActivityLinkDTO: { ...galDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
  72. }
  73. })
  74. }
  75. } else if (values?.platform === 'FAN_QIE') {
  76. params = {
  77. mpAccountIds: values.mpAccountIds,
  78. platform: values.platform,
  79. fanQieCreateLinkDTOList: values.fanQieCreateLinkDTOList.map(item => {
  80. const { linkType, pagePromoLinkCreateDTO, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, consumeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
  81. if (linkType === '1') {
  82. return { ...rest, pagePromoLinkCreateDTO, linkType }
  83. } else if (linkType === '2') {
  84. return { ...rest, bookPromoLinkCreateDTO, linkType }
  85. } else if (linkType === '3') {
  86. const { activityTime, ...ralDto } = rechargeActivityLinkDTO
  87. return { ...rest, rechargeActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
  88. } else if (linkType === '4') {
  89. const { activityTime, ...calDto } = giftActivityLinkDTO
  90. return { ...rest, giftActivityLinkDTO: { ...calDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
  91. } else if (linkType === '5') {
  92. const { activityTime, ...galDto } = consumeActivityLinkDTO
  93. return { ...rest, consumeActivityLinkDTO: { ...galDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
  94. }
  95. })
  96. }
  97. } else if (values?.platform === 'HUA_SHENG') {
  98. params = {
  99. mpAccountIds: values.mpAccountIds,
  100. platform: values.platform,
  101. huaShengCreateLinkDTOList: values.huaShengCreateLinkDTOList.map(item => {
  102. const { linkType, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
  103. if (linkType === '1') {
  104. return { ...rest, bookPromoLinkCreateDTO, linkType }
  105. } else if (linkType === '2') {
  106. const { activityTime, display, rechargeAmount, giftAmount, ...ralDto } = rechargeActivityLinkDTO
  107. 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 }
  108. } else if (linkType === '3') {
  109. const { activityTime, display, rechargeAmount, giftAmount, ...ralDto } = giftActivityLinkDTO
  110. return { ...rest, giftActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD'), display: display?.join(',') }, linkType }
  111. }
  112. })
  113. }
  114. } else if (values?.platform === 'WEN_DING') {
  115. params = {
  116. mpAccountIds: values.mpAccountIds,
  117. platform: values.platform,
  118. wenDingCreateLinkDTOList: values.wenDingCreateLinkDTOList.map(item => {
  119. const { linkType, bookPromoLinkCreateDTO, rechargeActivityLinkDTO, giftActivityLinkDTO, ...rest } = item
  120. if (linkType === '1') {
  121. return { ...rest, bookPromoLinkCreateDTO, linkType }
  122. } else if (linkType === '2') {
  123. const { activityTime, ...ralDto } = rechargeActivityLinkDTO
  124. return { ...rest, rechargeActivityLinkDTO: { ...ralDto, startTime: dayJs(activityTime[0]).format('YYYY-MM-DD'), endTime: dayJs(activityTime[1]).format('YYYY-MM-DD') }, linkType }
  125. }
  126. })
  127. }
  128. } else {
  129. message.error('当前书城占不支持')
  130. return
  131. }
  132. addCorpAutoLink.run(params).then(res => {
  133. if (res?.data) {
  134. message.success('添加成功')
  135. onChange?.()
  136. }
  137. })
  138. }).catch(() => {
  139. form.submit()
  140. });
  141. }
  142. return <Modal
  143. title={<strong>书城链接生成</strong>}
  144. open={visible}
  145. onCancel={onClose}
  146. onOk={handleOk}
  147. width={650}
  148. confirmLoading={addCorpAutoLink.loading}
  149. >
  150. <Form
  151. form={form}
  152. name="newBookLink"
  153. labelAlign='left'
  154. labelCol={{ span: 5 }}
  155. colon={false}
  156. scrollToFirstError={{
  157. behavior: 'smooth',
  158. block: 'center'
  159. }}
  160. onFinishFailed={({ errorFields }) => {
  161. message.error(errorFields?.[0]?.errors?.[0])
  162. }}
  163. onFinish={handleOk}
  164. initialValues={initialValues}
  165. >
  166. <Card title={<strong>基础信息配置</strong>} style={{ background: '#fff', marginBottom: 10 }}>
  167. <Form.Item label={<strong>书城</strong>} name="platform" rules={[{ required: true, message: '请选择书城!' }]}>
  168. <Select
  169. showSearch
  170. placeholder="书城"
  171. filterOption={(input, option) =>
  172. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  173. }
  174. allowClear
  175. options={bookPlatForm.map(item => ({ value: item.platformKey, label: item.platformName }))}
  176. onChange={(e) => {
  177. if (e === 'YUE_WEN') {
  178. form.setFieldsValue({ yueWenCreateLinkDTOList: [{}] })
  179. } else if (e === 'FAN_QIE') {
  180. form.setFieldsValue({ fanQieCreateLinkDTOList: [{}] })
  181. } else if (e === 'HUA_SHENG') {
  182. form.setFieldsValue({ huaShengCreateLinkDTOList: [{}] })
  183. } else if (e === 'WEN_DING') {
  184. form.setFieldsValue({ wenDingCreateLinkDTOList: [{}] })
  185. }
  186. }}
  187. />
  188. </Form.Item>
  189. <Form.Item label={<strong>公众号</strong>} name="mpAccountIds" rules={[{ required: true, message: '请选择公众号!' }]}>
  190. <Select
  191. showSearch
  192. mode="multiple"
  193. allowClear
  194. placeholder="公众号"
  195. filterOption={(input, option) =>
  196. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  197. }
  198. options={mpList}
  199. />
  200. </Form.Item>
  201. </Card>
  202. <DispatchBookLink.Provider value={{ form }}>
  203. {platform === 'YUE_WEN' ? <Form.List name="yueWenCreateLinkDTOList">
  204. {(fields, { add, remove }) => (
  205. <>
  206. {fields.map(({ key, name, ...restField }, index) => {
  207. const yueWenCreateLinkDTO = yueWenCreateLinkDTOList?.[index]
  208. return <Card
  209. title={<strong>链接信息配置{index + 1}</strong>}
  210. style={{ background: '#fff', marginBottom: 10 }}
  211. key={key}
  212. extra={yueWenCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
  213. <MinusCircleOutlined />
  214. </div> : undefined}
  215. >
  216. <Form.Item
  217. {...restField}
  218. name={[name, 'linkType']}
  219. label={<strong>链接类型</strong>}
  220. rules={[{ required: true, message: '请选择链接类型!' }]}
  221. >
  222. <Select
  223. showSearch
  224. placeholder="链接类型"
  225. filterOption={(input, option) =>
  226. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  227. }
  228. allowClear
  229. options={Object.keys(LINKTYPE).map(key => ({ label: LINKTYPE[key], value: key }))}
  230. onChange={(e) => {
  231. if (e === '1') {
  232. setTimeout(() => {
  233. form.setFieldsValue({
  234. yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
  235. if (index === i) {
  236. const { channelName, channelType } = item
  237. return { channelName, channelType, linkType: '1', pagePromoLinkCreateDTO: {} }
  238. }
  239. return item
  240. })
  241. })
  242. }, 0)
  243. } else if (e === '2') {
  244. setTimeout(() => {
  245. form.setFieldsValue({
  246. yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
  247. if (index === i) {
  248. const { channelName, channelType } = item
  249. return { channelName, channelType, linkType: '2', bookPromoLinkCreateDTO: { forceStyle: 1, isOpenBottom: false, forceChapter: 0 } }
  250. }
  251. return item
  252. })
  253. })
  254. }, 0)
  255. } else if (e === '3') {
  256. setTimeout(() => {
  257. form.setFieldsValue({
  258. yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
  259. if (index === i) {
  260. const { channelName, channelType } = item
  261. return { channelName, channelType, linkType: '3', rechargeActivityLinkDTO: { rechargeCount: 1, timeIsShow: 1, isDayRepeat: 0 } }
  262. }
  263. return item
  264. })
  265. })
  266. }, 0)
  267. } else if (e === '4') {
  268. setTimeout(() => {
  269. form.setFieldsValue({
  270. yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
  271. if (index === i) {
  272. const { channelName, channelType } = item
  273. return { channelName, channelType, linkType: '4', giftActivityLinkDTO: { expire: 7, resourceType: '1' } }
  274. }
  275. return item
  276. })
  277. })
  278. }, 0)
  279. } else if (e === '5') {
  280. setTimeout(() => {
  281. form.setFieldsValue({
  282. yueWenCreateLinkDTOList: yueWenCreateLinkDTOList.map((item, i) => {
  283. if (index === i) {
  284. const { channelName, channelType } = item
  285. return { channelName, channelType, linkType: '5', consumeActivityLinkDTO: {} }
  286. }
  287. return item
  288. })
  289. })
  290. }, 0)
  291. }
  292. }}
  293. />
  294. </Form.Item>
  295. <Form.Item
  296. {...restField}
  297. name={[name, 'channelName']}
  298. label={<strong>渠道名称</strong>}
  299. rules={[{ required: true, message: '请输入渠道名称!' }]}
  300. >
  301. <Input placeholder="请输入渠道名称" allowClear />
  302. </Form.Item>
  303. <Form.Item
  304. {...restField}
  305. name={[name, 'channelType']}
  306. label={<strong>推广类型</strong>}
  307. rules={[{ required: true, message: '请选择推广类型!' }]}
  308. >
  309. <Select
  310. showSearch
  311. placeholder="推广类型"
  312. filterOption={(input, option) =>
  313. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  314. }
  315. allowClear
  316. options={[{ label: '外部', value: '1' }, { label: '内部', value: '2' }]}
  317. />
  318. </Form.Item>
  319. {yueWenCreateLinkDTO?.linkType === '1' ? <PagePromoLinkCreateDTO restField={restField} name={name} /> :
  320. yueWenCreateLinkDTO?.linkType === '2' ? <BookPromoLinkCreateDTO restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} yueWenCreateLinkDTO={yueWenCreateLinkDTO} /> :
  321. yueWenCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTO restField={restField} name={name} itemData={yueWenCreateLinkDTO} /> :
  322. yueWenCreateLinkDTO?.linkType === '4' ? <GiftActivityLinkDTO restField={restField} name={name} /> :
  323. yueWenCreateLinkDTO?.linkType === '5' ? <ConsumeActivityLinkDTO restField={restField} name={name} /> :
  324. undefined}
  325. </Card>
  326. })}
  327. <Form.Item>
  328. <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
  329. 新增链接信息配置
  330. </Button>
  331. </Form.Item>
  332. </>
  333. )}
  334. </Form.List> : platform === "FAN_QIE" ? <Form.List name="fanQieCreateLinkDTOList">
  335. {(fields, { add, remove }) => (
  336. <>
  337. {fields.map(({ key, name, ...restField }, index) => {
  338. const fanQieCreateLinkDTO = fanQieCreateLinkDTOList?.[index]
  339. return <Card
  340. title={<strong>链接信息配置{index + 1}</strong>}
  341. style={{ background: '#fff', marginBottom: 10 }}
  342. key={key}
  343. extra={fanQieCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
  344. <MinusCircleOutlined />
  345. </div> : undefined}
  346. >
  347. <Form.Item
  348. {...restField}
  349. name={[name, 'linkType']}
  350. label={<strong>链接类型</strong>}
  351. rules={[{ required: true, message: '请选择链接类型!' }]}
  352. >
  353. <Select
  354. showSearch
  355. placeholder="链接类型"
  356. filterOption={(input, option) =>
  357. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  358. }
  359. allowClear
  360. options={Object.keys(FANQIELINKTYPE).map(key => ({ label: FANQIELINKTYPE[key], value: key }))}
  361. onChange={(e) => {
  362. if (e === '1') {
  363. setTimeout(() => {
  364. form.setFieldsValue({
  365. fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
  366. if (index === i) {
  367. const { channelName } = item
  368. return { channelName, linkType: '1', pagePromoLinkCreateDTO: {} }
  369. }
  370. return item
  371. })
  372. })
  373. }, 0)
  374. } else if (e === '2') {
  375. setTimeout(() => {
  376. form.setFieldsValue({
  377. fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
  378. if (index === i) {
  379. const { channelName } = item
  380. return { channelName, linkType: '2', bookPromoLinkCreateDTO: {} }
  381. }
  382. return item
  383. })
  384. })
  385. }, 0)
  386. } else if (e === '3') {
  387. setTimeout(() => {
  388. form.setFieldsValue({
  389. fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
  390. if (index === i) {
  391. const { channelName } = item
  392. return { channelName, linkType: '3', rechargeActivityLinkDTO: { rechargeCount: -1 } }
  393. }
  394. return item
  395. })
  396. })
  397. }, 0)
  398. } else if (e === '4') {
  399. setTimeout(() => {
  400. form.setFieldsValue({
  401. fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
  402. if (index === i) {
  403. const { channelName } = item
  404. return { channelName, linkType: '4', giftActivityLinkDTO: { rechargeCount: 1 } }
  405. }
  406. return item
  407. })
  408. })
  409. }, 0)
  410. } else if (e === '5') {
  411. setTimeout(() => {
  412. form.setFieldsValue({
  413. fanQieCreateLinkDTOList: fanQieCreateLinkDTOList.map((item, i) => {
  414. if (index === i) {
  415. const { channelName } = item
  416. return { channelName, linkType: '5', consumeActivityLinkDTO: { rechargeCount: 1, activityFrequencies: 2 } }
  417. }
  418. return item
  419. })
  420. })
  421. }, 0)
  422. }
  423. }}
  424. />
  425. </Form.Item>
  426. <Form.Item
  427. {...restField}
  428. name={[name, 'channelName']}
  429. label={<strong>渠道名称</strong>}
  430. rules={[{ required: true, message: '请输入渠道名称!' }]}
  431. >
  432. <Input placeholder="请输入渠道名称" allowClear />
  433. </Form.Item>
  434. {fanQieCreateLinkDTO?.linkType === '1' ? <PagePromoLinkCreateDTOFanQie restField={restField} name={name} /> :
  435. fanQieCreateLinkDTO?.linkType === '2' ? <BookPromoLinkCreateDTOFanqie restField={restField} name={name} platform={platform} /> :
  436. fanQieCreateLinkDTO?.linkType === '3' ? <RechargeActivityLinkDTOFanqie restField={restField} name={name} /> :
  437. fanQieCreateLinkDTO?.linkType === '4' ? <GiftActivityLinkDTOFanQie restField={restField} name={name} vipDuration={fanQieCreateLinkDTO?.giftActivityLinkDTO?.vipDuration} /> :
  438. fanQieCreateLinkDTO?.linkType === '5' ? <ConsumeActivityLinkDTOFanQie restField={restField} name={name} /> :
  439. undefined}
  440. </Card>
  441. })}
  442. <Form.Item>
  443. <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
  444. 新增链接信息配置
  445. </Button>
  446. </Form.Item>
  447. </>
  448. )}
  449. </Form.List> : platform === 'HUA_SHENG' ? <Form.List name="huaShengCreateLinkDTOList">
  450. {(fields, { add, remove }) => (
  451. <>
  452. {fields.map(({ key, name, ...restField }, index) => {
  453. const huaShengCreateLinkDTO = huaShengCreateLinkDTOList?.[index]
  454. return <Card
  455. title={<strong>链接信息配置{index + 1}</strong>}
  456. style={{ background: '#fff', marginBottom: 10 }}
  457. key={key}
  458. extra={huaShengCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
  459. <MinusCircleOutlined />
  460. </div> : undefined}
  461. >
  462. <Form.Item
  463. {...restField}
  464. name={[name, 'linkType']}
  465. label={<strong>链接类型</strong>}
  466. rules={[{ required: true, message: '请选择链接类型!' }]}
  467. >
  468. <Select
  469. showSearch
  470. placeholder="链接类型"
  471. filterOption={(input, option) =>
  472. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  473. }
  474. allowClear
  475. options={Object.keys(HUASHENGLINKTYPE).map(key => ({ label: HUASHENGLINKTYPE[key], value: key }))}
  476. onChange={(e) => {
  477. if (e === '1') {
  478. setTimeout(() => {
  479. form.setFieldsValue({
  480. huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
  481. if (index === i) {
  482. const { channelName, channelType } = item
  483. return { channelName, channelType, linkType: '1', bookPromoLinkCreateDTO: { cost: 0 } }
  484. }
  485. return item
  486. })
  487. })
  488. }, 0)
  489. } else if (e === '2') {
  490. setTimeout(() => {
  491. form.setFieldsValue({
  492. huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
  493. if (index === i) {
  494. const { channelName, channelType } = item
  495. return { channelName, channelType, linkType: '2', rechargeActivityLinkDTO: { status: 'normal', chargeType: 0, userType: 1, charge: 0, commonType: 0, display: ['stack', 'read_footer_text'] } }
  496. }
  497. return item
  498. })
  499. })
  500. }, 0)
  501. } else if (e === '3') {
  502. setTimeout(() => {
  503. form.setFieldsValue({
  504. huaShengCreateLinkDTOList: huaShengCreateLinkDTOList.map((item, i) => {
  505. if (index === i) {
  506. const { channelName } = item
  507. return { channelName, linkType: '3', giftActivityLinkDTO: { status: 'normal', freeAmount: 50, userType: 1, charge: 0, commonType: 0, display: ['stack', 'read_footer_text'] } }
  508. }
  509. return item
  510. })
  511. })
  512. }, 0)
  513. }
  514. }}
  515. />
  516. </Form.Item>
  517. <Form.Item
  518. {...restField}
  519. name={[name, 'channelName']}
  520. label={<strong>渠道名称</strong>}
  521. rules={[{ required: true, message: '请输入渠道名称!' }]}
  522. >
  523. <Input placeholder="请输入渠道名称" allowClear />
  524. </Form.Item>
  525. <Form.Item
  526. {...restField}
  527. name={[name, 'channelType']}
  528. label={<strong>推广类型</strong>}
  529. rules={[{ required: huaShengCreateLinkDTO?.linkType == 1 ? true : false, message: '请选择推广类型!' }]}
  530. >
  531. <Select
  532. showSearch
  533. placeholder="推广类型"
  534. filterOption={(input, option) =>
  535. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  536. }
  537. allowClear
  538. options={[{ label: '外部', value: '1' }, { label: '内部', value: '2' }]}
  539. />
  540. </Form.Item>
  541. {huaShengCreateLinkDTO?.linkType === '1' ? <BookPromoLinkCreateDTOHuaSheng restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} huaShengCreateLinkDTO={huaShengCreateLinkDTO} /> :
  542. huaShengCreateLinkDTO?.linkType === '2' ? <RechargeActivityLinkDTOHuaSheng restField={restField} name={name} itemData={huaShengCreateLinkDTO} /> :
  543. huaShengCreateLinkDTO?.linkType === '3' ? <GiftActivityLinkDTOHuaSheng restField={restField} name={name} itemData={huaShengCreateLinkDTO} /> :
  544. undefined}
  545. </Card>
  546. })}
  547. <Form.Item>
  548. <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
  549. 新增链接信息配置
  550. </Button>
  551. </Form.Item>
  552. </>
  553. )}
  554. </Form.List> : platform === 'WEN_DING' ? <Form.List name="wenDingCreateLinkDTOList">
  555. {(fields, { add, remove }) => (
  556. <>
  557. {fields.map(({ key, name, ...restField }, index) => {
  558. const wenDingCreateLinkDTO = wenDingCreateLinkDTOList?.[index]
  559. return <Card
  560. title={<strong>链接信息配置{index + 1}</strong>}
  561. style={{ background: '#fff', marginBottom: 10 }}
  562. key={key}
  563. extra={wenDingCreateLinkDTOList?.length > 1 ? <div style={{ color: 'red' }} onClick={() => remove(name)}>
  564. <MinusCircleOutlined />
  565. </div> : undefined}
  566. >
  567. <Form.Item
  568. {...restField}
  569. name={[name, 'linkType']}
  570. label={<strong>链接类型</strong>}
  571. rules={[{ required: true, message: '请选择链接类型!' }]}
  572. >
  573. <Select
  574. showSearch
  575. placeholder="链接类型"
  576. filterOption={(input, option) =>
  577. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  578. }
  579. allowClear
  580. options={Object.keys(WENDINGLINKTYPE).map(key => ({ label: WENDINGLINKTYPE[key], value: key }))}
  581. onChange={(e) => {
  582. if (e === '1') {
  583. setTimeout(() => {
  584. form.setFieldsValue({
  585. wenDingCreateLinkDTOList: wenDingCreateLinkDTOList.map((item, i) => {
  586. if (index === i) {
  587. const { channelName, channelType } = item
  588. return { channelName, channelType, linkType: '1', bookPromoLinkCreateDTO: { qrcodeOpenStatus: 0, linkClassify: '3' } }
  589. }
  590. return item
  591. })
  592. })
  593. }, 0)
  594. } else if (e === '2') {
  595. setTimeout(() => {
  596. form.setFieldsValue({
  597. wenDingCreateLinkDTOList: wenDingCreateLinkDTOList.map((item, i) => {
  598. if (index === i) {
  599. const { channelName, channelType } = item
  600. return { channelName, channelType, linkType: '2', rechargeActivityLinkDTO: { userGroup: 0, hideCountDown: 0 } }
  601. }
  602. return item
  603. })
  604. })
  605. }, 0)
  606. }
  607. }}
  608. />
  609. </Form.Item>
  610. <Form.Item
  611. {...restField}
  612. name={[name, 'channelName']}
  613. label={<strong>渠道名称</strong>}
  614. rules={[{ required: true, message: '请输入渠道名称!' }]}
  615. >
  616. <Input placeholder="请输入渠道名称" allowClear />
  617. </Form.Item>
  618. <Form.Item
  619. {...restField}
  620. name={[name, 'channelType']}
  621. label={<strong>推广类型</strong>}
  622. rules={[{ required: true, message: '请选择推广类型!' }]}
  623. >
  624. <Select
  625. showSearch
  626. placeholder="推广类型"
  627. filterOption={(input, option) =>
  628. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  629. }
  630. allowClear
  631. options={[{ label: '内推', value: 0 }, { label: '派单', value: 1 }]}
  632. />
  633. </Form.Item>
  634. {wenDingCreateLinkDTO?.linkType === '1' ? <BookPromoLinkCreateDTOWenDing restField={restField} name={name} platform={platform} mpAccountIds={mpAccountIds} wenDingCreateLinkDTO={wenDingCreateLinkDTO} /> :
  635. wenDingCreateLinkDTO?.linkType === '2' ? <RechargeActivityLinkDTOWenDing restField={restField} name={name} /> :
  636. undefined}
  637. </Card>
  638. })}
  639. <Form.Item>
  640. <Button type="dashed" onClick={() => add({})} block icon={<PlusOutlined />}>
  641. 新增链接信息配置
  642. </Button>
  643. </Form.Item>
  644. </>
  645. )}
  646. </Form.List> : undefined}
  647. </DispatchBookLink.Provider>
  648. </Form>
  649. </Modal>
  650. };
  651. export default React.memo(ModalBookLink);