Commit c86d58a8 by zhaochengxiang

资产详情问题

parent 2c948fe6
...@@ -35,7 +35,13 @@ const AssetAction = (props) => { ...@@ -35,7 +35,13 @@ const AssetAction = (props) => {
setCurrentAction('detail'); setCurrentAction('detail');
if ((id||'')!=='') { if ((id||'')!=='') {
getResourceRelations(); getResourceRelations();
getAsset();
if (readOnly) {
getUserElements();
} else {
getAsset();
}
} else { } else {
setMetadataId(''); setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}}); setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
...@@ -91,7 +97,21 @@ const AssetAction = (props) => { ...@@ -91,7 +97,21 @@ const AssetAction = (props) => {
}) })
} }
const getAsset = () => { const getUserElements = () => {
setLoading(true);
dispatch({
type: 'assetmanage.listUserElements',
callback: data => {
setLoading(false);
getAsset(data||[]);
},
error: () => {
setLoading(false);
}
})
}
const getAsset = (userElements=null) => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
type: 'assetmanage.getDataAssetDetail', type: 'assetmanage.getDataAssetDetail',
...@@ -101,6 +121,18 @@ const AssetAction = (props) => { ...@@ -101,6 +121,18 @@ const AssetAction = (props) => {
}, },
callback: data => { callback: data => {
setLoading(false); setLoading(false);
if (userElements) {
const userElementIds = [];
(userElements||[]).forEach(element => {
userElementIds.push(element?.id);
})
const filterElements = (data?.elements||[]).filter(element => userElementIds.indexOf(element?.id) !== -1);
data = { ...data, elements: filterElements }
}
setElements(data?.elements||[]); setElements(data?.elements||[]);
onElementsChange && onElementsChange(data?.elements||[]); onElementsChange && onElementsChange(data?.elements||[]);
......
...@@ -15,14 +15,26 @@ const AssetDetail = (props)=>{ ...@@ -15,14 +15,26 @@ const AssetDetail = (props)=>{
useEffect(() => { useEffect(() => {
if ((id||'') !== '') { if ((id||'') !== '') {
getAssetThenGetAssetName(); getUserElements();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ id ]) }, [ id ])
const getAssetThenGetAssetName = () => { const getUserElements = () => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
type: 'assetmanage.listUserElements',
callback: data => {
getAsset(data||[]);
},
error: () => {
setLoading(false);
}
})
}
const getAsset = (userElements) => {
dispatch({
type: 'assetmanage.getDataAssetDetail', type: 'assetmanage.getDataAssetDetail',
payload: { payload: {
dataAssetId: id, dataAssetId: id,
...@@ -30,6 +42,16 @@ const AssetDetail = (props)=>{ ...@@ -30,6 +42,16 @@ const AssetDetail = (props)=>{
}, },
callback: data => { callback: data => {
setLoading(false); setLoading(false);
const userElementIds = [];
(userElements||[]).forEach(element => {
userElementIds.push(element?.id);
})
const filterElements = (data?.elements||[]).filter(element => userElementIds.indexOf(element?.id) !== -1);
data = { ...data, elements: filterElements }
setAsset(data); setAsset(data);
const _types = []; const _types = [];
......
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