Commit 77d130eb by zhaochengxiang

资产详情样式与标准保持统一

parent 154749c8
import React, { useEffect, useState, useContext, useMemo, useRef } from 'react';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select, Cascader, Radio, Divider, Typography, Modal, Row, Col, Pagination, Dropdown, Menu } from 'antd';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select, Cascader, Radio, Divider, Typography, Modal, Row, Col, Pagination, Dropdown, Menu, message } from 'antd';
import { DownOutlined, UpOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import LocalStorage from 'local-storage';
......@@ -32,6 +32,7 @@ const AssetAction = (props) => {
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);
const [ confirmLoading, setConfirmLoading ] = useState(false);
......@@ -226,6 +227,7 @@ const AssetAction = (props) => {
} else {
setMetadataId('');
setAssetParams({...assetParams, ...{assets: {}, attributes: []}});
setCurrentAttribute();
getElements();
}
}
......@@ -482,6 +484,9 @@ const AssetAction = (props) => {
})
setAssetParams({ assets: data, attributes: _attributes, attributesFoldMap: newAttributesFoldMap });
if ((_attributes??[]).length > 0) {
setCurrentAttribute(_attributes[0])
}
let _fieldsValue = {};
(data.elements||[]).forEach(element => {
......@@ -668,16 +673,16 @@ const AssetAction = (props) => {
} catch (errInfo) {
console.log('Validate Failed:', errInfo);
setConfirmLoading(false);
showMessage('warn', '请完成资产必填项')
}
}
const onFoldButtonClick = (attribute, fold) => {
let newAttributesFoldMap = {...attributesFoldMap};
newAttributesFoldMap[attribute] = fold;
// const onFoldButtonClick = (attribute, fold) => {
// let newAttributesFoldMap = {...attributesFoldMap};
// newAttributesFoldMap[attribute] = fold;
setAssetParams({...assetParams, attributesFoldMap: newAttributesFoldMap});
}
// setAssetParams({...assetParams, attributesFoldMap: newAttributesFoldMap});
// }
const onFullScreenClick = () => {
setFullScreen(!fullScreen);
......@@ -999,10 +1004,18 @@ const AssetAction = (props) => {
spinning={loading}
>
<Form form={form} onValuesChange={onValuesChange}>
<Radio.Group 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}>
<Divider orientation='left'>{attribute}</Divider>
return <div key={index} style={{ display: (attribute===currentAttribute)?'':'none' }}>
<Descriptions column={1} bordered>
{
wholeElements?.length>0 && elements?.map((element, index) => {
......@@ -1152,7 +1165,7 @@ const AssetAction = (props) => {
</Space>
<Table
className='mt-2'
className='mt-3'
loading={loadingMetadataColumnList}
columns={permissionId?columns:columns.filter(item => item.dataIndex !== 'permission')}
rowKey='_id'
......
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