123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { history, Link } from 'umi';
  2. import { useRef } from 'react';
  3. import { Button, Modal, message, Popconfirm, Tooltip } from 'antd';
  4. import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
  5. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  6. import ProTable, { TableDropdown } from '@ant-design/pro-table';
  7. export default (props) => {
  8. const dataSource = [
  9. {
  10. id: 9,
  11. key: '1',
  12. name: '胡彦斌',
  13. age: 32,
  14. zz: '西湖区湖底公园1号',
  15. },
  16. ];
  17. // 测试内容👆-------------------------
  18. const actionRef = useRef();
  19. const gotoDetail = (id) => {
  20. history.push(`./GPS/GPSEdit`)
  21. }
  22. const handleDelete = (e) => {
  23. deleteNote(e.noteId).then(res => {
  24. message.success('删除成功');
  25. actionRef.current.reload();
  26. })
  27. }
  28. const handleOK = (record, data) => {
  29. const titleCourse = record.status ? '您确定要禁用该用户吗? 禁用后该用户不能在后台登陆!' : '您确定要启用该用户吗? 启用后该用户将允许在后台登陆!';
  30. Modal.confirm({
  31. title: titleCourse,
  32. okText: '确认',
  33. cancelText: '取消',
  34. onOk () {
  35. publishNote(record.noteId, record.status ? 'off' : 'on').then(res => {
  36. message.success('操作成功');
  37. actionRef.current.reload()
  38. })
  39. },
  40. });
  41. }
  42. const actions = () => [
  43. <Button key='add' type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>新增</Button>,
  44. ]
  45. const columns = [
  46. {
  47. title: 'ID',
  48. key: 'zz',
  49. dataIndex: 'zz',
  50. },
  51. {
  52. title: '设备号',
  53. dataIndex: 'name',
  54. key: 'name',
  55. },
  56. {
  57. title: '状态',
  58. dataIndex: 'status',
  59. key: 'status',
  60. render: (t, record) => record.noteType === 1 ? '已启用' : '已禁用',
  61. valueEnum: {
  62. online: { text: '已启用', status: 'Success' },
  63. error: { text: '已禁用', status: 'Error' },
  64. }
  65. },
  66. {
  67. title: '操作',
  68. valueType: 'option',
  69. key: 'option',
  70. ellipsis: true,
  71. width: 200,
  72. render: (_, record) => [
  73. <Link key={2} to={`./GPS/GPSEdit`}>编辑</Link>,
  74. <Popconfirm
  75. key={3}
  76. title="您是否确认删除 ?"
  77. onConfirm={() => handleDelete(record)}
  78. okText="确定"
  79. cancelText="取消"
  80. >
  81. <a href="#" >删除</a>
  82. </Popconfirm>,
  83. ]
  84. },
  85. ]
  86. return (
  87. <PageHeaderWrapper>
  88. <ProTable
  89. dataSource={dataSource}
  90. columns={columns}
  91. // request={getNoteList} 请求
  92. // rowKey="noteId"
  93. options={false}
  94. toolBarRender={actions}
  95. actionRef={actionRef}
  96. />
  97. </PageHeaderWrapper>
  98. )
  99. }