tableConfig.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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) => 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: 160,
  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={() => handleLog(record)}>详情</a>
  41. <Popconfirm
  42. title="确定删除?"
  43. onConfirm={() => { handleDel({ projectIds: [record.id] }, 'del') }}
  44. >
  45. <a style={{ color: 'red' }}>删除</a>
  46. </Popconfirm>
  47. </Space>
  48. },
  49. },
  50. {
  51. title: '任务名称',
  52. dataIndex: 'projectName',
  53. key: 'projectName',
  54. width: 120,
  55. ellipsis: true
  56. },
  57. {
  58. title: '基础信息',
  59. dataIndex: 'bizType',
  60. key: 'bizType',
  61. width: 180,
  62. render: (_, record) => {
  63. return <Paragraph style={{ margin: 0 }} ellipsis={{ tooltip: true }}>
  64. 业务类型:{record?.bizType === 'novel' ? '小说' : '<空>'}-书城:{record?.platformName || '<空>'}-适用产品:{record?.templateProductName || '<空>'}
  65. </Paragraph>
  66. }
  67. },
  68. {
  69. title: '欢迎语配置',
  70. dataIndex: 'welcomeMsgTemplateDTO',
  71. key: 'welcomeMsgTemplateDTO',
  72. width: 150,
  73. ellipsis: true,
  74. render: (_, record) => {
  75. return record?.welcomeMsgTemplateDTO && Object.keys(record?.welcomeMsgTemplateDTO)?.length > 0 ? <div className={style.nameBox}>
  76. <div>
  77. <Text ellipsis>{record?.welcomeMsgTemplateDTO?.welcomeName || '<空>'}</Text>
  78. </div>
  79. <Popover
  80. placement="left"
  81. content={<div>
  82. <PreviewWelcome
  83. welcomeMsgTemplateDTO={record?.welcomeMsgTemplateDTO}
  84. bookList={bookList}
  85. bookPlatForm={bookPlatForm}
  86. />
  87. </div>}
  88. styles={{ body: { width: 300, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  89. >
  90. <a><QuestionCircleFilled /></a>
  91. </Popover>
  92. </div> : <Text type="danger">当前没有欢迎语配置</Text>
  93. }
  94. },
  95. {
  96. title: '群发配置',
  97. dataIndex: 'groupSendTaskAddDTO',
  98. key: 'groupSendTaskAddDTO',
  99. width: 170,
  100. ellipsis: true,
  101. render: (value) => {
  102. if (value && Object.keys(value)?.length > 0) {
  103. const data = restoreGroupData(value)
  104. return <div className={style.nameBox}>
  105. <div>
  106. <Text ellipsis>{value?.groupSendName || '<空>'}</Text>
  107. </div>
  108. <Popover
  109. placement="left"
  110. content={<div>
  111. <PreviewMassSendingStrategy
  112. massSendingStrategy={data.massSendingStrategy}
  113. />
  114. </div>}
  115. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  116. >
  117. <a><QuestionCircleFilled /></a>
  118. </Popover>
  119. <Popover
  120. placement="left"
  121. content={<div>
  122. <ShowContent
  123. strategySettings={data?.massSendingStrategy?.strategySettings}
  124. massSendingContent={data?.massSendingContent}
  125. />
  126. </div>}
  127. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  128. >
  129. <a><QuestionCircleFilled /></a>
  130. </Popover>
  131. </div>
  132. }
  133. return <Text type="danger">当前没有群发配置</Text>
  134. }
  135. },
  136. {
  137. title: '客户继承配置',
  138. dataIndex: 'externalUserTransferTasksDTO',
  139. key: 'externalUserTransferTasksDTO',
  140. width: 150,
  141. ellipsis: true,
  142. render: (value) => {
  143. if (value && Object.keys(value)?.length > 0) {
  144. const data = restoreUserInheritData(value)
  145. return <div className={style.nameBox}>
  146. <div>
  147. <Text ellipsis>{value?.taskName || '<空>'}</Text>
  148. </div>
  149. <Popover
  150. placement="left"
  151. content={<div>
  152. <PreviewUserInherit
  153. userInherit={data}
  154. />
  155. </div>}
  156. styles={{ body: { width: 360, overflow: 'hidden', overflowY: 'auto', maxHeight: 400 } }}
  157. >
  158. <a><QuestionCircleFilled /></a>
  159. </Popover>
  160. </div>
  161. }
  162. return <Text type="danger">当前没有客户继承配置</Text>
  163. }
  164. },
  165. {
  166. title: '创建时间',
  167. dataIndex: 'createTime',
  168. key: 'createTime',
  169. align: 'center',
  170. width: 125,
  171. ellipsis: true
  172. },
  173. {
  174. title: '任务数量',
  175. dataIndex: 'taskCount',
  176. key: 'taskCount',
  177. width: 260,
  178. render(value, record) {
  179. return <Flex gap={6}>
  180. <Text type={record.welcomeMsgCount > 0 ? 'success' : 'danger'}>欢迎语:{record.welcomeMsgCount}</Text>
  181. <Text type={record.groupSendTaskCount > 0 ? 'success' : 'danger'}>群发:{record.groupSendTaskCount}</Text>
  182. <Text type={record.externalUserTransferTaskCount > 0 ? 'success' : 'danger'}>客户继承:{record.externalUserTransferTaskCount}</Text>
  183. </Flex>
  184. },
  185. },
  186. ]
  187. }
  188. export default taskListColumns