Commit 265bf08d by zhaochengxiang

岗位新增资产

parent 8e4946ef
import React, { useState } from 'react';
import { Modal, Form, Space, Button } from 'antd';
import { Modal, Form, Space, Button, Spin } from 'antd';
import { showMessage } from '../../../../util';
import { dispatch } from '../../../../model';
import AssetAction from './AssetAction';
import './AddAssetModel.less';
const AddAssetModel = (props) => {
const { onCancel, visible, nodeId } = props;
const [ confirmLoading, setConfirmLoading ] = useState(false);
const [ metadataId, setMetadataId ] = useState('');
const [ waiting, setWaiting ] = useState(false);
const [ elements, setElements ] = useState([]);
const [ form ] = Form.useForm();
......@@ -19,14 +15,15 @@ const AddAssetModel = (props) => {
setElements(value);
}
const onMetadataChange = (value) => {
setMetadataId(value);
const close = (refresh = false) => {
setWaiting(false)
form?.resetFields()
onCancel?.(refresh)
}
const onOk = async() => {
try {
const row = await form?.validateFields();
const newElements = [...elements];
(newElements||[]).forEach(element => {
if (row.hasOwnProperty(element.name)) {
......@@ -34,15 +31,7 @@ const AddAssetModel = (props) => {
}
});
const params = {
dirId: nodeId,
}
if ((metadataId||'')!=='') {
params.metadataId = metadataId;
}
setConfirmLoading(true);
setWaiting(true);
dispatch({
type: 'assetmanage.checkCodeIsExist',
......@@ -51,62 +40,63 @@ const AddAssetModel = (props) => {
},
callback: isExist => {
if (isExist === 'true') {
setConfirmLoading(false);
setWaiting(false);
showMessage('warn', '已存在相同的资产目录编号,请重新输入');
} else {
dispatch({
type: 'assetmanage.addOrUpdateDataAsset',
payload: {
params,
params: {
dirId: nodeId,
},
data: { elements: newElements }
},
callback: () => {
setConfirmLoading(false);
showMessage("success","新增成功");
onCancel && onCancel(true);
close(true)
},
error: () => {
setConfirmLoading(false);
setWaiting(false);
}
})
}
},
error: () => {
setConfirmLoading(false);
setWaiting(false);
}
})
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
setConfirmLoading(false);
setWaiting(false);
}
}
return (
<Modal
forceRender
destroyOnClose
className='asset-add'
title='新增资产目录信息'
visible={ visible }
width={ 600 }
onCancel={() => { onCancel && onCancel(); } }
centered
width={ 800 }
onCancel={() => { close() } }
footer={
<Space>
<Button onClick={() => onCancel && onCancel() }>取消</Button>
<Button type="primary" onClick={ onOk } loading={ confirmLoading }>确定</Button>
<Button type="primary" onClick={ onOk } disabled={ waiting }>确定</Button>
</Space>
}
bodyStyle={{ padding: '10px' }}
bodyStyle={{ overflowX: 'auto', height: '80vh' }}
>
{
visible && <AssetAction
form={form}
dirId={nodeId}
action='add'
onMetadataChange={onMetadataChange}
onElementsChange={onElementsChange}
/>
}
<Spin spinning={waiting}>
<AssetAction
form={form}
dirId={nodeId}
action='add'
onElementsChange={onElementsChange}
/>
</Spin>
</Modal>
);
}
......
.asset-add {
.yy-modal-body {
max-height: 500px !important;
overflow: auto !important;
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import ImportAssetDrawer from './ImportAssetDrawer';
import AssetEdit from './AddAssetModel';
import AssetDetailDrawer from "./AssetDetailDrawer";
import { dispatch, dispatchLatestHomepage } from '../../../../model';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv, highlightSearchContentByTerms } from '../../../../util';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv, highlightSearchContentByTerms, isPostAsset } from '../../../../util';
import { AnchorId, AnchorDirId, AnchorTimestamp, AssetBrowseReference, AssetManageReference, AssetRecycleReference, ResourceBrowseReference } from '../../../../util/constant';
import { FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import AssetDeleteModal from './AssetDeleteModal';
......@@ -935,7 +935,6 @@ const AssetTable = (props) => {
</Menu.Item>
}
{
//自定义目录下的资产不允许新增 删除
(nodeType!=='custom') && <Menu.Item disabled={(checkedKeys||[]).length===0}>
<div className='text-center' onClick={deleteAssets}>
删除
......@@ -987,8 +986,7 @@ const AssetTable = (props) => {
>
<Space size={15}>
{
//栏目和自定义目录 不允许新增资产
// (reference===AssetManageReference && nodeLevel!==1 && nodeType!=='custom') && <Button onClick={addAsset}>新增</Button>
(reference===AssetManageReference && isPostAsset(getTemplateType()) && nodeId) && <Button onClick={addAsset}>新增</Button>
}
{
......
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