tableConfig.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Popconfirm, Space, TableProps } from "antd";
  2. import React from "react";
  3. import PreviewImg from "./PreviewImg";
  4. export const Columns = (del: (id: number) => void): TableProps<any>['columns'] => {
  5. const columns: TableProps<any>['columns'] = [
  6. {
  7. title: '创建人',
  8. dataIndex: 'putUserName',
  9. key: 'putUserName',
  10. width: 60,
  11. align: 'center'
  12. },
  13. {
  14. title: '描述',
  15. dataIndex: 'strategyKey',
  16. key: 'strategyKey',
  17. width: 140,
  18. ellipsis: true,
  19. },
  20. {
  21. title: '创建时间',
  22. dataIndex: 'createTime',
  23. key: 'createTime',
  24. ellipsis: true,
  25. width: 135
  26. },
  27. {
  28. title: '操作',
  29. dataIndex: 'cz',
  30. key: 'cz',
  31. fixed: 'right',
  32. width: 120,
  33. align: 'center',
  34. render: (_, b) => {
  35. return <Space>
  36. <PreviewImg strategyValue={JSON.parse(b.strategyValue)} />
  37. <Popconfirm
  38. title="是否删除?"
  39. onConfirm={() => del(b?.id)}
  40. >
  41. <a style={{ color: 'red' }}>删除</a>
  42. </Popconfirm>
  43. </Space>
  44. }
  45. }
  46. ];
  47. return columns
  48. }