Commit 13ae2ddd by zhaochengxiang

资产打标签

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