|
|
@@ -1,6 +1,5 @@
|
|
|
import React, { useState, useEffect } from 'react'
|
|
|
-import { Drawer, Row, Col } from 'antd'
|
|
|
-import useAutoTable from '@/hooks/useAutoTable'
|
|
|
+import { Row, Col, Spin } from 'antd'
|
|
|
import consts from '@/consts'
|
|
|
import { apiCompanyDetail } from '@/services/company'
|
|
|
import CompanyForm from '@/pages/Customer/Company/components/CompanyDetail/CompanyForm'
|
|
|
@@ -9,16 +8,14 @@ import CompanyTabList from '@/pages/Customer/Company/components/CompanyDetail/Co
|
|
|
import { connect } from 'dva'
|
|
|
|
|
|
const Index = props => {
|
|
|
- const { dispatch, shouldUpdate, visible, onClose, collapsed, id = '' } = props
|
|
|
- const needSubtractHeight = 55 // 需要被裁掉的高度
|
|
|
- // const needSubtractWidth = (collapsed ? 208 : 48) + 48 + 48 + 48 // 需要被裁掉的高度
|
|
|
- const [x, y] = useAutoTable(collapsed, needSubtractHeight)
|
|
|
- const [clientWidth, setClientWidth] = useState(document.body.clientWidth * 0.75)
|
|
|
+ const { dispatch, shouldUpdate, visible, id = '' } = props
|
|
|
const [state, setState] = useState({
|
|
|
+ loading: false,
|
|
|
customer: {},
|
|
|
log: []
|
|
|
})
|
|
|
const initData = async () => {
|
|
|
+ setState({ ...state, loading: true })
|
|
|
const {
|
|
|
data: { customer = {}, log = [] },
|
|
|
code = -1
|
|
|
@@ -30,22 +27,21 @@ const Index = props => {
|
|
|
payload: 'company'
|
|
|
})
|
|
|
}
|
|
|
- setState({ ...state, customer, log })
|
|
|
+ setState({ ...state, customer, log, loading: false })
|
|
|
}
|
|
|
}
|
|
|
useEffect(() => {
|
|
|
- if (visible || shouldUpdate) {
|
|
|
+ if (shouldUpdate) {
|
|
|
initData()
|
|
|
}
|
|
|
- window.addEventListener('resize', () => {
|
|
|
- setClientWidth(document.body.clientWidth * 0.7)
|
|
|
- })
|
|
|
- return () => {
|
|
|
- window.removeEventListener('resize', () => {})
|
|
|
+ }, [shouldUpdate])
|
|
|
+ useEffect(() => {
|
|
|
+ if (visible) {
|
|
|
+ initData()
|
|
|
}
|
|
|
- }, [visible, shouldUpdate])
|
|
|
+ }, [visible])
|
|
|
return (
|
|
|
- <div>
|
|
|
+ <Spin spinning={state.loading}>
|
|
|
<div className="sheet-box">
|
|
|
<Row>
|
|
|
<Col span={12} className="sheet-box-left">
|
|
|
@@ -59,7 +55,7 @@ const Index = props => {
|
|
|
</Col>
|
|
|
</Row>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </Spin>
|
|
|
)
|
|
|
}
|
|
|
|