index.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { Drawer, Row, Col } from 'antd'
  2. import React, { useState, useEffect } from 'react'
  3. import '../index.scss'
  4. import ContanctForm from '@/components/PopContent/Contacts/ContanctForm.jsx'
  5. import ContanctTabList from '@/components/PopContent/Contacts/ContanctTabList.jsx'
  6. import ContanctLowerList from '@/components/PopContent/Contacts/ContanctLowerList.jsx'
  7. import { apiContactDetail } from '@/services/contact'
  8. import useAutoTable from '@/hooks/useAutoTable'
  9. import consts from '@/consts'
  10. const Popcontent = 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. // 浏览器实际宽度
  16. const [clientWidth, setClientWidth] = useState(document.body.clientWidth * 0.75)
  17. const [state, setState] = useState({
  18. client: {},
  19. log:[]
  20. })
  21. const initData = async () => {
  22. const {
  23. data: { client = {},log = [] },
  24. code = -1
  25. } = await apiContactDetail(id)
  26. if (code === consts.RET_CODE.SUCCESS) {
  27. setState({ ...state, client, log })
  28. }
  29. }
  30. useEffect(() => {
  31. if (visible) {
  32. initData()
  33. }
  34. window.addEventListener('resize', () => {
  35. setClientWidth(document.body.clientWidth * 0.7)
  36. })
  37. return () => {
  38. window.removeEventListener('resize', () => {})
  39. }
  40. }, [visible])
  41. return (
  42. <div>
  43. <div className='sheet-box'>
  44. <Drawer
  45. title="联系人"
  46. placement="right"
  47. bodyStyle={{
  48. height:y,
  49. overflowY:'hidden'
  50. }}
  51. width={clientWidth}
  52. closable
  53. onClose={onClose}
  54. visible={visible}
  55. // mask={false}
  56. >
  57. <Row>
  58. <Col span={12} className="sheet-box-left" style={{ height:y-25,overflowY:'auto' }}>
  59. <div className="sheet-left-panel zh-pd-right-15">
  60. <ContanctForm client={state.client} />
  61. </div>
  62. </Col>
  63. <Col span={12}>
  64. <ContanctTabList />
  65. <ContanctLowerList log={state.log} />
  66. </Col>
  67. </Row>
  68. </Drawer>
  69. </div>
  70. </div>
  71. )
  72. }
  73. export default Popcontent
  74. // export default connect(({ journallist, loading }) => ({
  75. // journalName: journallist,
  76. // getlist: loading.effects['journallist/fetch']
  77. // }))(Popcontent)