bookPromoLinkCreateDTO.tsx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { App, Form, InputNumber, Select } from "antd";
  2. import React from "react";
  3. import SelectBook from "../../selectBook";
  4. import { useAjax } from "@/Hook/useAjax";
  5. import { getFreeChapterListApi } from "@/pages/weComTask/API/bookLink";
  6. interface Props extends BOOKLINK.BookLinkChildProps {
  7. huaShengCreateLinkDTO: { [x: string]: any }
  8. platform: string,
  9. mpAccountIds: number[]
  10. }
  11. /**
  12. * 花生作品链接
  13. * @returns
  14. */
  15. const BookPromoLinkCreateDTO: React.FC<Props> = ({ restField, name, huaShengCreateLinkDTO, platform, mpAccountIds }) => {
  16. /**********************************/
  17. const { message } = App.useApp()
  18. const getFreeChapterList = useAjax((params) => getFreeChapterListApi(params))
  19. /**********************************/
  20. const getChapterList = () => {
  21. if (platform && mpAccountIds?.length && huaShengCreateLinkDTO?.bookPromoLinkCreateDTO?.bookId) {
  22. getFreeChapterList.run({ platform, mpAccountIds, bookId: huaShengCreateLinkDTO.bookPromoLinkCreateDTO.bookId })
  23. } else {
  24. message.error('请先选择书城、公众号')
  25. }
  26. }
  27. return <>
  28. <Form.Item
  29. {...restField}
  30. name={[name, 'bookPromoLinkCreateDTO', 'bookId']}
  31. rules={[{ required: true, message: '请输入作品(书籍)ID!' }]}
  32. label={<strong>作品(书籍)ID</strong>}
  33. >
  34. <SelectBook
  35. platformKey={platform}
  36. searchChapterDisabled={!huaShengCreateLinkDTO?.bookPromoLinkCreateDTO?.bookId}
  37. searchChapterLoading={getFreeChapterList.loading}
  38. hanldeSearchChapter={getChapterList}
  39. />
  40. </Form.Item>
  41. <Form.Item
  42. {...restField}
  43. name={[name, 'bookPromoLinkCreateDTO', 'chapterId']}
  44. label={<strong>章节</strong>}
  45. rules={[{ required: true, message: '请选择章节!' }]}
  46. >
  47. <Select
  48. showSearch
  49. placeholder="请选择章节"
  50. filterOption={(input, option) =>
  51. ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
  52. }
  53. allowClear
  54. options={getFreeChapterList?.data?.data?.chapterList?.map(item => ({ value: item.chapterId, label: item.chapterName }))}
  55. />
  56. </Form.Item>
  57. <Form.Item
  58. {...restField}
  59. name={[name, 'bookPromoLinkCreateDTO', 'forceChapter']}
  60. label={<strong>强关章节序号</strong>}
  61. rules={[{ required: true, message: '请输入强关章节序号!' }]}
  62. >
  63. <InputNumber placeholder="请输入强关章节序号" style={{ width: '100%' }} />
  64. </Form.Item>
  65. <Form.Item
  66. {...restField}
  67. name={[name, 'bookPromoLinkCreateDTO', 'cost']}
  68. label={<strong>推广成本</strong>}
  69. rules={[{ required: true, message: '请输入推广成本!' }]}
  70. >
  71. <InputNumber placeholder="请输入推广成本" min={0} style={{ width: '100%' }} />
  72. </Form.Item>
  73. </>
  74. }
  75. export default React.memo(BookPromoLinkCreateDTO);