|
|
@@ -1,14 +1,16 @@
|
|
|
-import React, { useState, useEffect } from 'react'
|
|
|
-import { Row, Col, Spin } from 'antd'
|
|
|
+import React, { useState, useEffect, useMemo } from 'react'
|
|
|
+import { Row, Col, Spin, Tooltip } from 'antd'
|
|
|
import consts from '@/consts'
|
|
|
import { apiCompanyDetail } from '@/services/company'
|
|
|
import CompanyForm from '@/pages/customer/Company/components/CompanyDetail/CompanyForm'
|
|
|
import CompanyLowerList from '@/pages/customer/Company/components/CompanyDetail/CompanyLowerList'
|
|
|
import CompanyTabList from '@/pages/customer/Company/components/CompanyDetail/CompanyTabList'
|
|
|
import { connect } from 'dva'
|
|
|
+import { IconPark } from '@/components/SvgIcon'
|
|
|
+import { FlipOverEnum, useFlipOver } from '@/hooks/web/useFlipOver'
|
|
|
|
|
|
const Index = props => {
|
|
|
- const { dispatch, shouldUpdate, visible, id = '' } = props
|
|
|
+ const { dispatch, shouldUpdate, visible, id = '', orderIds = [] } = props
|
|
|
const [state, setState] = useState({
|
|
|
loading: false,
|
|
|
customer: {},
|
|
|
@@ -16,12 +18,12 @@ const Index = props => {
|
|
|
software: {},
|
|
|
client: {}
|
|
|
})
|
|
|
- const initData = async () => {
|
|
|
+ const initData = async dataId => {
|
|
|
setState({ ...state, loading: true })
|
|
|
const {
|
|
|
data: { customer = {}, log = [], software = {}, client = {} },
|
|
|
code = -1
|
|
|
- } = await apiCompanyDetail(id)
|
|
|
+ } = await apiCompanyDetail(dataId)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
if (shouldUpdate) {
|
|
|
dispatch({
|
|
|
@@ -32,21 +34,43 @@ const Index = props => {
|
|
|
setState({ ...state, customer, log, software, loading: false, client })
|
|
|
}
|
|
|
}
|
|
|
+ const { flipFn, flipConsts } = useFlipOver(initData, id, orderIds)
|
|
|
useEffect(() => {
|
|
|
- if (shouldUpdate) {
|
|
|
- initData()
|
|
|
- }
|
|
|
+ shouldUpdate && initData(id)
|
|
|
}, [shouldUpdate])
|
|
|
useEffect(() => {
|
|
|
- if (visible) {
|
|
|
- initData()
|
|
|
- }
|
|
|
+ visible && initData(id)
|
|
|
}, [visible])
|
|
|
return (
|
|
|
<Spin spinning={state.loading}>
|
|
|
<div className="sheet-box">
|
|
|
<Row>
|
|
|
- <Col span={12} className="sheet-box-left">
|
|
|
+ <Col span={12} className="sheet-box-left text-gray-400">
|
|
|
+ <div className="mb-3">
|
|
|
+ <Tooltip title="上一条记录">
|
|
|
+ <IconPark
|
|
|
+ type="up"
|
|
|
+ fill={flipConsts.disableUpBtn ? '#BDBDBE' : '#886ab5'}
|
|
|
+ size="20"
|
|
|
+ onClick={() => flipFn(FlipOverEnum.UP)}
|
|
|
+ className={[
|
|
|
+ flipConsts.disableUpBtn ? 'cursor-not-allowed' : 'cursor-pointer'
|
|
|
+ ].join(' ')}
|
|
|
+ />
|
|
|
+ </Tooltip>
|
|
|
+ <Tooltip title="下一条记录">
|
|
|
+ <IconPark
|
|
|
+ type="down"
|
|
|
+ fill={flipConsts.disableDownBtn ? '#BDBDBE' : '#886ab5'}
|
|
|
+ size="20"
|
|
|
+ onClick={() => flipFn(FlipOverEnum.DOWN)}
|
|
|
+ className={[
|
|
|
+ flipConsts.disableDownBtn ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
|
+ 'ml-1'
|
|
|
+ ].join(' ')}
|
|
|
+ />
|
|
|
+ </Tooltip>
|
|
|
+ </div>
|
|
|
<div className="sheet-left-panel zh-pd-right-15">
|
|
|
<CompanyForm customer={state.customer} />
|
|
|
</div>
|
|
|
@@ -54,7 +78,7 @@ const Index = props => {
|
|
|
<Col span={12} flex={{ flexDirection: 'column' }} className="sheet-box-right">
|
|
|
<CompanyTabList
|
|
|
initData={initData}
|
|
|
- customerId={id}
|
|
|
+ customerId={flipConsts.curId}
|
|
|
software={state.software}
|
|
|
client={state.client}
|
|
|
/>
|