Commit 3ec1f59e by zhaochengxiang

没有资产,详情内容清空

parent c414404c
...@@ -21,7 +21,7 @@ export function saveDatasource(payload) { ...@@ -21,7 +21,7 @@ export function saveDatasource(payload) {
} }
export function validateDatasource(payload) { export function validateDatasource(payload) {
return Post("/metadataharvester/datasource/validateDatasource", payload); return PostJSON("/metadataharvester/datasource/validateDatasource", payload);
} }
export function getDatasource(payload) { export function getDatasource(payload) {
......
...@@ -17,7 +17,7 @@ const AssetAction = (props) => { ...@@ -17,7 +17,7 @@ const AssetAction = (props) => {
const { id, dirId, action, terms, onChange, readOnly = false, form, onMetadataChange, onElementsChange } = props; const { id, dirId, action, terms, onChange, readOnly = false, form, onMetadataChange, onElementsChange } = props;
const [ currentAction, setCurrentAction ] = useState(action); const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: [], attributes: [], attributesFoldMap: {} }); const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} });
const [ elements, setElements ] = useState([]); const [ elements, setElements ] = useState([]);
const [ metadataId, setMetadataId ] = useState(''); const [ metadataId, setMetadataId ] = useState('');
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
...@@ -29,9 +29,15 @@ const AssetAction = (props) => { ...@@ -29,9 +29,15 @@ const AssetAction = (props) => {
useEffect(() => { useEffect(() => {
if (action === 'add') { if (action === 'add') {
getElements(); getElements();
} else if ((id||'')!=='') { } else {
setCurrentAction('detail'); setCurrentAction('detail');
getAsset(); if ((id||'')!=='') {
getAsset();
} else {
setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
setElements([]);
}
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]) }, [id])
...@@ -60,7 +66,7 @@ const AssetAction = (props) => { ...@@ -60,7 +66,7 @@ const AssetAction = (props) => {
} }
}) })
setAssetParams({ assets: [], attributes: _attributes, attributesFoldMap: newAttributesFoldMap }); setAssetParams({ assets: {}, attributes: _attributes, attributesFoldMap: newAttributesFoldMap });
form?.resetFields(); form?.resetFields();
} }
...@@ -324,13 +330,7 @@ const AssetAction = (props) => { ...@@ -324,13 +330,7 @@ const AssetAction = (props) => {
> >
{ {
(attributes||[]).map((attribute, index) => { (attributes||[]).map((attribute, index) => {
let sameAttributeElements = []; let sameAttributeElements = (elements||[]).filter(element => element.type===attribute);
if (currentAction==='add' || currentAction==='edit') {
sameAttributeElements = (elements||[]).filter(element => element.type===attribute);
} else {
sameAttributeElements = (assets?.elements||[]).filter(element => element.type===attribute);
}
if (currentAction!=='add' && !fullScreen && attributesFoldMap[attribute]) { if (currentAction!=='add' && !fullScreen && attributesFoldMap[attribute]) {
sameAttributeElements = (sameAttributeElements||[]).filter(element => unfoldedElements.indexOf(element?.name||'')!==-1); sameAttributeElements = (sameAttributeElements||[]).filter(element => unfoldedElements.indexOf(element?.name||'')!==-1);
......
...@@ -166,13 +166,9 @@ const UpdateDatasourceModal = (props) => { ...@@ -166,13 +166,9 @@ const UpdateDatasourceModal = (props) => {
payload: { payload: {
data: newDatasource data: newDatasource
}, },
callback: data => { callback: () => {
setValidateLoading(false); setValidateLoading(false);
if (data === 'true') { showMessage('success', '测试成功');
showMessage('success', '测试成功');
} else if (data === 'false') {
showMessage('error', '测试失败');
}
}, },
error: () => { error: () => {
setValidateLoading(false); setValidateLoading(false);
......
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