Commit 6f73b805 by zhaochengxiang

资产增加来源操作

parent b7e1128f
...@@ -29,7 +29,7 @@ const AssetBrowse = (props) => { ...@@ -29,7 +29,7 @@ const AssetBrowse = (props) => {
return ( return (
<div className={classes}> <div className={classes}>
<div className='left'> <div className='left'>
<AssetTree onSelect={onTreeSelect} readOnly {...props} /> <AssetTree onSelect={onTreeSelect} showTrash={false} readOnly {...props} />
</div> </div>
<div className='tree-toggle-wrap'> <div className='tree-toggle-wrap'>
<div className='tree-toggle' onClick={treeToggleClick}> <div className='tree-toggle' onClick={treeToggleClick}>
......
...@@ -10,10 +10,10 @@ import AssetMount from '../../AssetRecycle/Component/AssetMount'; ...@@ -10,10 +10,10 @@ import AssetMount from '../../AssetRecycle/Component/AssetMount';
import AttributeRelationModal from "./AttributeRelationModal"; import AttributeRelationModal from "./AttributeRelationModal";
import ImportAsset from './ImportAsset'; import ImportAsset from './ImportAsset';
import AssetEdit from './AssetEdit'; import AssetEdit from './AssetEdit';
import MetadataInfo from './MetadataInfo';
import { dispatch, dispatchLatestHomepage } from '../../../../model'; import { dispatch, dispatchLatestHomepage } from '../../../../model';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv } from '../../../../util'; import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv } from '../../../../util';
import { AnchorId, AnchorTimestamp } from '../../../../util/constant'; import { AnchorId, AnchorTimestamp } from '../../../../util/constant';
import { AppContext } from '../../../../App';
import "./AssetTable.less"; import "./AssetTable.less";
...@@ -41,11 +41,35 @@ const AssetTable = (props) => { ...@@ -41,11 +41,35 @@ const AssetTable = (props) => {
const actionColumn = { const actionColumn = {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 140, width: 190,
fixed: 'right', fixed: 'right',
render: (_,record) => { render: (_,record) => {
const metadata = record['metadata']||'';
return ( return (
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<AppContext.Consumer>
{
value => <Button
type='link'
size='small'
onClick={() => {
value?.setGlobalState && value?.setGlobalState({
message: 'data-govern-show-metadata-message',
data: metadata
})
}}
style={{ padding: 0 }}
disabled={typeof metadata==='string'}
>
来源
</Button>
}
</AppContext.Consumer>
<div>
<Divider type='vertical' />
</div>
<Button <Button
type='link' type='link'
size='small' size='small'
...@@ -86,6 +110,7 @@ const AssetTable = (props) => { ...@@ -86,6 +110,7 @@ const AssetTable = (props) => {
const timestamp = getQueryParam(AnchorTimestamp, props.location.search); const timestamp = getQueryParam(AnchorTimestamp, props.location.search);
const shouldScrollRef = useRef(false); const shouldScrollRef = useRef(false);
const [ metadataIndex, setMetadataIndex ] = useState('');
useEffect(() => { useEffect(() => {
if ((nodeId||'') !== '' ) { if ((nodeId||'') !== '' ) {
...@@ -169,7 +194,7 @@ const AssetTable = (props) => { ...@@ -169,7 +194,7 @@ const AssetTable = (props) => {
callback: data => { callback: data => {
const _columns = []; const _columns = [];
let index = 0; let index = 0, _metadataIndex = '';
(data||[]).forEach(group => { (data||[]).forEach(group => {
(group.names||[]).forEach((name, i) => { (group.names||[]).forEach((name, i) => {
...@@ -209,11 +234,28 @@ const AssetTable = (props) => { ...@@ -209,11 +234,28 @@ const AssetTable = (props) => {
} else if (name === '资产项') { } else if (name === '资产项') {
params.width = isSzseEnv?250:120; params.width = isSzseEnv?250:120;
params.fixed = 'right'; params.fixed = 'right';
params.render = (text, _) => {
params.render = (metadata, _) => {
let _content = '';
if (typeof metadata==='string') {
_content = metadata;
} else {
(metadata.columnItems||[]).forEach((item, index) => {
_content += ((index===0)?'':',') + item.metadataColumnName||'';
})
}
return ( return (
<MetadataInfo config={false} value={text||''} /> <Tooltip title={_content}>
<span>{_content}</span>
</Tooltip>
); );
} }
_metadataIndex = `element${index}`;
setMetadataIndex(_metadataIndex);
} }
_columns.push(params); _columns.push(params);
...@@ -226,7 +268,7 @@ const AssetTable = (props) => { ...@@ -226,7 +268,7 @@ const AssetTable = (props) => {
setColumns([..._columns, actionColumn]); setColumns([..._columns, actionColumn]);
} }
getDataAssets(); getDataAssets(_metadataIndex);
}, },
error: () => { error: () => {
...@@ -235,7 +277,7 @@ const AssetTable = (props) => { ...@@ -235,7 +277,7 @@ const AssetTable = (props) => {
}) })
} }
const getDataAssets = () => { const getDataAssets = (projectIndex = metadataIndex) => {
setLoading(true); setLoading(true);
dispatchLatestHomepage({ dispatchLatestHomepage({
type: 'assetmanage.listDataAssetsByPage', type: 'assetmanage.listDataAssetsByPage',
...@@ -255,7 +297,21 @@ const AssetTable = (props) => { ...@@ -255,7 +297,21 @@ const AssetTable = (props) => {
(elementValue.values||[]).forEach((value, i) => { (elementValue.values||[]).forEach((value, i) => {
index += (i+1); index += (i+1);
if (projectIndex === `element${index}`) {
let metadata = {};
try {
metadata = JSON.parse(value);
_asset['metadata'] = metadata;
_asset[`element${index}`] = metadata;
} catch(error) {
metadata = value;
_asset['metadata'] = metadata;
_asset[`element${index}`] = metadata;
}
} else {
_asset[`element${index}`] = value; _asset[`element${index}`] = value;
}
}); });
}) })
......
...@@ -13,7 +13,7 @@ import './AssetTree.less'; ...@@ -13,7 +13,7 @@ import './AssetTree.less';
const AssetTree = (props) => { const AssetTree = (props) => {
const { readOnly = false, checkable = false, onSelect, className, onCheck, tableId, reference='', showCustom=true } = props; const { readOnly = false, checkable = false, onSelect, className, onCheck, tableId, reference='', showCustom=true, showTrash=true } = props;
const [ keyword, setKeyword ] = useState(''); const [ keyword, setKeyword ] = useState('');
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [ treeData, setTreeData ] = useState([]); const [ treeData, setTreeData ] = useState([]);
...@@ -96,6 +96,9 @@ const AssetTree = (props) => { ...@@ -96,6 +96,9 @@ const AssetTree = (props) => {
if (!showCustom) { if (!showCustom) {
newData = (newData||[]).filter(item => item.type!=='custom'); newData = (newData||[]).filter(item => item.type!=='custom');
} }
if (!showTrash) {
newData = (newData||[]).filter(item => item.type!=='RecycleBin');
}
setTreeData(newData); setTreeData(newData);
......
...@@ -79,7 +79,7 @@ const FilterElementModal = (props) => { ...@@ -79,7 +79,7 @@ const FilterElementModal = (props) => {
}); });
} else { } else {
(elements||[]).forEach(element => { (elements||[]).forEach(element => {
if ((element.name||'')==='中文名称') { if ((element.name||'')==='中文名称' || (element.name||'')==='资产项') {
_selectedKeys.push(element.id||''); _selectedKeys.push(element.id||'');
} }
}); });
...@@ -165,7 +165,7 @@ const FilterElementModal = (props) => { ...@@ -165,7 +165,7 @@ const FilterElementModal = (props) => {
return ( return (
<Col className='mb-3' key={_index} md={6}> <Col className='mb-3' key={_index} md={6}>
<div className='d-flex'> <div className='d-flex'>
<Checkbox checked={ selectedKeys.indexOf(element.id||'')!==-1 } value={element.id||''} onChange={onCheckChange} disabled={(element.name||'')==='中文名称'} > <Checkbox checked={ selectedKeys.indexOf(element.id||'')!==-1 } value={element.id||''} onChange={onCheckChange} disabled={(element.name||'')==='中文名称'||(element.name||'')==='资产项'} >
</Checkbox> </Checkbox>
<Typography.Paragraph className='ml-1' title={element.name||''} ellipsis> <Typography.Paragraph className='ml-1' title={element.name||''} ellipsis>
{element.name||''} {element.name||''}
......
...@@ -62,6 +62,7 @@ const AssetMount = (props) => { ...@@ -62,6 +62,7 @@ const AssetMount = (props) => {
readOnly={true} readOnly={true}
checkable={true} checkable={true}
showCustom={false} showCustom={false}
showTrash={false}
onCheck={onCheck} onCheck={onCheck}
tableId={(refrence==='asset-manage'&&(ids||[].length>0))?ids[0]:''} tableId={(refrence==='asset-manage'&&(ids||[].length>0))?ids[0]:''}
reference='mount' reference='mount'
......
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