Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
7488ab73
Commit
7488ab73
authored
Apr 07, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产打标签
parent
5beb3735
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
292 additions
and
0 deletions
+292
-0
tag.js
src/model/tag.js
+9
-0
tag.js
src/service/tag.js
+8
-0
AssetAction.jsx
src/view/Manage/AssetManage/Component/AssetAction.jsx
+28
-0
AssetTagModal.jsx
src/view/Manage/AssetManage/Component/AssetTagModal.jsx
+247
-0
No files found.
src/model/tag.js
View file @
7488ab73
...
@@ -13,6 +13,10 @@ export function* getResourceTagIn(payload) {
...
@@ -13,6 +13,10 @@ export function* getResourceTagIn(payload) {
return
yield
call
(
service
.
getResourceTagIn
,
payload
);
return
yield
call
(
service
.
getResourceTagIn
,
payload
);
}
}
export
function
*
batchAddTagResourceByTagList
(
payload
)
{
return
yield
call
(
service
.
batchAddTagResourceByTagList
,
payload
);
}
export
function
*
getTagByKeywordAndCreator
(
payload
)
{
export
function
*
getTagByKeywordAndCreator
(
payload
)
{
return
yield
call
(
service
.
getTagByKeywordAndCreator
,
payload
);
return
yield
call
(
service
.
getTagByKeywordAndCreator
,
payload
);
}
}
...
@@ -23,4 +27,8 @@ export function* getSupportTagForm(payload) {
...
@@ -23,4 +27,8 @@ export function* getSupportTagForm(payload) {
export
function
*
saveTag
(
payload
)
{
export
function
*
saveTag
(
payload
)
{
return
yield
call
(
service
.
saveTag
,
payload
);
return
yield
call
(
service
.
saveTag
,
payload
);
}
export
function
*
getTagIdListByNameList
(
payload
)
{
return
yield
call
(
service
.
getTagIdListByNameList
,
payload
);
}
}
\ No newline at end of file
src/service/tag.js
View file @
7488ab73
...
@@ -12,6 +12,10 @@ export function getResourceTagIn(payload) {
...
@@ -12,6 +12,10 @@ export function getResourceTagIn(payload) {
return
PostJSON
(
"/tagger/tagResource/getResourceTagIn"
,
payload
);
return
PostJSON
(
"/tagger/tagResource/getResourceTagIn"
,
payload
);
}
}
export
function
batchAddTagResourceByTagList
(
payload
)
{
return
PostJSON
(
"/tagger/tagResource/batchAddTagResourceByTagList"
,
payload
)
}
export
function
getTagByKeywordAndCreator
(
payload
)
{
export
function
getTagByKeywordAndCreator
(
payload
)
{
return
GetJSON
(
"/tagger/tag/getTagByKeywordAndCreator"
,
payload
);
return
GetJSON
(
"/tagger/tag/getTagByKeywordAndCreator"
,
payload
);
}
}
...
@@ -23,3 +27,7 @@ export function getSupportTagForm(payload) {
...
@@ -23,3 +27,7 @@ export function getSupportTagForm(payload) {
export
function
saveTag
(
payload
)
{
export
function
saveTag
(
payload
)
{
return
PostJSON
(
"/tagger/tag/saveTag"
,
payload
);
return
PostJSON
(
"/tagger/tag/saveTag"
,
payload
);
}
}
export
function
getTagIdListByNameList
(
payload
)
{
return
PostJSON
(
"/tagger/tag/getTagIdListByNameList"
,
payload
);
}
src/view/Manage/AssetManage/Component/AssetAction.jsx
View file @
7488ab73
...
@@ -9,6 +9,7 @@ import { highlightSearchContentByTerms, showMessage } from '../../../../util';
...
@@ -9,6 +9,7 @@ import { highlightSearchContentByTerms, showMessage } from '../../../../util';
import
{
AppContext
}
from
'../../../../App'
;
import
{
AppContext
}
from
'../../../../App'
;
import
Tag
from
'../../Tag'
;
import
Tag
from
'../../Tag'
;
import
Separate
from
'./Separate'
;
import
Separate
from
'./Separate'
;
import
AssetTagModal
from
'./AssetTagModal'
;
import
{
CancelSvg
,
EditSvg
,
SaveSvg
,
FullScreenSvg
,
CancelFullScreenSvg
}
from
'./AssetSvg'
;
import
{
CancelSvg
,
EditSvg
,
SaveSvg
,
FullScreenSvg
,
CancelFullScreenSvg
}
from
'./AssetSvg'
;
...
@@ -24,6 +25,8 @@ const AssetAction = (props) => {
...
@@ -24,6 +25,8 @@ const AssetAction = (props) => {
const
[
fullScreen
,
setFullScreen
]
=
useState
(
false
);
const
[
fullScreen
,
setFullScreen
]
=
useState
(
false
);
const
[
resourceRelations
,
setResourceRelations
]
=
useState
([]);
const
[
resourceRelations
,
setResourceRelations
]
=
useState
([]);
const
{
assets
,
attributes
,
attributesFoldMap
}
=
assetParams
;
const
{
assets
,
attributes
,
attributesFoldMap
}
=
assetParams
;
const
[
assetTagModalVisible
,
setAssetTagModalVisible
]
=
useState
(
false
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
action
===
'add'
)
{
if
(
action
===
'add'
)
{
...
@@ -233,7 +236,16 @@ const AssetAction = (props) => {
...
@@ -233,7 +236,16 @@ const AssetAction = (props) => {
}
}
const
onAssetTag
=
(
keyword
)
=>
{
const
onAssetTag
=
(
keyword
)
=>
{
setKeyword
(
keyword
);
setAssetTagModalVisible
(
true
);
}
const
onAssetTagModalCancel
=
(
refresh
=
false
)
=>
{
setAssetTagModalVisible
(
false
);
if
(
refresh
)
{
getResourceRelations
();
}
}
}
const
formItemLayout
=
{
const
formItemLayout
=
{
...
@@ -463,6 +475,22 @@ const AssetAction = (props) => {
...
@@ -463,6 +475,22 @@ const AssetAction = (props) => {
}
}
</
Spin
>
</
Spin
>
</
div
>
</
div
>
<
AppContext
.
Consumer
>
{
value
=>
{
return
(
<
AssetTagModal
visible=
{
assetTagModalVisible
}
id=
{
id
}
keyword=
{
keyword
}
creator=
{
value
?.
user
?.
userName
||
''
}
onCancel=
{
onAssetTagModalCancel
}
/>
);
}
}
</
AppContext
.
Consumer
>
</
div
>
</
div
>
)
)
}
}
...
...
src/view/Manage/AssetManage/Component/AssetTagModal.jsx
0 → 100644
View file @
7488ab73
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Form
,
Input
,
Space
,
Button
,
Select
}
from
'antd'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
AppContext
}
from
'../../../../App'
;
import
MetadataInfo
from
'./MetadataInfo'
;
const
{
Option
}
=
Select
;
const
AssetTagModal
=
(
props
)
=>
{
const
{
onCancel
,
visible
,
id
,
keyword
,
creator
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
elements
,
setElements
]
=
useState
([]);
const
[
asset
,
setAsset
]
=
useState
(
''
);
const
[
metadataId
,
setMetadataId
]
=
useState
(
''
);
const
[
dirs
,
setDirs
]
=
useState
([]);
useEffect
(()
=>
{
if
(
visible
&&
(
id
||
''
)
!==
''
)
{
getAsset
();
}
else
{
setMetadataId
(
''
);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
,
id
])
useEffect
(()
=>
{
if
(
visible
&&
(
keyword
||
''
)
!==
''
)
{
getDirectoryByName
(
keyword
);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
,
keyword
])
const
getAsset
=
()
=>
{
dispatch
({
type
:
'assetmanage.getDataAssetDetail'
,
payload
:
{
dataAssetId
:
id
},
callback
:
data
=>
{
setAsset
(
data
);
setElements
(
data
?.
elements
||
[]);
setMetadataId
(
data
.
mid
||
''
);
let
_fieldsValue
=
{};
(
data
.
elements
||
[]).
forEach
(
element
=>
{
_fieldsValue
[
element
.
name
]
=
element
.
value
;
})
form
.
setFieldsValue
(
_fieldsValue
);
}
})
}
const
getDirectoryByName
=
(
keyword
)
=>
{
dispatch
({
type
:
'assetmanage.listDirectoryByName'
,
payload
:
{
name
:
keyword
},
callback
:
data
=>
{
setDirs
(
data
||
[]);
}
});
}
//选中元数据后 内容回填.
const
fillElementValueBeforeCreate
=
(
mid
=
metadataId
)
=>
{
dispatch
({
type
:
'assetmanage.fillElementValueBeforeCreate'
,
payload
:
{
params
:
{
metadataIds
:
mid
}
},
callback
:
data
=>
{
let
_fieldsValue
=
{};
(
data
||
[]).
forEach
(
element
=>
{
_fieldsValue
[
element
.
name
]
=
element
.
value
;
})
form
.
setFieldsValue
(
_fieldsValue
);
}
})
}
const
onOk
=
async
()
=>
{
try
{
const
row
=
await
form
.
validateFields
();
const
newElements
=
[...
elements
];
(
newElements
||
[]).
forEach
(
element
=>
{
if
(
row
.
hasOwnProperty
(
element
.
name
))
{
element
.
value
=
row
[
element
.
name
];
}
});
const
params
=
{
dirId
:
row
.
tags
.
join
(
','
),
}
if
((
metadataId
||
''
)
!==
''
)
{
params
.
metadataId
=
metadataId
;
}
setConfirmLoading
(
true
);
dispatch
({
type
:
'assetmanage.addOrUpdateDataAsset'
,
payload
:
{
params
,
data
:
{
...
asset
,
elements
:
newElements
}
},
callback
:
()
=>
{
const
nameList
=
[];
(
dirs
||
[]).
forEach
(
dir
=>
{
if
(
row
.
tags
.
indexOf
(
dir
.
id
)
!==
-
1
)
{
nameList
.
push
(
dir
.
path
);
}
})
dispatch
({
type
:
'tag.getTagIdListByNameList'
,
payload
:
{
params
:
{
nameList
:
nameList
.
join
(
','
)
}
},
callback
:
data
=>
{
dispatch
({
type
:
'tag.batchAddTagResourceByTagList'
,
payload
:
{
params
:
{
tagIds
:
(
data
||
[]).
join
(
','
),
resourceIds
:
id
,
type
:
'public'
,
creator
}
},
callback
:
()
=>
{
setConfirmLoading
(
false
);
onCancel
&&
onCancel
(
true
);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
setConfirmLoading
(
false
);
}
}
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
5
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
17
},
},
};
return
(
<
Modal
forceRender
className=
'asset-add'
title=
'资产打标签'
visible=
{
visible
}
width=
{
600
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
();
}
}
footer=
{
<
Space
>
<
Button
onClick=
{
()
=>
onCancel
&&
onCancel
()
}
>
取消
</
Button
>
<
Button
type=
"primary"
onClick=
{
onOk
}
loading=
{
confirmLoading
}
>
确定
</
Button
>
</
Space
>
}
>
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
<
AppContext
.
Consumer
>
{
value
=>
{
value
?.
onGlobalStateChange
&&
value
?.
onGlobalStateChange
((
state
,
prev
)
=>
{
if
(
state
.
message
===
'data-govern-show-metadata-list-callback-message'
)
{
setMetadataId
(
state
.
data
?.
metadataId
||
''
);
form
?.
setFieldsValue
({
'资产项'
:
state
.
data
?.
metadataInfoJson
||
''
});
if
((
state
.
data
?.
metadataId
||
''
)
!==
''
)
{
fillElementValueBeforeCreate
(
state
.
data
?.
metadataId
||
''
);
}
}
});
return
(
<>
<
Form
.
Item
label=
'资产标签'
name=
'tags'
required=
{
true
}
>
<
Select
mode=
'multiple'
>
{
(
dirs
||
[]).
map
((
dir
,
index
)
=>
{
return
(
<
Option
key=
{
index
}
value=
{
dir
.
id
||
''
}
>
{
dir
.
path
||
''
}
</
Option
>
);
})
}
</
Select
>
</
Form
.
Item
>
{
(
elements
||
[]).
map
((
element
,
index
)
=>
{
return
(
<
Form
.
Item
label=
{
element
.
name
}
name=
{
element
.
name
}
key=
{
index
}
>
{
(
element
.
name
===
'资产项'
)
?
<
MetadataInfo
/>
:
<
Input
disabled=
{
element
.
manualMaintain
===
'否'
}
/>
}
</
Form
.
Item
>
)
})
}
</>
);
}
}
</
AppContext
.
Consumer
>
</
Form
>
</
Modal
>
);
}
export
default
AssetTagModal
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment