Dtxxdata.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React from "react";
  2. import {Badge, ConfigProvider, Table,} from "antd"
  3. function dtxxdata(props: { height: string }) {
  4. return (
  5. <ConfigProvider
  6. theme={{
  7. components: {
  8. Table: {
  9. headerBorderRadius: 0,
  10. },
  11. },
  12. }}
  13. >
  14. <div style={{height: props.height}}>
  15. <Table className="fixed-header"
  16. headerBg='red'
  17. bordered={false}
  18. columns={[
  19. {
  20. title: '时间',
  21. dataIndex: 'time',
  22. key: 'time',
  23. width: '30%',
  24. render: (text) => <span style={{color: 'white'}}>{text}</span>
  25. },
  26. {
  27. title: '事件',
  28. dataIndex: 'event',
  29. key: 'event',
  30. width: '50%',
  31. ellipsis: true,
  32. render: (text) => <span style={{color: 'white'}}>{text}</span>
  33. },
  34. {
  35. title: '状态',
  36. dataIndex: 'status',
  37. key: 'status',
  38. width: '20%',
  39. render: (status) => (
  40. <Badge status={status === 'success' ? 'success' : 'processing'}
  41. text={<span style={{color: status === 'success' ? '#52c41a' : '#faad14'}}>
  42. {status === 'success' ? '已完成' : '处理中'}
  43. </span>}/>
  44. )
  45. }
  46. ]}
  47. dataSource={[
  48. {key: '1', time: '2025-09-23 09:23', event: '污水井盖#W023发生倾斜告警', status: 'processing'},
  49. {key: '2', time: '2025-08-45 09:23', event: '电力井盖#D112维修完成', status: 'success'},
  50. {key: '3', time: '2025-07-18 09:23', event: '通信井盖#T056电压异常', status: 'processing'},
  51. {key: '4', time: '2025-08-23 09:23', event: '雨水井盖#Y091更换完成', status: 'success'},
  52. {key: '5', time: '2025-08-23 09:23', event: '燃气井盖#R034压力告警', status: 'success'},
  53. {key: '6', time: '2025-08-23 09:23', event: '新增通信井盖#T057安装完成', status: 'success'},
  54. {key: '7', time: '2025-08-23 09:23', event: '电力井盖#D108电池更换', status: 'success'}
  55. ]}
  56. pagination={false}
  57. size="small"
  58. style={{backgroundColor: 'transparent'}}
  59. // 添加固定表头配置
  60. scroll={{x: 200, y: 138}}></Table>
  61. <style jsx global>{`
  62. .fixed-header .ant-table-thead > tr > th,
  63. .custom-table .ant-table-thead > tr > td {
  64. background-color: rgba(58, 56, 153, 1) !important; /* 目标背景色 */
  65. color: white !important; /* 表头文字颜色 */
  66. border: none !important; /* 移除边框 */
  67. }
  68. /* 新增:移除表头伪元素样式 */
  69. .fixed-header .ant-table-thead > tr > th::before,
  70. .fixed-header .ant-table-thead > tr > th::after {
  71. content: none !important; /* 清除伪元素内容 */
  72. background: none !important; /* 清除背景 */
  73. }
  74. .fixed-header .ant-table-cell-scrollbar {
  75. background-color: #3a3899 !important; /* 目标背景色 */
  76. color: white !important; /* 表头文字颜色 */
  77. box-shadow: 0 0 0 rgba(0, 0, 0, 0) !important;
  78. }
  79. `}</style>
  80. </div>
  81. </ConfigProvider>
  82. )
  83. }
  84. export default dtxxdata;