Commit b4476607 by zhaochengxiang

标签同步

parent f7d064f5
......@@ -415,7 +415,7 @@ const FC = (props) => {
}
setColumns([...newColumns, ...notElementCol])
}, [elements])
}, [elements, resoureTagMap])
const tableData = React.useMemo(() => {
const newTableData = []
......
......@@ -9,7 +9,7 @@ import { showMessage } from '../../../../util'
import { dispatch } from '../../../../model'
import { AppContext } from '../../../../App'
const FC = ({ type, id, tags }) => {
const FC = ({ type, id, did, tags }) => {
const [data, setData] = React.useState([])
const [tagSelectPopupParams, setTagSelectPopupParams] = React.useState({
visible: false,
......@@ -21,6 +21,19 @@ const FC = ({ type, id, tags }) => {
setData(tags)
}, [tags])
const storageChange = (e) => {
if (e.key === 'assetDetailTagChangeEvent' && type==='dataAsset' && e.id === id) {
getTags()
}
}
React.useEffect(() => {
window?.addEventListener("storage", storageChange)
return () => {
window?.removeEventListener("storage", storageChange)
}
}, [type, id])
const getTags = () => {
dispatch({
type: 'tag.getResourceTagIn',
......@@ -37,18 +50,29 @@ const FC = ({ type, id, tags }) => {
});
}
//资产或者资源详情里的标签同步
const syncTag = () => {
if (type === 'dataAsset') {
let event = new Event('storage')
event.key = 'assetListTagChangeEvent'
event.id = id
window?.dispatchEvent(event)
}
}
return (
<React.Fragment>
<TagCell
value={data}
onChange={(val) => {
getTags()
syncTag()
}}
onAdd={(val) => {
setTagSelectPopupParams({
visible: true,
type,
items: [{ resourceId: id }]
items: [{ resourceId: id, resourceCatalogId: did }]
})
}}
/>
......@@ -62,6 +86,7 @@ const FC = ({ type, id, tags }) => {
}}
onChange={(val) => {
getTags()
syncTag()
}}
{...tagSelectPopupParams}
/>
......
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