|
|
@@ -0,0 +1,74 @@
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
+import { Row, Col } from 'antd'
|
|
|
+import { connect } from 'umi'
|
|
|
+import consts from '@/consts'
|
|
|
+import RoadpricingForm from './Form'
|
|
|
+import RoadpricingLowerList from './LowerList'
|
|
|
+import RoadpricingTabList from './TabList'
|
|
|
+import { apiRoadpricingDetail } from '@/services/product'
|
|
|
+import roadpricingEnum from '../RoadpricingDetail'
|
|
|
+
|
|
|
+const RoadpricingDetail = props => {
|
|
|
+ const { dispatch, updateKey = 'cloud', refresh, visible, dataId = '' } = props
|
|
|
+ const shouldUpdate = refresh[updateKey] || false
|
|
|
+ const columnStateType = pathname?.match(/\/([^/]*)$/)[1]?.toUpperCase()
|
|
|
+ const [state, setState] = useState({
|
|
|
+ loading: false,
|
|
|
+ cloudUser: {},
|
|
|
+ projectPype: roadpricingEnum[columnStateType]
|
|
|
+ })
|
|
|
+ console.log(state.projectPype)
|
|
|
+ const initData = async (id = dataId) => {
|
|
|
+ setState({ ...state, loading: true, projectPype })
|
|
|
+ const {
|
|
|
+ data: { cloudUser = {} },
|
|
|
+ code = -1
|
|
|
+ } = await apiRoadpricingDetail(id)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (shouldUpdate) {
|
|
|
+ dispatch({
|
|
|
+ type: 'refresh/commitAction',
|
|
|
+ payload: updateKey
|
|
|
+ })
|
|
|
+ }
|
|
|
+ setState({ ...state, cloudUser, loading: false, projectPype })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ useEffect(() => {
|
|
|
+ shouldUpdate && initData(dataId)
|
|
|
+ }, [shouldUpdate])
|
|
|
+ useEffect(() => {
|
|
|
+ visible && initData(dataId)
|
|
|
+ }, [visible])
|
|
|
+ return (
|
|
|
+ <div className="sheet-box">
|
|
|
+ <Row>
|
|
|
+ <Col
|
|
|
+ sm={{ span: 24 }}
|
|
|
+ md={{ span: 24 }}
|
|
|
+ lg={{ span: 9 }}
|
|
|
+ xl={{ span: 9 }}
|
|
|
+ className="sheet-box-left">
|
|
|
+ <div className="sheet-left-panel pr-4">
|
|
|
+ <RoadpricingForm updateKey={updateKey} />
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ <Col
|
|
|
+ sm={{ span: 24 }}
|
|
|
+ md={{ span: 24 }}
|
|
|
+ lg={{ span: 15 }}
|
|
|
+ xl={{ span: 15 }}
|
|
|
+ flex={{ flexDirection: 'column' }}
|
|
|
+ className="sheet-box-right">
|
|
|
+ <RoadpricingTabList />
|
|
|
+ <RoadpricingLowerList />
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default connect(({ refresh, single }) => ({
|
|
|
+ refresh,
|
|
|
+ visible: single.drawer.visible
|
|
|
+}))(RoadpricingDetail)
|