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
29d35247
Commit
29d35247
authored
Jun 21, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产权限
parent
b9f41121
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
38 deletions
+127
-38
assetmanage.js
src/model/assetmanage.js
+5
-0
dataassetmanager.js
src/service/dataassetmanager.js
+5
-0
PermissionMenuItem.jsx
src/util/Component/PermissionMenuItem.jsx
+30
-0
index.js
src/util/index.js
+15
-1
AssetTable.jsx
src/view/Manage/AssetManage/Component/AssetTable.jsx
+72
-37
No files found.
src/model/assetmanage.js
View file @
29d35247
...
@@ -219,4 +219,8 @@ export function* getResourceRelations(payload) {
...
@@ -219,4 +219,8 @@ export function* getResourceRelations(payload) {
export
function
*
updateResourceState
(
payload
)
{
export
function
*
updateResourceState
(
payload
)
{
return
yield
call
(
service
.
updateResourceState
,
payload
);
return
yield
call
(
service
.
updateResourceState
,
payload
);
}
export
function
*
getPrivilege
(
payload
)
{
return
yield
call
(
service
.
getPrivilege
,
payload
);
}
}
\ No newline at end of file
src/service/dataassetmanager.js
View file @
29d35247
...
@@ -226,4 +226,8 @@ export function getResourceRelations(payload) {
...
@@ -226,4 +226,8 @@ export function getResourceRelations(payload) {
export
function
updateResourceState
(
payload
)
{
export
function
updateResourceState
(
payload
)
{
return
PostJSON
(
"/dataassetmanager/resourceApi/updateResourceState"
,
payload
);
return
PostJSON
(
"/dataassetmanager/resourceApi/updateResourceState"
,
payload
);
}
export
function
getPrivilege
(
payload
)
{
return
GetJSON
(
"/dataassetmanager/AuthorityApi/listAllowButtons"
,
payload
);
}
}
\ No newline at end of file
src/util/Component/PermissionMenuItem.jsx
0 → 100644
View file @
29d35247
import
React
,
{
useMemo
}
from
'react'
;
import
{
Tooltip
,
Menu
}
from
'antd'
;
const
FC
=
(
props
)
=>
{
const
{
permissionKey
,
permissions
,
defaultPermission
,
disabled
,
tip
,
children
,
...
restProps
}
=
props
;
const
havePermission
=
useMemo
(()
=>
{
let
_havePermission
=
true
;
if
(
defaultPermission
===
false
)
{
_havePermission
=
defaultPermission
;
}
else
if
(
permissionKey
)
{
const
index
=
(
permissions
||
[]).
findIndex
(
item
=>
item
===
permissionKey
);
_havePermission
=
(
index
!==
-
1
);
}
return
_havePermission
;
},
[
permissionKey
,
permissions
,
defaultPermission
])
return
(
<
Menu
.
Item
disabled=
{
!
havePermission
||
disabled
}
{
...
restProps
}
>
<
Tooltip
title=
{
havePermission
?
tip
:
'暂无权限'
}
>
{
children
}
</
Tooltip
>
</
Menu
.
Item
>
)
}
export
default
FC
;
\ No newline at end of file
src/util/index.js
View file @
29d35247
...
@@ -7,7 +7,7 @@ import { Subject } from 'rxjs';
...
@@ -7,7 +7,7 @@ import { Subject } from 'rxjs';
import
{
dispatchLatest
,
action
}
from
'../model'
;
import
{
dispatchLatest
,
action
}
from
'../model'
;
import
{
set_sess_state
}
from
"../model/reducer"
;
import
{
set_sess_state
}
from
"../model/reducer"
;
import
{
DataModelerRoleAdmin
,
DataModelerRoleUser
,
DataModelerRoleReader
}
from
'./constant'
;
import
{
DataModelerRoleAdmin
,
DataModelerRoleUser
,
DataModelerRoleReader
,
AssetManageReference
,
AssetBrowseReference
,
ResourceBrowseReference
,
AssetRecycleReference
}
from
'./constant'
;
//内网深交所环境 isSzseEnv true
//内网深交所环境 isSzseEnv true
//元曜公网环境 isSzseEnv false
//元曜公网环境 isSzseEnv false
...
@@ -398,3 +398,16 @@ export function getDataModelerRole(user) {
...
@@ -398,3 +398,16 @@ export function getDataModelerRole(user) {
return
DataModelerRoleAdmin
;
return
DataModelerRoleAdmin
;
}
}
export
function
getAssetRange
(
menuName
)
{
if
(
menuName
===
AssetManageReference
)
{
return
'dataAsset_dataAssetManage'
;
}
else
if
(
menuName
===
AssetBrowseReference
)
{
return
'dataAsset_dataAssetBrowse'
;
}
else
if
(
menuName
===
ResourceBrowseReference
)
{
return
'dataAsset_resourceBrowse'
;
}
else
if
(
menuName
===
AssetRecycleReference
)
{
return
'dataAsset_unloadDataAsset'
;
}
return
''
;
}
\ No newline at end of file
src/view/Manage/AssetManage/Component/AssetTable.jsx
View file @
29d35247
...
@@ -12,12 +12,13 @@ import ImportAssetDrawer from './ImportAssetDrawer';
...
@@ -12,12 +12,13 @@ import ImportAssetDrawer from './ImportAssetDrawer';
import
AssetEdit
from
'./AddAssetModel'
;
import
AssetEdit
from
'./AddAssetModel'
;
import
AssetDetailDrawer
from
"./AssetDetailDrawer"
;
import
AssetDetailDrawer
from
"./AssetDetailDrawer"
;
import
{
dispatch
,
dispatchLatestHomepage
}
from
'../../../../model'
;
import
{
dispatch
,
dispatchLatestHomepage
}
from
'../../../../model'
;
import
{
showMessage
,
showNotifaction
,
getQueryParam
,
inputWidth
,
isSzseEnv
}
from
'../../../../util'
;
import
{
showMessage
,
showNotifaction
,
getQueryParam
,
inputWidth
,
isSzseEnv
,
getAssetRange
}
from
'../../../../util'
;
import
{
AnchorId
,
AnchorDirId
,
AnchorTimestamp
,
AssetBrowseReference
,
AssetManageReference
,
AssetRecycleReference
,
ResourceBrowseReference
}
from
'../../../../util/constant'
;
import
{
AnchorId
,
AnchorDirId
,
AnchorTimestamp
,
AssetBrowseReference
,
AssetManageReference
,
AssetRecycleReference
,
ResourceBrowseReference
}
from
'../../../../util/constant'
;
import
{
FullScreenSvg
,
CancelFullScreenSvg
}
from
'./AssetSvg'
;
import
{
FullScreenSvg
,
CancelFullScreenSvg
}
from
'./AssetSvg'
;
import
AssetDeleteModal
from
'./AssetDeleteModal'
;
import
AssetDeleteModal
from
'./AssetDeleteModal'
;
import
PermissionButton
from
'../../../../util/Component/PermissionButton'
;
import
PermissionButton
from
'../../../../util/Component/PermissionButton'
;
import
PermissionRcItem
from
'../../../../util/Component/PermissionRcItem'
;
import
PermissionRcItem
from
'../../../../util/Component/PermissionRcItem'
;
import
PermissionMenuItem
from
'../../../../util/Component/PermissionMenuItem'
;
import
"./AssetTable.less"
;
import
"./AssetTable.less"
;
import
'react-contexify/dist/ReactContexify.css'
;
import
'react-contexify/dist/ReactContexify.css'
;
...
@@ -150,6 +151,7 @@ const AssetTable = (props) => {
...
@@ -150,6 +151,7 @@ const AssetTable = (props) => {
const
[
TableWidth
,
setTableWidth
]
=
useState
(
0
);
const
[
TableWidth
,
setTableWidth
]
=
useState
(
0
);
const
[
compact
,
setCompact
]
=
useState
(
false
);
const
[
compact
,
setCompact
]
=
useState
(
false
);
const
[
assetDeleteModalVisible
,
setAssetDeleteModalVisible
]
=
useState
(
false
);
const
[
assetDeleteModalVisible
,
setAssetDeleteModalVisible
]
=
useState
(
false
);
const
[
permissions
,
setPermissions
]
=
useState
([]);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
anchorId
=
getQueryParam
(
AnchorId
,
props
?.
location
?.
search
);
const
anchorId
=
getQueryParam
(
AnchorId
,
props
?.
location
?.
search
);
...
@@ -192,6 +194,7 @@ const AssetTable = (props) => {
...
@@ -192,6 +194,7 @@ const AssetTable = (props) => {
setSelectItem
({});
setSelectItem
({});
setCheckedKeys
([]);
setCheckedKeys
([]);
getPermissions
();
if
(
shouldScrollRef
.
current
===
true
)
{
if
(
shouldScrollRef
.
current
===
true
)
{
if
(
remoteRelationRef
.
current
)
{
if
(
remoteRelationRef
.
current
)
{
getDataAssetLocationByRelation
();
getDataAssetLocationByRelation
();
...
@@ -223,31 +226,46 @@ const AssetTable = (props) => {
...
@@ -223,31 +226,46 @@ const AssetTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
keyword
,
pagination
,
elementsChanged
,
assetActionChanged
,
recursive
,
fullSearch
])
},
[
keyword
,
pagination
,
elementsChanged
,
assetActionChanged
,
recursive
,
fullSearch
])
const
canAdd
=
useMemo
(()
=>
{
const
allowIndex
=
(
permissions
||
[]).
findIndex
(
item
=>
item
===
'add'
);
return
(
allowIndex
!==
-
1
);
},
[
permissions
])
const
canImport
=
useMemo
(()
=>
{
const
canImport
=
useMemo
(()
=>
{
let
_canImport
=
true
;
let
_canImport
=
true
;
checkedKeys
?.
forEach
(
key
=>
{
if
((
checkedKeys
||
[]).
length
===
0
)
{
const
index
=
(
assets
||
[]).
findIndex
(
item
=>
item
.
id
===
key
);
const
allowIndex
=
(
permissions
||
[]).
findIndex
(
item
=>
item
===
'import'
);
if
(
index
!==
-
1
)
{
_canImport
=
(
allowIndex
!==
-
1
);
const
allowIndex
=
(
assets
[
index
].
allowButtons
||
[]).
findIndex
(
item
=>
item
===
'import'
);
}
else
{
_canImport
=
(
allowIndex
!==
-
1
);
checkedKeys
?.
forEach
(
key
=>
{
}
const
index
=
(
assets
||
[]).
findIndex
(
item
=>
item
.
id
===
key
);
})
if
(
index
!==
-
1
)
{
const
allowIndex
=
(
assets
[
index
].
allowButtons
||
[]).
findIndex
(
item
=>
item
===
'import'
);
_canImport
=
(
allowIndex
!==
-
1
);
}
});
}
return
_canImport
;
return
_canImport
;
},
[
assets
,
checkedKeys
])
},
[
assets
,
checkedKeys
,
permissions
])
const
canExport
=
useMemo
(()
=>
{
const
canExport
=
useMemo
(()
=>
{
let
_canExport
=
true
;
let
_canExport
=
true
;
checkedKeys
?.
forEach
(
key
=>
{
if
((
checkedKeys
||
[]).
length
===
0
)
{
const
index
=
(
assets
||
[]).
findIndex
(
item
=>
item
.
id
===
key
);
const
allowIndex
=
(
permissions
||
[]).
findIndex
(
item
=>
item
===
'export'
);
if
(
index
!==
-
1
)
{
_canExport
=
(
allowIndex
!==
-
1
);
const
allowIndex
=
(
assets
[
index
].
allowButtons
||
[]).
findIndex
(
item
=>
item
===
'export'
);
}
else
{
_canExport
=
(
allowIndex
!==
-
1
);
checkedKeys
?.
forEach
(
key
=>
{
}
const
index
=
(
assets
||
[]).
findIndex
(
item
=>
item
.
id
===
key
);
})
if
(
index
!==
-
1
)
{
const
allowIndex
=
(
assets
[
index
].
allowButtons
||
[]).
findIndex
(
item
=>
item
===
'export'
);
_canExport
=
(
allowIndex
!==
-
1
);
}
});
}
return
_canExport
;
return
_canExport
;
},
[
assets
,
checkedKeys
])
},
[
assets
,
checkedKeys
,
permissions
])
const
canChangeDir
=
useMemo
(()
=>
{
const
canChangeDir
=
useMemo
(()
=>
{
let
_canChangeDir
=
true
;
let
_canChangeDir
=
true
;
...
@@ -288,6 +306,19 @@ const AssetTable = (props) => {
...
@@ -288,6 +306,19 @@ const AssetTable = (props) => {
}
}
}
}
const
getPermissions
=
()
=>
{
dispatch
({
type
:
'assetmanage.getPrivilege'
,
payload
:
{
range
:
getAssetRange
(
reference
),
optionId
:
nodeId
},
callback
:
data
=>
{
setPermissions
(
data
);
}
});
}
const
getDataAssetLocationByRelation
=
()
=>
{
const
getDataAssetLocationByRelation
=
()
=>
{
setLoading
(
true
);
setLoading
(
true
);
dispatch
({
dispatch
({
...
@@ -435,7 +466,8 @@ const AssetTable = (props) => {
...
@@ -435,7 +466,8 @@ const AssetTable = (props) => {
dirId
:
nodeId
,
dirId
:
nodeId
,
pageNum
,
pageNum
,
pageSize
,
pageSize
,
keyword
:
keyword
keyword
:
keyword
,
range
:
getAssetRange
(
reference
),
};
};
if
(
reference
!==
AssetRecycleReference
)
{
if
(
reference
!==
AssetRecycleReference
)
{
...
@@ -447,16 +479,6 @@ const AssetTable = (props) => {
...
@@ -447,16 +479,6 @@ const AssetTable = (props) => {
}
}
}
}
if
(
reference
===
AssetManageReference
)
{
params
.
range
=
'dataAsset_dataAssetManage'
;
}
else
if
(
reference
===
AssetBrowseReference
)
{
params
.
range
=
'dataAsset_dataAssetBrowse'
;
}
else
if
(
reference
===
ResourceBrowseReference
)
{
params
.
range
=
'dataAsset_resourceBrowse'
;
}
else
if
(
reference
===
AssetRecycleReference
)
{
params
.
range
=
'dataAsset_unloadDataAsset'
;
}
let
url
=
'assetmanage.listDataAssetsByPage'
;
let
url
=
'assetmanage.listDataAssetsByPage'
;
if
(
reference
===
AssetRecycleReference
)
{
if
(
reference
===
AssetRecycleReference
)
{
url
=
'assetmanage.listRecycleBinDataAssetsByPage'
;
url
=
'assetmanage.listRecycleBinDataAssetsByPage'
;
...
@@ -833,32 +855,40 @@ const AssetTable = (props) => {
...
@@ -833,32 +855,40 @@ const AssetTable = (props) => {
const
moreMenu
=
(
const
moreMenu
=
(
<
Menu
>
<
Menu
>
{
{
(
reference
===
AssetManageReference
&&
nodeType
!==
'custom'
)
&&
<
Menu
.
Item
>
(
reference
===
AssetManageReference
&&
nodeType
!==
'custom'
)
&&
<
PermissionMenuItem
defaultPermission=
{
canImport
}
>
<
div
className=
'text-center'
onClick=
{
importAsset
}
>
<
div
className=
'text-center'
onClick=
{
importAsset
}
>
导入
导入
</
div
>
</
div
>
</
Menu
.
Item
>
</
PermissionMenu
Item
>
}
}
{
{
(
reference
===
AssetManageReference
||
reference
===
AssetRecycleReference
)
&&
<
React
.
Fragment
>
(
reference
===
AssetManageReference
||
reference
===
AssetRecycleReference
)
&&
<
React
.
Fragment
>
<
Menu
.
Item
>
<
PermissionMenuItem
defaultPermission=
{
canExport
}
>
<
div
className=
'text-center'
onClick=
{
exportAsset
}
>
<
div
className=
'text-center'
onClick=
{
exportAsset
}
>
导出
导出
</
div
>
</
div
>
</
Menu
.
Item
>
</
PermissionMenuItem
>
<
Menu
.
Item
disabled=
{
(
checkedKeys
||
[]).
length
===
0
}
>
<
PermissionMenuItem
defaultPermission=
{
canChangeDir
}
disabled=
{
(
checkedKeys
||
[]).
length
===
0
}
tip=
{
(
checkedKeys
||
[]).
length
===
0
?
'请先选择资产'
:
''
}
>
<
div
className=
'text-center'
onClick=
{
onBatchCatalogChangeBtnClick
}
>
<
div
className=
'text-center'
onClick=
{
onBatchCatalogChangeBtnClick
}
>
{
(
reference
===
AssetRecycleReference
)?
'挂载'
:
'变更目录'
}
{
(
reference
===
AssetRecycleReference
)?
'挂载'
:
'变更目录'
}
</
div
>
</
div
>
</
Menu
.
Item
>
</
PermissionMenu
Item
>
{
{
//自定义目录下的资产不允许新增 删除
//自定义目录下的资产不允许新增 删除
(
nodeType
!==
'custom'
)
&&
<
Menu
.
Item
disabled=
{
(
checkedKeys
||
[]).
length
===
0
}
>
(
nodeType
!==
'custom'
)
&&
<
PermissionMenuItem
defaultPermission=
{
canDelete
}
disabled=
{
(
checkedKeys
||
[]).
length
===
0
}
tip=
{
(
checkedKeys
||
[]).
length
===
0
?
'请先选择资产'
:
''
}
>
<
div
className=
'text-center'
onClick=
{
deleteAssets
}
>
<
div
className=
'text-center'
onClick=
{
deleteAssets
}
>
删除
删除
</
div
>
</
div
>
</
Menu
.
Item
>
</
PermissionMenu
Item
>
}
}
</
React
.
Fragment
>
</
React
.
Fragment
>
}
}
...
@@ -905,7 +935,12 @@ const AssetTable = (props) => {
...
@@ -905,7 +935,12 @@ const AssetTable = (props) => {
<
Space
size=
{
15
}
>
<
Space
size=
{
15
}
>
{
{
//栏目和自定义目录 不允许新增资产
//栏目和自定义目录 不允许新增资产
(
reference
===
AssetManageReference
&&
nodeLevel
!==
1
&&
nodeType
!==
'custom'
)
&&
<
Button
onClick=
{
addAsset
}
>
新增
</
Button
>
(
reference
===
AssetManageReference
&&
nodeLevel
!==
1
&&
nodeType
!==
'custom'
)
&&
<
PermissionButton
defaultPermission=
{
canAdd
}
onClick=
{
addAsset
}
>
新增
</
PermissionButton
>
}
}
{
{
(
compact
&&
reference
===
AssetManageReference
)
?
<
Dropdown
overlay=
{
moreMenu
}
placement=
"bottomCenter"
>
(
compact
&&
reference
===
AssetManageReference
)
?
<
Dropdown
overlay=
{
moreMenu
}
placement=
"bottomCenter"
>
...
...
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