tableConfig.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React from "react"
  2. import { Image, Popconfirm, Space } from 'antd'
  3. let columns = (del: (id: number) => void, edit: (data: any) => void) => {
  4. let data: any[] = [
  5. {
  6. title: '操作',
  7. dataIndex: 'cz',
  8. key: 'cz',
  9. align: 'center',
  10. width: 100,
  11. render: (a: any, b: any) => {
  12. return <Space>
  13. <a onClick={() => edit(b)}>修改</a>
  14. <Popconfirm
  15. title="确定删除?"
  16. onConfirm={() => del(b.id)}
  17. okText="是"
  18. cancelText="否"
  19. >
  20. <a style={{ color: 'red' }}>删除</a>
  21. </Popconfirm>
  22. </Space>
  23. }
  24. },
  25. {
  26. title: 'ID',
  27. dataIndex: 'id',
  28. key: 'id',
  29. width: 60,
  30. align: 'center',
  31. render: (a: any, b: any) => {
  32. return <span style={{ fontSize: "12px" }}>{a}</span>
  33. }
  34. },
  35. {
  36. title: '头像预览图',
  37. dataIndex: 'brandImgUrl',
  38. key: 'brandImgUrl',
  39. width: 120,
  40. ellipsis: true,
  41. align: 'center',
  42. render: (a: any, b: any) => {
  43. return <Image width={40} style={{ borderRadius: 4 }} src={a} />
  44. }
  45. },
  46. {
  47. title: '头像名称',
  48. dataIndex: 'name',
  49. key: 'name',
  50. align: 'center',
  51. render: (a: any, b: any) => {
  52. return <span style={{ fontSize: "12px" }}>{a}</span>
  53. }
  54. },
  55. {
  56. title: '创建时间',
  57. dataIndex: 'createTime',
  58. key: 'createTime',
  59. align: 'center',
  60. render: (a: any, b: any) => {
  61. return <span style={{ fontSize: "12px" }}>{a}</span>
  62. }
  63. }
  64. ]
  65. return data
  66. }
  67. export default columns