index.jsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { useState, useEffect } from 'react'
  2. import '../index.scss'
  3. import { Drawer, Row, Col } from 'antd'
  4. import useAutoTable from '@/hooks/useAutoTable'
  5. import consts from '@/consts'
  6. import { apiSoftwareDetail } from '@/services/lock'
  7. import LockForm from '@/components/PopContent/Locks/LockForm'
  8. import LockLowerList from '@/components/PopContent/Locks/LockLowerList'
  9. import LockTabList from '@/components/PopContent/Locks/LockTabList'
  10. const Index = props => {
  11. const { visible, onClose, collapsed, id = '' } = props
  12. const needSubtractHeight = 55 // 需要被裁掉的高度
  13. // const needSubtractWidth = (collapsed ? 208 : 48) + 48 + 48 + 48 // 需要被裁掉的高度
  14. const [x, y] = useAutoTable(collapsed, needSubtractHeight)
  15. const [clientWidth, setClientWidth] = useState(document.body.clientWidth * 0.75)
  16. const [state, setState] = useState({
  17. longle: {},
  18. log: [],
  19. total: 0,
  20. longleLog: []
  21. })
  22. const initData = async () => {
  23. const {
  24. data: { longle = {}, log = [], longleLog = [] } = { longle: {}, longleLog: [] },
  25. code = -1
  26. } = await apiSoftwareDetail(id)
  27. if (code === consts.RET_CODE.SUCCESS) {
  28. setState({ ...state, longle, log, longleLog })
  29. }
  30. }
  31. useEffect(() => {
  32. if (visible) {
  33. initData()
  34. }
  35. window.addEventListener('resize', () => {
  36. setClientWidth(document.body.clientWidth * 0.7)
  37. })
  38. return () => {
  39. window.removeEventListener('resize', () => {})
  40. }
  41. }, [visible])
  42. return (
  43. <div>
  44. <div className="sheet-box">
  45. <Drawer
  46. title="软件锁"
  47. placement="right"
  48. bodyStyle={{
  49. height: y,
  50. overflowY: 'hidden'
  51. }}
  52. width={clientWidth}
  53. closable
  54. onClose={onClose}
  55. visible={visible}
  56. // mask={false}
  57. >
  58. <Row>
  59. <Col span={12} className="sheet-box-left">
  60. <div className="sheet-left-panel zh-pd-right-15">
  61. <LockForm longle={state.longle} />
  62. </div>
  63. </Col>
  64. <Col span={12}>
  65. <LockTabList longleLog={state.longleLog} />
  66. <LockLowerList log={state.log} />
  67. </Col>
  68. </Row>
  69. </Drawer>
  70. </div>
  71. </div>
  72. )
  73. }
  74. export default Index