Commit 13ae2ddd by zhaochengxiang

资产打标签

parent 7488ab73
......@@ -245,6 +245,10 @@ const AssetAction = (props) => {
if (refresh) {
getResourceRelations();
let event = new Event('storage');
event.key = 'tagChange';
window?.dispatchEvent(event);
}
}
......
......@@ -6,6 +6,46 @@ import MetadataInfo from './MetadataInfo';
const { Option } = Select;
const DirsSelect = ({ value = [], data = [], onChange, ...restProps }) => {
const onDirChange = (value, option) => {
if (option.length > 0) {
const recentItem = option[option.length-1];
const recentItemTheme = recentItem.children.split('/')[0];
const newValue = [];
option.forEach(item => {
if (item.children.split('/')[0] !== recentItemTheme) {
newValue.push(item.value);
}
})
newValue.push(recentItem.value);
onChange(newValue);
} else {
onChange(value);
}
}
return (
<Select
mode="multiple"
value={value||[]}
onChange={onDirChange}
allowClear
style={{ width: '100%' }}
>
{
(data||[]).map((dir, index) => {
return (
<Option key={index} value={dir.id||''}>{dir.path||''}</Option>
);
})
}
</Select>
)
}
const AssetTagModal = (props) => {
const { onCancel, visible, id, keyword, creator } = props;
......@@ -142,6 +182,7 @@ const AssetTagModal = (props) => {
},
callback: () => {
setConfirmLoading(false);
form?.resetFields();
onCancel && onCancel(true);
},
error: () => {
......@@ -183,7 +224,10 @@ const AssetTagModal = (props) => {
title='资产打标签'
visible={ visible }
width={ 600 }
onCancel={() => { onCancel && onCancel(); } }
onCancel={() => {
form?.resetFields();
onCancel && onCancel();
} }
footer={
<Space>
<Button onClick={() => onCancel && onCancel() }>取消</Button>
......@@ -213,15 +257,7 @@ const AssetTagModal = (props) => {
name='tags'
required={true}
>
<Select mode='multiple'>
{
(dirs||[]).map((dir, index) => {
return (
<Option key={index} value={dir.id||''}>{dir.path||''}</Option>
);
})
}
</Select>
<DirsSelect data={dirs||[]} />
</Form.Item>
{ (elements||[]).map((element, index) => {
return (
......
......@@ -22,6 +22,23 @@ const TagColumn = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [id])
useEffect(() => {
window?.addEventListener("storage", tagEventChange);
return () => {
window?.removeEventListener("storage", tagEventChange);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
const tagEventChange = (e) => {
if (e.key === 'tagChange' && (id||'') !== '') {
getTags();
}
}
const getTags = () => {
dispatch({
type: 'tag.getResourceTagIn',
......
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