Commit 4de3f948 by zhaochengxiang

流程跳转资产详情

parent b7d94614
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Spin } from "antd";
import AssetDetail from './AssetDetail'; import AssetDetail from './AssetDetail';
import { getQueryParam } from '../../../../util'; import { getQueryParam } from '../../../../util';
import { dispatch } from '../../../../model'
import './AssetDetailPage.less'; import './AssetDetailPage.less';
const AssetDetailPage = (props)=>{ const AssetDetailPage = (props)=>{
const id = getQueryParam('id', props.location?.search)
const [ data, setData ] = useState({ id: '', dirId: '' }); const [dirId, setDirId] = useState(getQueryParam('dirId', props.location?.search))
const [loading, setLoading] = useState(false)
const { id, dirId } = data;
useEffect(() => { useEffect(() => {
if (!dirId) {
const _id = getQueryParam('id', props.location.search); getAssetPaths()
const _dirId = getQueryParam('dirId', props.location.search); }
setData({ id: _id, dirId: _dirId });
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const getAssetPaths = () => {
if (id) {
setLoading(true);
dispatch({
type: 'assetmanage.getAssetPaths',
payload: {
dataAssetId: id,
},
callback: data => {
setLoading(false);
if ((data??[]).length > 0) {
setDirId(data[0].dirId)
}
},
error: () => {
setLoading(false);
}
})
}
}
return( return(
<div className='asset-detail position-relative'> <div className='asset-detail position-relative'>
<div className='detail-header'> <div className='detail-header'>
<span style={{ fontSize: 16, fontWeight: 'bold', color: '#fff' }}>资产详情</span> <span style={{ fontSize: 16, fontWeight: 'bold', color: '#fff' }}>资产详情</span>
</div> </div>
<Spin spinning={loading}>
<div className='detail-container'> <div className='detail-container'>
<div className='detail-container-card'> <div className='detail-container-card'>
<AssetDetail id={id} dirId={dirId} /> {
dirId && <AssetDetail id={id} dirId={dirId} />
}
</div> </div>
</div> </div>
</Spin>
</div> </div>
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment