tableConfig.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import { ColumnsType } from "antd/es/table";
  2. import React from "react";
  3. import { COMPONENT_GENERATION_TYPE_ENUM, COMPONENT_SUB_TYPE, getComponentType } from "./const";
  4. import { Popconfirm, Tag } from "antd";
  5. import moment from "moment";
  6. import Image1X1 from "../../components/AdsComponent/Image1X1";
  7. import ImageXXX from "../../components/AdsComponent/ImageXXX";
  8. const TableConfig = (activeKey: 'IMAGE' | 'VIDEO', del: (id: number[]) => void): ColumnsType<any> => {
  9. const columns: ColumnsType<any> = [
  10. {
  11. title: activeKey === 'IMAGE' ? '图片' : '视频' + '组件',
  12. dataIndex: 'componentSubType',
  13. key: 'componentSubType',
  14. width: 380,
  15. fixed: 'left',
  16. render(value, records) {
  17. const type = getComponentType(value)
  18. if (type === 'IMAGE') {
  19. return <Image1X1 imageUrl={records?.componentValue?.image?.value?.imageUrl} />
  20. } else if (type === 'IMAGE_LIST') {
  21. return <ImageXXX imageList={records?.componentValue?.imageList?.value?.list || []} />
  22. } else if (type === 'VIDEO') {
  23. return <Image1X1
  24. imageUrl={records?.componentValue?.video?.value?.coverUrl || records?.componentValue?.shortVideo?.value?.shortVideo2Url}
  25. videoUrl={records?.componentValue?.video?.value?.videoUrl || records?.componentValue?.shortVideo?.value?.shortVideo1Url}
  26. />
  27. }
  28. return <div className='image-9x16'>联系技术添加</div>
  29. },
  30. },
  31. {
  32. title: '二级组件类型',
  33. dataIndex: 'componentSubType',
  34. key: 'componentSubType',
  35. width: 100,
  36. ellipsis: true,
  37. align: 'center',
  38. render(value) {
  39. return <span style={{ fontSize: 12 }}>{COMPONENT_SUB_TYPE.find(item => item.value === value)?.label || '--'}</span>
  40. },
  41. },
  42. {
  43. title: '组件名称',
  44. dataIndex: 'componentCustomName',
  45. key: 'componentCustomName',
  46. width: 180,
  47. ellipsis: true,
  48. render(value) {
  49. return <span style={{ fontSize: 12 }}>{value}</span>
  50. },
  51. },
  52. {
  53. title: '组件ID',
  54. dataIndex: 'componentId',
  55. key: 'componentId',
  56. width: 90,
  57. ellipsis: true,
  58. align: 'center',
  59. render(value) {
  60. return <span style={{ fontSize: 12 }}>{value}</span>
  61. },
  62. },
  63. {
  64. title: '来源',
  65. dataIndex: 'generationType',
  66. key: 'generationType',
  67. width: 90,
  68. ellipsis: true,
  69. align: 'center',
  70. render(value) {
  71. return <span style={{ fontSize: 12 }}>{COMPONENT_GENERATION_TYPE_ENUM['COMPONENT_GENERATION_TYPE_' + value as keyof typeof COMPONENT_GENERATION_TYPE_ENUM] || '--'}</span>
  72. },
  73. },
  74. {
  75. title: '广告账号',
  76. dataIndex: 'accountId',
  77. key: 'accountId',
  78. width: 90,
  79. ellipsis: true,
  80. align: 'center',
  81. render(value) {
  82. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  83. },
  84. },
  85. {
  86. title: '业务单元ID',
  87. dataIndex: 'organizationId',
  88. key: 'organizationId',
  89. width: 90,
  90. ellipsis: true,
  91. align: 'center',
  92. render(value) {
  93. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  94. },
  95. },
  96. {
  97. title: '创建时间',
  98. dataIndex: 'createdTime',
  99. key: 'createdTime',
  100. width: 95,
  101. ellipsis: true,
  102. align: 'center',
  103. render(value) {
  104. return <span style={{ fontSize: 12 }}>{value ? moment.unix(value).format('YYYY-MM-DD') : '--'}</span>
  105. },
  106. },
  107. {
  108. title: '最后修改时间',
  109. dataIndex: 'lastModifiedTime',
  110. key: 'lastModifiedTime',
  111. width: 95,
  112. ellipsis: true,
  113. align: 'center',
  114. render(value) {
  115. return <span style={{ fontSize: 12 }}>{value ? moment.unix(value).format('YYYY-MM-DD') : '--'}</span>
  116. },
  117. },
  118. {
  119. title: '是否删除',
  120. dataIndex: 'isDeleted',
  121. key: 'isDeleted',
  122. width: 70,
  123. ellipsis: true,
  124. align: 'center',
  125. render(value) {
  126. return value ? <Tag color="error" style={{ margin: 0 }}>是</Tag> : <Tag color="success" style={{ margin: 0 }}>否</Tag>
  127. },
  128. },
  129. {
  130. title: '组件状态',
  131. dataIndex: 'status',
  132. key: 'status',
  133. width: 90,
  134. ellipsis: true,
  135. render(value) {
  136. return <span style={{ fontSize: 12 }}>{value || '--'}</span>
  137. },
  138. },
  139. {
  140. title: '操作',
  141. dataIndex: 'cz',
  142. key: 'cz',
  143. width: 130,
  144. render(_, record) {
  145. if (!record?.isDeleted) {
  146. return <Popconfirm
  147. title="确定删除?"
  148. onConfirm={() => { del([record?.componentId]) }}
  149. >
  150. <a style={{ color: 'red', fontSize: 12 }}>删除</a>
  151. </Popconfirm>
  152. }
  153. return '--'
  154. },
  155. },
  156. ]
  157. return columns
  158. }
  159. export default TableConfig