settingsContent.tsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { Button, Input, Modal, Typography } from 'antd';
  2. import React, { useEffect, useState } from 'react';
  3. import style from '../../../../../components/selectExternalAccount/index.less'
  4. import { CheckOutlined } from '@ant-design/icons';
  5. import SelectBookLinkButton from '@/pages/weComTask/page/bookLink/SelectBookLinkButton';
  6. const { Paragraph, Title } = Typography;
  7. interface Props {
  8. corpUserGroups: TASK_CREATE.CorpUserGroupProps[]
  9. content: Array<{ msgType: "TASK_CONTENT_LINK", link: { title: string, picUrl: string, desc: string } } | { msgType: "TASK_STATUS_MINIPROGRAM", miniprogram: { title: string, picUrl: string } }>
  10. bookPlatForm: TASK_CREATE.BookPlatFormProps[]
  11. value?: any[];
  12. onChange?: (value?: any) => void;
  13. }
  14. const SettingsContent: React.FC<Props> = ({ value, onChange, content, bookPlatForm, corpUserGroups }) => {
  15. /*******************************************/
  16. const [visible, setVisible] = useState<boolean>(false)
  17. const [data, setData] = useState<any>([])
  18. /*******************************************/
  19. useEffect(() => {
  20. if (visible) {
  21. setData(value || corpUserGroups.map(() => {
  22. return {
  23. content
  24. }
  25. }))
  26. }
  27. }, [visible, corpUserGroups, value])
  28. return <>
  29. <Button onClick={() => setVisible(true)}>设置链接、小程序</Button>
  30. {visible && <SettingsContentModal
  31. corpUserGroups={corpUserGroups}
  32. visible={visible}
  33. value={data}
  34. bookPlatForm={bookPlatForm}
  35. onChange={(value) => {
  36. setData(value)
  37. onChange(value)
  38. }}
  39. onClose={() => {
  40. setVisible(false)
  41. }}
  42. />}
  43. </>
  44. };
  45. const SettingsContentModal: React.FC<{
  46. value: any[],
  47. onChange: (value: any) => void
  48. onClose: () => void
  49. corpUserGroups: TASK_CREATE.CorpUserGroupProps[]
  50. bookPlatForm: TASK_CREATE.BookPlatFormProps[]
  51. visible?: boolean
  52. }> = ({ visible, onClose, onChange, value, corpUserGroups, bookPlatForm }) => {
  53. /***************************************/
  54. const [data, setData] = useState<any>([])
  55. const [selectAdz, setSelectAdz] = useState<number>(1)
  56. /***************************************/
  57. useEffect(() => {
  58. if (visible) {
  59. setData(value)
  60. }
  61. }, [visible, value])
  62. const handleSelectAdz = (value: number) => {
  63. if (value === selectAdz) {
  64. return
  65. }
  66. setSelectAdz(value)
  67. }
  68. return <Modal
  69. title={<strong>群发内容链接、小程序配置</strong>}
  70. open={visible}
  71. onCancel={onClose}
  72. width={800}
  73. className={`${style.SelectPackage}`}
  74. styles={{
  75. body: {
  76. padding: '0 10px 0 10px'
  77. }
  78. }}
  79. >
  80. <div className={style.content}>
  81. <div className={style.left}>
  82. <h4 className={style.title}>客服组</h4>
  83. <div className={style.accountIdList}>
  84. {data?.map((item, index) => {
  85. // const bookLink = item?.bookLink
  86. return <div style={{ height: 'auto', lineHeight: 'normal', }} key={index} onClick={() => { handleSelectAdz(index + 1) }} className={`${style.accItem} ${selectAdz === index + 1 && style.select} `}>
  87. <div style={{ flexDirection: 'column', alignItems: 'flex-start', padding: '2px 0', flex: 1, overflow: 'hidden' }}>
  88. <Title ellipsis={{ tooltip: true }} level={5} style={{ margin: 0 }}>客服组{index + 1}</Title>
  89. <Paragraph ellipsis={{ tooltip: true }} style={{ margin: 0, width: '100%' }}>{corpUserGroups[index]?.corpUsers?.map(i => i.name).join('、')}</Paragraph>
  90. </div>
  91. {/* {bookLink?.length > 0 && <CheckOutlined style={{ color: '#1890ff' }} />} */}
  92. <CheckOutlined style={{ color: '#1890ff' }} />
  93. </div>
  94. })}
  95. </div>
  96. </div>
  97. <div className={style.right}>
  98. {data?.[selectAdz - 1]?.content?.map((item, index) => {
  99. return <div key={index}>
  100. {item.msgType === 'TASK_CONTENT_LINK' ? <div style={{ marginBottom: 10 }}>
  101. <Title level={5} style={{ margin: 0 }}>链接:{item?.link?.title || ''}</Title>
  102. <div style={{ display: 'flex', gap: 4, alignItems: 'flex-end' }}>
  103. <Input.TextArea placeholder="请输入链接" />
  104. {/* <SelectBookLinkButton
  105. bookPlatForm={bookPlatForm}
  106. mpAccountId={corpUserGroups[index]?.corpUsers?.[0]?.mpAccountId}
  107. linkData={[item]}
  108. onChange={(linkStr, miniprogramAppid, miniprogramPage) => {
  109. }}
  110. /> */}
  111. </div>
  112. </div> : <>
  113. <Title level={5} style={{ margin: 0 }}>所有小程序</Title>
  114. <Input.TextArea placeholder="请输入链接" />
  115. </>}
  116. </div>
  117. })}
  118. </div>
  119. </div>
  120. </Modal>
  121. }
  122. export default SettingsContent;