index.jsx 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { getRegulationList, deleteRegulation } from '@/services/regulation';
  2. import { ProFormTextArea, ProForm, PageContainer, ProTable } from '@ant-design/pro-components';
  3. import { Button, message, Popconfirm } from 'antd';
  4. import { useNavigate } from 'react-router-dom';
  5. import { queryTable } from '@/utils/request';
  6. import { useRef, useState, useEffect } from 'react';
  7. const IntroductionList = (props) => {
  8. const actionRef = useRef();
  9. const navigate = useNavigate();
  10. const handleDelete = (id) => {
  11. if (id) {
  12. deleteRegulation(id).then((res) => {
  13. // message.success('删除成功');
  14. actionRef.current.reload();
  15. });
  16. }
  17. };
  18. const columns = [
  19. {
  20. title: 'id',
  21. dataIndex: 'id',
  22. width: 100,
  23. search: false,
  24. hideInTable: true,
  25. },
  26. {
  27. title: '内容',
  28. dataIndex: 'detail',
  29. width: 400,
  30. search: false,
  31. },
  32. {
  33. title: '操作',
  34. valueType: 'option',
  35. width: 100,
  36. render: (_, record) => [
  37. <Button
  38. key={2}
  39. style={{ padding: 0 }}
  40. type="link"
  41. onClick={() => {
  42. console.log(record, ']]');
  43. navigate(`/cms/rotationChart/introduction/edit?id=${record.id}`);
  44. }}
  45. >
  46. 编辑
  47. </Button>,
  48. <Popconfirm
  49. key={3}
  50. title="您是否确认删除 ?"
  51. onConfirm={() => handleDelete(record.id)}
  52. okText="确定"
  53. cancelText="取消"
  54. >
  55. {/* manualPush */}
  56. <Button style={{ padding: 0 }} type="link">
  57. 删除
  58. </Button>
  59. </Popconfirm>,
  60. ],
  61. },
  62. ];
  63. return (
  64. <PageContainer>
  65. <ProTable
  66. search={false}
  67. actionRef={actionRef}
  68. rowKey="id"
  69. toolBarRender={() => [
  70. <Button
  71. key="2"
  72. type="primary"
  73. onClick={() => {
  74. navigate('/cms/rotationChart/introduction/edit');
  75. }}
  76. >
  77. 新增
  78. </Button>,
  79. ]}
  80. request={queryTable(getRegulationList)}
  81. columns={columns}
  82. />
  83. </PageContainer>
  84. );
  85. }
  86. export default IntroductionList;