Commit 0f2b50ba by zhaochengxiang

bug fix

parent bd949de1
...@@ -414,6 +414,10 @@ export function getAssetType(reference) { ...@@ -414,6 +414,10 @@ export function getAssetType(reference) {
return (reference===AssetManageReference || reference===AssetBrowseReference || reference===AssetRecycleReference) ? 'dataAsset' : 'resource' return (reference===AssetManageReference || reference===AssetBrowseReference || reference===AssetRecycleReference) ? 'dataAsset' : 'resource'
} }
export function getAssetTypeByRange(range) {
return (range==='dataAsset_dataAssetManage' || range==='dataAsset_dataAssetBrowse') ? 'dataAsset' : 'resource'
}
export function getAssetRange(menuName) { export function getAssetRange(menuName) {
if (menuName === ResourceManageReference ) { if (menuName === ResourceManageReference ) {
return 'dataAsset_resourceManage'; return 'dataAsset_resourceManage';
......
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { Spin, Descriptions, Divider } from "antd"; import { Spin, Descriptions, Divider } from "antd";
import { getAssetRange, getAssetType, highlightSearchContentByTerms } from '../../../../util'; import { getAssetRange, getAssetType, getAssetTypeByRange, highlightSearchContentByTerms } from '../../../../util';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { ElementItem } from "./AssetAction"; import { ElementItem } from "./AssetAction";
import { AssetManageReference, ResourceManageReference } from "../../../../util/constant"; import { AssetManageReference, ResourceManageReference } from "../../../../util/constant";
...@@ -13,20 +13,14 @@ const AssetDetail = (props)=>{ ...@@ -13,20 +13,14 @@ const AssetDetail = (props)=>{
const [ types, setTypes ] = useState([]); const [ types, setTypes ] = useState([]);
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [ userElements, setUserElements ] = useState(undefined); const [ userElements, setUserElements ] = useState(undefined);
const [range, setRange] = useState();
useEffect(() => { useEffect(() => {
if ((id||'') !== '') { if (dirId && id) {
getUserElements();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ id ])
useEffect(() => {
if (dirId) {
getPreviewRangeByDirIdThenGetAsset(); getPreviewRangeByDirIdThenGetAsset();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ dirId ]) }, [ dirId, id])
const _asset = useMemo(() => { const _asset = useMemo(() => {
let newAsset = {}; let newAsset = {};
...@@ -58,7 +52,9 @@ const AssetDetail = (props)=>{ ...@@ -58,7 +52,9 @@ const AssetDetail = (props)=>{
}, },
callback: data => { callback: data => {
setLoading(false); setLoading(false);
getAsset(data); setRange(data);
getUserElements();
getAsset();
}, },
error: () => { error: () => {
setLoading(false); setLoading(false);
...@@ -67,50 +63,56 @@ const AssetDetail = (props)=>{ ...@@ -67,50 +63,56 @@ const AssetDetail = (props)=>{
} }
const getUserElements = () => { const getUserElements = () => {
setLoading(true); setRange(prevRange => {
dispatch({ setLoading(true);
type: 'assetmanage.listUserElements', dispatch({
payload: { type: 'assetmanage.listUserElements',
params: { payload: {
range: getAssetRange(reference), params: {
dataAssetType: getAssetType(reference) range: prevRange,
} dataAssetType: getAssetTypeByRange(prevRange)
},
callback: data => {
setLoading(false);
setUserElements(data||[]);
const _types = [];
(data||[]).forEach(element => {
if (_types.indexOf(element.type) === -1) {
_types.push(element.type);
} }
}) },
callback: data => {
setTypes(_types); setLoading(false);
}, setUserElements(data||[]);
error: () => { const _types = [];
setLoading(false); (data||[]).forEach(element => {
} if (_types.indexOf(element.type) === -1) {
_types.push(element.type);
}
})
setTypes(_types);
},
error: () => {
setLoading(false);
}
})
return prevRange
}) })
} }
const getAsset = (range) => { const getAsset = () => {
setLoading(true); setRange(prevRange => {
dispatch({ setLoading(true);
type: 'assetmanage.getDataAssetDetail', dispatch({
payload: { type: 'assetmanage.getDataAssetDetail',
range, payload: {
dataAssetId: id, range: prevRange,
dirId: dirId||'', dataAssetId: id,
checkPermission: true dirId: dirId||'',
}, checkPermission: true
callback: data => { },
setLoading(false); callback: data => {
setAsset(data); setLoading(false);
}, setAsset(data);
error: () => { },
setLoading(false); error: () => {
} setLoading(false);
}
})
return prevRange
}) })
} }
......
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