Commit b6aba012 by zhaochengxiang

标签

parent 1bf7eb15
...@@ -113,7 +113,7 @@ export function getMetadataModelTree() { ...@@ -113,7 +113,7 @@ export function getMetadataModelTree() {
} }
export function getAttributesByMetadataModel(payload) { export function getAttributesByMetadataModel(payload) {
return GetJSON(`/metadatarepo/rest/model/getAttributes/${payload.model||''}`); return GetJSON("/dataassetmanager/eleAndAttrApi/getModelAttributes", payload);
} }
export function loadElementWithoutCustom() { export function loadElementWithoutCustom() {
......
...@@ -60,7 +60,7 @@ const AttributeRelationModal = (props) => { ...@@ -60,7 +60,7 @@ const AttributeRelationModal = (props) => {
dispatchLatest({ dispatchLatest({
type: 'assetmanage.getAttributesByMetadataModel', type: 'assetmanage.getAttributesByMetadataModel',
payload: { payload: {
model modelName: model
}, },
callback: data => { callback: data => {
setAttributes(data||[]); setAttributes(data||[]);
......
...@@ -17,6 +17,7 @@ const ModelTable = (props) => { ...@@ -17,6 +17,7 @@ const ModelTable = (props) => {
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]); const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]);
const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
const [ subData, setSubData ] = useState([]); const [ subData, setSubData ] = useState([]);
const moreMenu = (record) => { const moreMenu = (record) => {
...@@ -123,16 +124,24 @@ const ModelTable = (props) => { ...@@ -123,16 +124,24 @@ const ModelTable = (props) => {
width: 100, width: 100,
ellipsis: true, ellipsis: true,
}, },
// { {
// title: '标签', title: '标签',
// dataIndex: 'tag', dataIndex: 'tag',
// width: 250, width: 200,
// render: (_,__) => { onCell: (record) => ({
// return ( onMouseEnter: event => {
// <Tag /> setMouseEnterKey(record.id);
// ); },
// } onMouseLeave: event => {
// }, setMouseEnterKey(null);
},
}),
render: (_,record) => {
return (
record.id===mouseEnterKey?<Tag styleType='complex' />:<Tag />
);
}
},
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
...@@ -202,7 +211,7 @@ const ModelTable = (props) => { ...@@ -202,7 +211,7 @@ const ModelTable = (props) => {
</div> </div>
) )
} }
} },
]; ];
const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } ); const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } );
...@@ -482,10 +491,10 @@ const ModelTable = (props) => { ...@@ -482,10 +491,10 @@ const ModelTable = (props) => {
dataSource={modelId?(subData||[]):(_data||[])} dataSource={modelId?(subData||[]):(_data||[])}
pagination={false} pagination={false}
size={modelId?'small':'default'} size={modelId?'small':'default'}
onRow={(record) => { onRow={(record, index) => {
return { return {
id: `data-model-${record?.id}`, id: `data-model-${record?.id}`,
style: { backgroundColor: (record?.id===anchorId)?'#e7f7ff':'transparent' } style: { backgroundColor: (record?.id===anchorId)?'#e7f7ff':'transparent' },
} }
}} }}
expandable={expandable} expandable={expandable}
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Space } from 'antd'; import { Button, Space, Tag, Modal } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import AddTagModal from './Component/AddTagModal'; import AddTagModal from './Component/AddTagModal';
import { dispatch } from '../../../model'; import { dispatch } from '../../../model';
const Tag = (props) => { const TagColumn = (props) => {
const { id = '619dd97e9e14e63b24b1dbc2-1', type = 'dataModel', creator = 'demotest' } = props; const { id = '619dd97e9e14e63b24b1dbc2-1', type = 'dataModel', creator = 'demotest', styleType = 'simple' } = props;
const [ ownTags, setOwnTags ] = useState([]); const [ ownTags, setOwnTags ] = useState([]);
const [ addTagModalVisible, setAddTagModalVisible ] = useState(false); const [ addTagModalVisible, setAddTagModalVisible ] = useState(false);
const [modal, contextHolder] = Modal.useModal();
useEffect(() => { useEffect(() => {
getTags(); getTags();
...@@ -42,35 +44,96 @@ const Tag = (props) => { ...@@ -42,35 +44,96 @@ const Tag = (props) => {
refresh && getTags(); refresh && getTags();
} }
const handleClose = (index) => {
const _tag = ownTags[index];
modal.confirm({
title: '提示!',
content: '您确定要删除该标签吗?',
onOk: () => {
dispatch({
type: 'tag.deleteTagResource',
payload: {
esIds: _tag.esId
},
callback: () => {
getTags();
}
})
}
});
}
let tagsContent = '';
(ownTags||[]).forEach((item, index) => {
if (index === 0) {
tagsContent = (item.name||'');
} else {
tagsContent += ',' + (item.name||'');
}
})
return ( return (
<div className='tag'> <React.Fragment>
<Space> {
(styleType==='simple') && <div
className='textOverflow'
style={{
fontSize: 13,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
wordBreak: 'break-all'
}}
>
{ tagsContent }
</div>
}
{
(styleType==='complex') && <div>
<div>
{ {
(ownTags||[]).map((item, index) => { (ownTags||[]).map((item, index) => {
return ( return (
<Button key={index} size='small'> <Tag
key={index}
closable
onClose={e => {
e.preventDefault();
handleClose(index);
}}
style={{ marginTop: 5 }}
color={item.type==='public'?'#2db7f5':'volcano'}
>
{ item.name||'' } { item.name||'' }
</Button> </Tag>
); );
}) })
} }
</div>
<div style={{ marginTop: 5 }}>
<Button <Button
size='small' size='small'
type='dashed' type='text'
icon={<PlusOutlined />}
onClick={onAddBtnClick} onClick={onAddBtnClick}
> >
增标签
</Button> </Button>
<AddTagModal </div>
visible={addTagModalVisible} </div>
id={id} }
type={type} <AddTagModal
creator={creator} visible={addTagModalVisible}
onCancel={onAddTagModalCancel} id={id}
/> type={type}
</Space> creator={creator}
</div> onCancel={onAddTagModalCancel}
/>
{contextHolder}
</React.Fragment>
); );
} }
export default Tag; export default TagColumn;
\ No newline at end of file \ No newline at end of file
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