tableConfig.tsx 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import { Flex, Popconfirm, Popover, Space, Typography } from "antd";
  2. import { AnyObject } from "antd/es/_util/type";
  3. import { ColumnsType } from "antd/es/table";
  4. import style from './index.less'
  5. import { QuestionCircleFilled } from '@ant-design/icons';
  6. import { restoreGroupData, restoreUserInheritData } from "../create/const";
  7. import PreviewUserInherit from "../create/components/userInherit/previewUserlnherit";
  8. import PreviewMassSendingStrategy from "../create/components/massSending/previewMassSendingStrategy";
  9. import ShowContent from "../create/components/massSending/showContent";
  10. import PreviewWelcome from "../create/components/welcome/previewWelcome";
  11. const { Text, Paragraph } = Typography;
  12. const taskListColumns = (
  13. bookPlatForm: any[],
  14. bookList: any[],
  15. handleLog: (data: any) => void,
  16. handleCopy: (data: any, isCopy: boolean, isEditSc?: boolean) => void,
  17. handleDel: (data: any, type: 'del' | 'cancel' | 'open') => void,
  18. ): ColumnsType<AnyObject> => {
  19. return [
  20. {
  21. title: '操作',
  22. dataIndex: 'cz',
  23. key: 'cz',
  24. width: 210,
  25. render(_, record) {
  26. return <Space>
  27. {record?.status === 1 ? <Popconfirm
  28. title="确定暂停?"
  29. onConfirm={() => { handleDel({ projectIds: [record.id] }, 'cancel') }}
  30. >
  31. <a style={{ color: 'orange' }}>暂停任务</a>
  32. </Popconfirm> : record?.status === 3 ? <Popconfirm
  33. title="确定启用?"
  34. onConfirm={() => { handleDel({ projectIds: [record.id] }, 'open') }}
  35. >
  36. <a style={{ color: '#87d068' }}>启用任务</a>
  37. </Popconfirm> : undefined}
  38. <a onClick={() => handleCopy(record, true)}>复制</a>
  39. <a onClick={() => handleCopy(record, false)}>编辑</a>
  40. <a onClick={() => handleCopy(record, false, true)}>编辑素材</a>
  41. <a onClick={() => handleLog(record)}>详情</a>
  42. <Popconfirm
  43. title="确定删除?"
  44. onConfirm={() => { handleDel({ projectIds: [record.id] }, 'del') }}
  45. >
  46. <a style={{ color: 'red' }}>删除</a>
  47. </Popconfirm>
  48. </Space>
  49. },
  50. },
  51. {
  52. title: '任务名称',
  53. dataIndex: 'projectName',
  54. key: 'projectName',
  55. width: 120,
  56. ellipsis: true
  57. },
  58. {
  59. title: '基础信息',
  60. dataIndex: 'bizType',
  61. key: 'bizType',
  62. width: 180,
  63. render: (_, record) => {
  64. return <Paragraph style={{ margin: 0 }} ellipsis={{ tooltip: true }}>
  65. 业务类型:{record?.bizType === 'novel' ? '小说' : '<空>'}-书城:{record?.platformName || '<空>'}-适用产品:{record?.templateProductName || '<空>'}
  66. </Paragraph>
  67. }
  68. },
  69. {
  70. title: '欢迎语配置',
  71. dataIndex: 'welcomeMsgTemplateDTO',
  72. key: 'welcomeMsgTemplateDTO',
  73. width: 150,
  74. ellipsis: true,
  75. render: (_, record) => {
  76. return record?.welcomeMsgTemplateDTO && Object.keys(record?.welcomeMsgTemplateDTO)?.length > 0 ? <div className={style.nameBox}>
  77. <div>
  78. <Text ellipsis>{record?.welcomeMsgTemplateDTO?.welcomeName || '<空>'}</Text>
  79. </div>
  80. <Popover
  81. placement="left"
  82. content={<div>
  83. <PreviewWelcome
  84. welcomeMsgTemplateDTO={record?.welcomeMsgTemplateDTO}
  85. bookList={bookList}
  86. bookPlatForm={bookPlatForm}
  87. />
  88. </div>}
  89. styles={{ body: { width: 300, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  90. >
  91. <a><QuestionCircleFilled /></a>
  92. </Popover>
  93. </div> : <Text type="danger">当前没有欢迎语配置</Text>
  94. }
  95. },
  96. {
  97. title: '群发配置',
  98. dataIndex: 'groupSendTaskAddDTO',
  99. key: 'groupSendTaskAddDTO',
  100. width: 170,
  101. ellipsis: true,
  102. render: (value) => {
  103. if (value && Object.keys(value)?.length > 0) {
  104. const data = restoreGroupData(value)
  105. return <div className={style.nameBox}>
  106. <div>
  107. <Text ellipsis>{value?.groupSendName || '<空>'}</Text>
  108. </div>
  109. <Popover
  110. placement="left"
  111. content={<div>
  112. <PreviewMassSendingStrategy
  113. massSendingStrategy={data.massSendingStrategy}
  114. />
  115. </div>}
  116. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  117. >
  118. <a><QuestionCircleFilled /></a>
  119. </Popover>
  120. <Popover
  121. placement="left"
  122. content={<div>
  123. <ShowContent
  124. strategySettings={data?.massSendingStrategy?.strategySettings}
  125. massSendingContent={data?.massSendingContent}
  126. />
  127. </div>}
  128. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  129. >
  130. <a><QuestionCircleFilled /></a>
  131. </Popover>
  132. </div>
  133. }
  134. return <Text type="danger">当前没有群发配置</Text>
  135. }
  136. },
  137. {
  138. title: '客户继承配置',
  139. dataIndex: 'externalUserTransferTasksDTO',
  140. key: 'externalUserTransferTasksDTO',
  141. width: 150,
  142. ellipsis: true,
  143. render: (value) => {
  144. if (value && Object.keys(value)?.length > 0) {
  145. const data = restoreUserInheritData(value)
  146. return <div className={style.nameBox}>
  147. <div>
  148. <Text ellipsis>{value?.taskName || '<空>'}</Text>
  149. </div>
  150. <Popover
  151. placement="left"
  152. content={<div>
  153. <PreviewUserInherit
  154. userInherit={data}
  155. />
  156. </div>}
  157. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  158. >
  159. <a><QuestionCircleFilled /></a>
  160. </Popover>
  161. </div>
  162. }
  163. return <Text type="danger">当前没有客户继承配置</Text>
  164. }
  165. },
  166. {
  167. title: '创建时间',
  168. dataIndex: 'createTime',
  169. key: 'createTime',
  170. align: 'center',
  171. width: 125,
  172. ellipsis: true
  173. },
  174. {
  175. title: '任务数量',
  176. dataIndex: 'taskCount',
  177. key: 'taskCount',
  178. width: 260,
  179. render(value, record) {
  180. return <Flex gap={6}>
  181. <Text type={record.welcomeMsgCount > 0 ? 'success' : 'danger'}>欢迎语:{record.welcomeMsgCount}</Text>
  182. <Text type={record.groupSendTaskCount > 0 ? 'success' : 'danger'}>群发:{record.groupSendTaskCount}</Text>
  183. <Text type={record.externalUserTransferTaskCount > 0 ? 'success' : 'danger'}>客户继承:{record.externalUserTransferTaskCount}</Text>
  184. </Flex>
  185. },
  186. },
  187. ]
  188. }
  189. export default taskListColumns