stationEquipment.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import {Table, Button, Input, Popconfirm} from "antd";
  2. import {useState, useEffect} from "react";
  3. import ModalHooks from "./components/stationEquipmentModal.jsx";
  4. import "./stationEquipment.scss";
  5. import axios from "@/utils/axios.js";
  6. import { useDispatch } from 'react-redux';
  7. import { setDictData } from '@/store/reducer.js';
  8. const {Column} = Table;
  9. export default function StationEquipment() {
  10. // 页面数据
  11. const [data, setData] = useState([]);
  12. // 是否展示弹框
  13. const [isModalOpen, setIsModalOpen] = useState(false);
  14. const [row, setRow] = useState({});
  15. // 新增用户页面
  16. function addUser() {
  17. setRow([]);
  18. setIsModalOpen(true);
  19. }
  20. // 关闭页面
  21. function closeModal() {
  22. setIsModalOpen(false);
  23. getData()
  24. dispatch(setDictData(data))
  25. }
  26. // 点击修改的回调
  27. function modify(data) {
  28. setRow(data);
  29. setIsModalOpen(true);
  30. }
  31. // reduce状态
  32. const dispatch = useDispatch();
  33. // 获取数据
  34. async function getData() {
  35. let {data} = await axios.get("/homePage/getBusTotal");
  36. setData([data]);
  37. }
  38. const columns = [
  39. {
  40. title: '设备车辆数量',
  41. dataIndex: 'busNum',
  42. key: 'id',
  43. },
  44. {
  45. title: '线路数量',
  46. dataIndex: 'lineNum',
  47. key: 'id',
  48. },
  49. {
  50. title: '场站数量',
  51. dataIndex: 'stationNum',
  52. key: 'id',
  53. },
  54. {
  55. title: '中途站数量',
  56. dataIndex: 'midwayStationNum',
  57. key: 'id',
  58. },
  59. {
  60. title: '班次数量',
  61. dataIndex: 'classesNum',
  62. key: 'id',
  63. },
  64. {
  65. title: '总里程',
  66. dataIndex: 'totalMileage',
  67. key: 'id',
  68. },
  69. {
  70. title: '入场率',
  71. dataIndex: 'admissionRate',
  72. key: 'id',
  73. },
  74. {
  75. title: '操作',
  76. render:(text, record)=>(
  77. <div className="btn">
  78. <Button type="primary" onClick={() => modify(record)}>
  79. 修改
  80. </Button>
  81. </div>
  82. )
  83. },
  84. ];
  85. useEffect(() => {
  86. getData();
  87. }, []);
  88. return (
  89. <div className="user">
  90. <Table
  91. dataSource={data}
  92. pagination={{position: ["bottomRight"]}}
  93. bordered={true}
  94. rowKey="id"
  95. columns={columns}
  96. >
  97. </Table>
  98. <ModalHooks
  99. isModalOpen={isModalOpen}
  100. closeModal={closeModal}
  101. row={row}
  102. ></ModalHooks>
  103. </div>
  104. );
  105. }