tableConfig.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { PageStatusEnum } from "@/services/launchAdq/enum"
  2. import { Badge, TableProps, Tag } from "antd"
  3. import React from "react"
  4. import QrCode from "../QrCode"
  5. let columns = (type?: 1 | 2): TableProps<any>['columns'] => {
  6. if (type === 2) { // 灵鹊落地页
  7. return [
  8. {
  9. title: '是否可用?',
  10. dataIndex: 'disableCode',
  11. key: 'disableCode',
  12. width: 80,
  13. fixed: 'left',
  14. align: 'center',
  15. render(value) {
  16. return <Tag style={{ fontSize: 12 }} color={value === 0 ? 'success' : 'error'}>{value === 0 ? '可用' : '不可用'}</Tag>
  17. },
  18. },
  19. {
  20. title: '落地页ID',
  21. dataIndex: 'pageId',
  22. key: 'pageId',
  23. align: 'center',
  24. width: 85
  25. },
  26. {
  27. title: '落地页名称',
  28. dataIndex: 'pageName',
  29. key: 'pageName',
  30. ellipsis: true,
  31. width: 300
  32. },
  33. {
  34. title: '落地页状态',
  35. dataIndex: 'pageStatus',
  36. key: 'pageStatus',
  37. align: 'center',
  38. width: 90,
  39. render: (a: string | number) => {
  40. return <Badge status={a === 'NORMAL' ? "success" : a === 'DELETED' ? "error" : 'processing'} text={PageStatusEnum[a as keyof typeof PageStatusEnum]} />
  41. }
  42. },
  43. {
  44. title: '不可用原因',
  45. dataIndex: 'disableMessage',
  46. key: 'disableMessage',
  47. ellipsis: true,
  48. width: 200
  49. },
  50. ]
  51. }
  52. return [
  53. {
  54. title: '落地页ID',
  55. dataIndex: 'pageId',
  56. key: 'pageId',
  57. align: 'center',
  58. width: 90
  59. },
  60. {
  61. title: '落地页名称',
  62. dataIndex: 'pageName',
  63. key: 'pageName',
  64. ellipsis: true
  65. },
  66. {
  67. title: '预览',
  68. dataIndex: 'previewUrl',
  69. key: 'previewUrl',
  70. width: 60,
  71. align: 'center',
  72. render(value) {
  73. return <QrCode url={value}/>
  74. }
  75. },
  76. {
  77. title: '落地页状态',
  78. dataIndex: 'pageStatus',
  79. key: 'pageStatus',
  80. align: 'center',
  81. width: 90,
  82. render: (a: string | number) => {
  83. return <Badge status={a === 'NORMAL' ? "success" : a === 'DELETED' ? "error" : 'processing'} text={PageStatusEnum[a as keyof typeof PageStatusEnum]} />
  84. }
  85. }
  86. ]
  87. }
  88. export default columns