Commit f7d064f5 by zhaochengxiang

资源新增

parent f44a8654
...@@ -5,10 +5,11 @@ import { dispatch } from '../../../../model'; ...@@ -5,10 +5,11 @@ import { dispatch } from '../../../../model';
import AssetAction from './AssetAction'; import AssetAction from './AssetAction';
import './AddAssetModel.less'; import './AddAssetModel.less';
import { AssetManageReference, ResourceManageReference } from '../../../../util/constant';
const AddAssetModel = (props) => { const AddAssetModel = (props) => {
const { onCancel, visible, nodeId } = props; const { onCancel, visible, nodeId, reference = AssetManageReference } = props;
const [ confirmLoading, setConfirmLoading ] = useState(false); const [ confirmLoading, setConfirmLoading ] = useState(false);
const [ metadataId, setMetadataId ] = useState(''); const [ metadataId, setMetadataId ] = useState('');
const [ elements, setElements ] = useState([]); const [ elements, setElements ] = useState([]);
...@@ -34,12 +35,17 @@ const AddAssetModel = (props) => { ...@@ -34,12 +35,17 @@ const AddAssetModel = (props) => {
} }
}); });
const params = { let params = {}
if (reference === ResourceManageReference) {
params = {
dirIds: nodeId,
metadataId
};
} else {
params = {
dirId: nodeId, dirId: nodeId,
} metadataId
};
if ((metadataId||'')!=='') {
params.metadataId = metadataId;
} }
setConfirmLoading(true); setConfirmLoading(true);
...@@ -55,7 +61,7 @@ const AddAssetModel = (props) => { ...@@ -55,7 +61,7 @@ const AddAssetModel = (props) => {
showMessage('warn', '已存在相同的资产编号,请重新输入'); showMessage('warn', '已存在相同的资产编号,请重新输入');
} else { } else {
dispatch({ dispatch({
type: 'assetmanage.addOrUpdateDataAsset', type: (reference===ResourceManageReference)?'assetmanage.addOrUpdateResource':'assetmanage.addOrUpdateDataAsset',
payload: { payload: {
params, params,
data: { elements: newElements } data: { elements: newElements }
......
...@@ -81,6 +81,7 @@ const FC = (props) => { ...@@ -81,6 +81,7 @@ const FC = (props) => {
const [resoureTagMap, setResourceTagMap] = React.useState() const [resoureTagMap, setResourceTagMap] = React.useState()
const [addAssetParams, setAddAssetParams] = React.useState({ const [addAssetParams, setAddAssetParams] = React.useState({
visible: false, visible: false,
reference: undefined,
nodeId: undefined nodeId: undefined
}) })
const [addToAssetParams, setAddToAssetParams] = React.useState({ const [addToAssetParams, setAddToAssetParams] = React.useState({
...@@ -619,6 +620,7 @@ const FC = (props) => { ...@@ -619,6 +620,7 @@ const FC = (props) => {
const onAddClick = () => { const onAddClick = () => {
setAddAssetParams({ setAddAssetParams({
visible: true, visible: true,
reference: ResourceManageReference,
nodeId: node?.nodeId nodeId: node?.nodeId
}) })
} }
...@@ -1282,6 +1284,7 @@ const FC = (props) => { ...@@ -1282,6 +1284,7 @@ const FC = (props) => {
onCancel={(refresh = false) => { onCancel={(refresh = false) => {
setAddAssetParams({ setAddAssetParams({
visible: false, visible: false,
reference: undefined,
nodeId: undefined nodeId: undefined
}) })
refresh && getAssets() refresh && getAssets()
......
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