tableConfig.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react"
  2. import { Row, Col, Popconfirm } from "antd"
  3. import { DeleteOutlined, FormOutlined } from "@ant-design/icons"
  4. let columns = (edit: (value: { id: number, name: string, }) => void, del: (id: number) => void) => [
  5. {
  6. title: 'ID',
  7. dataIndex: 'id',
  8. key: 'id',
  9. align: 'center'
  10. },
  11. {
  12. title: '名称',
  13. dataIndex: 'name',
  14. key: 'name',
  15. align: 'center'
  16. },
  17. {
  18. title: '操作',
  19. dataIndex: 'cz',
  20. key: 'cz',
  21. align: 'center',
  22. width: 200,
  23. render: (a: string, b: { id: number, name: string }) => (
  24. <Row justify='center' gutter={[10, 0]}>
  25. <Col><a onClick={() => edit(b)} style={{fontSize: "12px"}}><FormOutlined /> 编辑</a></Col>
  26. <Col>
  27. <Popconfirm
  28. title={`是否要删除?`}
  29. onConfirm={() => del(b.id)}
  30. okText="是"
  31. cancelText="否"
  32. >
  33. <a style={{color: "red", fontSize: "12px"}}><DeleteOutlined /> 删除</a>
  34. </Popconfirm>
  35. </Col>
  36. </Row>
  37. )
  38. }
  39. ]
  40. export default columns