diff --git a/web/client/src/sections/metadataManagement/containers/tagManagement.js b/web/client/src/sections/metadataManagement/containers/tagManagement.js index 277791c..94c3587 100644 --- a/web/client/src/sections/metadataManagement/containers/tagManagement.js +++ b/web/client/src/sections/metadataManagement/containers/tagManagement.js @@ -1,7 +1,97 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react'; +import { connect } from 'react-redux'; +import { Spin, Button, Collapse, Input, Popconfirm, Tag } from 'antd'; +import { SearchOutlined, EditOutlined, CloseOutlined } from '@ant-design/icons'; +import './style.less' +const { Panel } = Collapse; -function TagManagement (props) { - return <>标签管理 +const TagManagement = (props) => { + const { user, dispatch, actions, tagList, isRequesting } = props; + const { metadataManagement } = actions; + const [tagData, setTagData] = useState([]); + const [activeKey, setActiveKey] = useState(); + const [keywords, setKeywords] = useState(''); + + useEffect(() => { + dispatch(metadataManagement.getTagList()).then(res => { + const { data } = res.payload; + if (res.success) { + setTagData(data); + if (data.length) { + setActiveKey(`tagSet-${data[0].tagSetId}`) + } + } + }) + }, []) + const onChange = (key) => { + setActiveKey(key); + }; + const header = (ts) => { + return
{ts.tagSetName} + { }} /> + { }} okText="确定" cancelText="取消"> + + +
+ } + const tag = (t) => { + return
{t.name} + { }} /> + { }} okText="确定" cancelText="取消"> + + +
+ } + const onSearch = () => { + let data = []; + const dataSource = JSON.parse(JSON.stringify(tagList)); + dataSource.map(td => { + if (td.tagSetName.includes(keywords)) { + td.tags = td.tags.filter(tag => tag.name.includes(keywords)); + if (data.length === 0) + setActiveKey(`tagSet-${td.tagSetId}`); + data.push(td); + } + else { + let tags = td.tags.filter(tag => tag.name.includes(keywords)) + if (tags.length) { + td.tags = tags; + if (data.length === 0) + setActiveKey(`tagSet-${td.tagSetId}`); + data.push(td); + } + } + }) + setTagData(data); + if (data.length === 0) + setActiveKey(''); + } + return +
+ {/* */} + + + setKeywords(e.target.value || '')} /> +
+ + {tagData.map(ts => + + {ts.tags.map(t => + {tag(t)} + )} + )} + +
} -export default TagManagement \ No newline at end of file +function mapStateToProps(state) { + const { global, auth, tagList } = state; + return { + user: auth.user, + actions: global.actions, + tagList: tagList.data || [], + isRequesting: tagList.isRequesting + }; +} +export default connect(mapStateToProps)(TagManagement) \ No newline at end of file