Commit 3ec1f59e by zhaochengxiang

没有资产,详情内容清空

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