tableConfig.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import { ColumnsType } from "antd/es/table"
  2. import { Flex, Popconfirm, Image } from "antd"
  3. import { copy } from "@/utils/utils"
  4. export function TableConfig(
  5. handleEdit?: (d: Record<string, any>, isCopy?: boolean) => void,
  6. handleDel?: (data: number[]) => void,
  7. handleCode?: (id: number) => void
  8. ): ColumnsType<any> {
  9. const arr: ColumnsType<any> = [
  10. {
  11. title: 'ID',
  12. dataIndex: 'id',
  13. key: 'id',
  14. width: 70,
  15. align: 'center'
  16. },
  17. {
  18. title: '落地页名称',
  19. dataIndex: 'name',
  20. key: 'name',
  21. width: 150,
  22. ellipsis: true
  23. },
  24. {
  25. title: 'Sign',
  26. dataIndex: 'sign',
  27. key: 'sign',
  28. width: 150,
  29. ellipsis: true
  30. },
  31. {
  32. title: '落地页标题',
  33. dataIndex: 'pageName',
  34. key: 'pageName',
  35. width: 150,
  36. ellipsis: true,
  37. render(_, record) {
  38. return JSON.parse(record?.content || '{}')?.pageName || ''
  39. },
  40. },
  41. {
  42. title: '企微主体',
  43. dataIndex: 'corpName',
  44. key: 'corpName',
  45. width: 120,
  46. align: 'center',
  47. ellipsis: true,
  48. render: (v: string) => v || '--'
  49. },
  50. {
  51. title: '企微客服号',
  52. dataIndex: 'corpUserList',
  53. key: 'corpUserList',
  54. width: 160,
  55. align: 'center',
  56. ellipsis: true,
  57. render: (v: any[]) => v?.map(item => item.corpUserName)?.join('、') || '--'
  58. },
  59. {
  60. title: '书名',
  61. dataIndex: 'bookName',
  62. key: 'bookName',
  63. width: 150,
  64. align: 'center',
  65. ellipsis: true,
  66. render: (v: string) => v || '--'
  67. },
  68. {
  69. title: '备注',
  70. dataIndex: 'remark',
  71. key: 'remark',
  72. width: 150,
  73. ellipsis: true,
  74. render: (v: string) => v || '--'
  75. },
  76. {
  77. title: '小程序AppId',
  78. dataIndex: 'appid',
  79. key: 'appid',
  80. width: 150,
  81. align: 'center',
  82. render: () => `wxed3542b04192b2ee`
  83. },
  84. {
  85. title: '小程序路径',
  86. dataIndex: 'path',
  87. key: 'path',
  88. width: 350,
  89. ellipsis: true,
  90. render: (_, records) => <a onClick={() => copy(`pages/Ldpage/index?pageId=${records.sign}`)}>pages/Ldpage/index?pageId={records.sign}</a>
  91. },
  92. {
  93. title: '项目组',
  94. dataIndex: 'projectGroupIdList',
  95. key: 'projectGroupIdList',
  96. width: 120,
  97. align: 'center',
  98. ellipsis: true,
  99. render: (v: { projectGroupName: string }[]) => v?.map(item => item?.projectGroupName)?.join('、') || '--'
  100. },
  101. {
  102. title: '客服号二维码',
  103. dataIndex: 'qrCodeList',
  104. key: 'qrCodeList',
  105. width: 250,
  106. render: (v: { urlList: string[] }[]) => v?.map(item => item?.urlList?.map((item, i) => <Image
  107. key={i}
  108. height={20}
  109. alt="basic"
  110. src={item}
  111. />)) || '--'
  112. },
  113. {
  114. title: '悬浮客服号二维码',
  115. dataIndex: 'qrCodeFloatList',
  116. key: 'qrCodeFloatList',
  117. width: 250,
  118. render: (v: { urlList: string[] }[]) => v?.map(item => item?.urlList?.map((item, i) => <Image
  119. key={i}
  120. height={20}
  121. alt="basic"
  122. src={item}
  123. />)) || '--'
  124. },
  125. {
  126. title: '创建人',
  127. dataIndex: 'createBy',
  128. key: 'createBy',
  129. align: 'center',
  130. width: 70
  131. },
  132. {
  133. title: '创建时间',
  134. dataIndex: 'createTime',
  135. key: 'createTime',
  136. align: 'center',
  137. width: 140,
  138. render: (value) => {
  139. return <span style={{ fontSize: 12 }}>{value}</span>
  140. }
  141. },
  142. {
  143. title: '操作',
  144. dataIndex: 'cz',
  145. key: 'cz',
  146. width: 250,
  147. fixed: 'right',
  148. render: (_, records) => {
  149. return <Flex gap={4}>
  150. <a onClick={() => handleEdit?.(records, true)}>复制</a>
  151. <a onClick={() => handleEdit?.(records)}>修改</a>
  152. <a onClick={() => handleCode?.(records.id)}>小程序预览链接</a>
  153. <Popconfirm
  154. title="确定删除?"
  155. onConfirm={() => { handleDel?.([records.id]) }}
  156. >
  157. <a style={{ color: 'red' }}>删除</a>
  158. </Popconfirm>
  159. </Flex>
  160. }
  161. },
  162. ]
  163. return arr
  164. }