Commit 53cf45a4 by zhaochengxiang

bug fix

parent 9f33ce11
......@@ -31,7 +31,6 @@ const AssetAction = (props) => {
const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} });
const [ elements, setElements ] = useState([]);
const [ wholeElements, setWholeElements ] = useState([]);
const [currentAttribute, setCurrentAttribute] = useState();
const [ metadataId, setMetadataId ] = useState('');
const [ loading, setLoading ] = useState(false);
......@@ -213,12 +212,11 @@ const AssetAction = (props) => {
getTreeData();
getDepartments();
if (action === 'add') {
// getElements();
} else {
setCurrentAction('detail');
if ((id||'')!=='') {
setPagination({...pagination, pageNum: 1});
getElements();
getAssetPaths();
getResourceRelations();
checkDataAssetEditable();
......@@ -228,7 +226,6 @@ const AssetAction = (props) => {
setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
setCurrentAttribute();
getElements();
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
......@@ -385,20 +382,6 @@ const AssetAction = (props) => {
});
}
const getElements = ( cb = null ) => {
dispatch({
type: (currentAction==='add')?'assetmanage.listElementsAndFillValue':'assetmanage.listElements',
payload: (currentAction==='add')?{
params: {
dirId
}
}:undefined,
callback: data => {
setWholeElements(data||[]);
}
})
}
const getUserElements = () => {
setLoading(true);
dispatch({
......@@ -597,7 +580,7 @@ const AssetAction = (props) => {
if (item.resourceType==='innerSource'||item.resourceType==='outerSource') {
window.open(`/center-home/menu/asset-resource-browse?${AnchorId}=${item?.dataAssetId}&${AnchorDirId}=${item?.dirId}&timestamp=${timestamp}`);
} else if (item.resourceType==='dataAsset') {
window.open(`/center-home/menu/asset-browse?${AnchorId}=${item?.dataAssetId}&${AnchorDirId}=${item?.dirId}&templateType=${LocalStorage.get(`templateType-${appId}`)}&timestamp=${timestamp}`);
window.open(`/center-home/menu/asset-browse?${AnchorId}=${item?.dataAssetId}&${AnchorDirId}=${item?.dirId}&templateType=${assets?.templateType}&timestamp=${timestamp}`);
} else {
showMessage('warn', '资产目录类型不是资源也不是资产!');
}
......@@ -946,53 +929,57 @@ const AssetAction = (props) => {
</Space>
</div>
}
{
(action!=='add' && (id||'')!=='') && <div>
<div className='pl-common py-compact-common'>
<Descriptions column={1}>
<Descriptions.Item
label={<div className='title-text' style={{ textAlign: 'right', width: 90 }}>资产目录路径</div>}
style={{ paddingBottom: 0 }}
>
<div className='flex' style={{ flexDirection: 'column' }}>
{
(assetPaths||[]).map((item, key) => {
return (
<a key={key} onClick={() => { jumpToPath(item); }}>
<span>{item?.dataAssetName||''}</span>
</a>
);
})
}
</div>
</Descriptions.Item>
{/* <Descriptions.Item label={<div className='title-text' style={{ textAlign: 'right', width: 90 }}>资产目录标签</div>} style={{ paddingBottom: 15 }}>
<AppContext.Consumer>
{
value => {
return (currentAction==='add'||currentAction==='edit')?<Tag styleType='complex' id={id} creator={value?.user?.userName||''} onAssetTag={onAssetTag} />:<Tag id={id} creator={value?.user?.userName||''} />
}
}
</AppContext.Consumer>
</Descriptions.Item> */}
{/* <Descriptions.Item
label={<div className='title-text' style={{ textAlign: 'right', width: 80 }}>关联关系</div>}
style={{ paddingBottom: 0 }}
>
<div className='flex' style={{ flexDirection: 'column' }}>
{
(resourceRelations||[]).map((item, key) => {
return (
<a key={key} onClick={() => { jumpToRelation(item); }}>{item?.dataAssetName||''}</a>
);
})
}
</div>
</Descriptions.Item> */}
</Descriptions>
</div>
</div>
}
<Spin
spinning={loading}
>
{
(action!=='add' && (id||'')!=='') && <div>
<div className='pl-common py-compact-common'>
<Descriptions column={1}>
<Descriptions.Item
label={<div className='title-text' style={{ textAlign: 'right', width: 90 }}>资产目录路径</div>}
style={{ paddingBottom: 0 }}
>
<div className='flex' style={{ flexDirection: 'column' }}>
{
(assetPaths||[]).map((item, key) => {
return (
<a key={key} onClick={() => { jumpToPath(item); }}>
<span>{item?.dataAssetName||''}</span>
</a>
);
})
}
</div>
</Descriptions.Item>
{/* <Descriptions.Item label={<div className='title-text' style={{ textAlign: 'right', width: 90 }}>资产目录标签</div>} style={{ paddingBottom: 15 }}>
<AppContext.Consumer>
{
value => {
return (currentAction==='add'||currentAction==='edit')?<Tag styleType='complex' id={id} creator={value?.user?.userName||''} onAssetTag={onAssetTag} />:<Tag id={id} creator={value?.user?.userName||''} />
}
}
</AppContext.Consumer>
</Descriptions.Item> */}
{/* <Descriptions.Item
label={<div className='title-text' style={{ textAlign: 'right', width: 80 }}>关联关系</div>}
style={{ paddingBottom: 0 }}
>
<div className='flex' style={{ flexDirection: 'column' }}>
{
(resourceRelations||[]).map((item, key) => {
return (
<a key={key} onClick={() => { jumpToRelation(item); }}>{item?.dataAssetName||''}</a>
);
})
}
</div>
</Descriptions.Item> */}
</Descriptions>
</div>
</div>
}
{/* <div
style={{
......@@ -1000,93 +987,85 @@ const AssetAction = (props) => {
overflow: 'auto',
}}
> */}
<Spin
spinning={loading}
>
<Form form={form} onValuesChange={onValuesChange}>
<Radio.Group buttonStyle='solid' className='mb-3' value={currentAttribute} onChange={(e) => {
setCurrentAttribute(e.target.value)
}}>
{
(attributes??[]).map((item,key) => (
<Radio.Button key={key} value={item}>{item}</Radio.Button>
))
}
</Radio.Group>
{
attributes?.map((attribute, index) => {
return <div key={index} style={{ display: (attribute===currentAttribute)?'':'none' }}>
<Descriptions column={1} bordered>
{
wholeElements?.length>0 && elements?.map((element, index) => {
if (element.type!==attribute || element.name === '资产项') return null;
let interpretation = null;
const filterElements = wholeElements?.filter(_element => _element.id === element.id);
if (filterElements.length>0) {
interpretation = filterElements[0].interpretation;
}
<Form form={form} onValuesChange={onValuesChange}>
<Radio.Group buttonStyle='solid' className='mb-3' value={currentAttribute} onChange={(e) => {
setCurrentAttribute(e.target.value)
}}>
{
(attributes??[]).map((item,key) => (
<Radio.Button key={key} value={item}>{item}</Radio.Button>
))
}
</Radio.Group>
{
attributes?.map((attribute, index) => {
return <div key={index} style={{ display: (attribute===currentAttribute)?'':'none' }}>
<Descriptions column={1} bordered>
{
elements?.map((element, index) => {
if (element.type!==attribute || element.name === '资产项') return null;
return (
<Descriptions.Item
key={index}
label={
<span>
{element.name}
{
(currentAction==='add'||currentAction==='edit') && element.required && <span style={{ color: 'red' }}>*</span>
}
</span>
return (
<Descriptions.Item
key={index}
label={
<span>
{element.name}
{
(currentAction==='add'||currentAction==='edit') && element.required && <span style={{ color: 'red' }}>*</span>
}
labelStyle={{ width: 180 }}
>
{
(currentAction==='add'||currentAction==='edit') ?
<Row gutter={8} align='middle'>
<Col span={22}>
<Form.Item
label=''
name={element.name}
rules={[{ required: element.required }]}
style={{ marginBottom: 0 }}
>
{elementEditComponent(element)}
</Form.Item>
</span>
}
labelStyle={{ width: 180 }}
>
{
(currentAction==='add'||currentAction==='edit') ?
<Row gutter={8} align='middle'>
<Col span={22}>
<Form.Item
label=''
name={element.name}
rules={[{ required: element.required }]}
style={{ marginBottom: 0 }}
>
{elementEditComponent(element)}
</Form.Item>
</Col>
{
element.interpretation && <Col span={2}>
<Tooltip placement="left" title={element.interpretation}>
<QuestionCircleOutlined style={{ fontSize: 16 }} />
</Tooltip>
</Col>
{
interpretation && <Col span={2}>
<Tooltip placement="left" title={interpretation}>
<QuestionCircleOutlined style={{ fontSize: 16 }} />
</Tooltip>
</Col>
}
</Row>
: <React.Fragment>
<Row gutter={8} align='middle'>
<Col span={22}>
{ elementDetailComponent(element) }
}
</Row>
: <React.Fragment>
<Row gutter={8} align='middle'>
<Col span={22}>
{ elementDetailComponent(element) }
</Col>
{
element.interpretation && <Col span={2}>
<Tooltip placement="left" title={element.interpretation}>
<QuestionCircleOutlined style={{ fontSize: 16 }} />
</Tooltip>
</Col>
{
interpretation && <Col span={2}>
<Tooltip placement="left" title={interpretation}>
<QuestionCircleOutlined style={{ fontSize: 16 }} />
</Tooltip>
</Col>
}
</Row>
</React.Fragment>
}
</Descriptions.Item>
)
})
}
</Descriptions>
</div>
})
}
</Form>
}
</Row>
</React.Fragment>
}
</Descriptions.Item>
)
})
}
</Descriptions>
</div>
})
}
</Form>
</Spin>
</Spin>
{/* </div> */}
<div>
......
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