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
d6496c28
Commit
d6496c28
authored
Jun 19, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型配置权限
parent
6c0f3df3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
178 additions
and
40 deletions
+178
-40
datamodel.js
src/model/datamodel.js
+9
-0
datamodeler.js
src/service/datamodeler.js
+9
-0
PermissionButton.jsx
src/util/Component/PermissionButton.jsx
+28
-0
PartitionCURD.jsx
src/view/Manage/ModelConfig/Component/PartitionCURD.jsx
+26
-9
TemplateCURD.jsx
src/view/Manage/ModelConfig/Component/TemplateCURD.jsx
+26
-7
WordTemplate.jsx
src/view/Manage/ModelConfig/Component/WordTemplate.jsx
+31
-6
index.jsx
src/view/Manage/ModelConfig/index.jsx
+49
-18
No files found.
src/model/datamodel.js
View file @
d6496c28
...
...
@@ -324,4 +324,12 @@ export function* getInheritanceTypes() {
export
function
*
inheriteDataModel
(
payload
)
{
return
yield
call
(
datamodelerService
.
inheriteDataModel
,
payload
);
}
export
function
*
getConfigPrivilege
()
{
return
yield
call
(
datamodelerService
.
getConfigPrivilege
);
}
export
function
*
getDesignPrivilege
()
{
return
yield
call
(
datamodelerService
.
getDesignPrivilege
);
}
\ No newline at end of file
src/service/datamodeler.js
View file @
d6496c28
...
...
@@ -275,4 +275,12 @@ export function getInheritanceTypes() {
export
function
inheriteDataModel
(
payload
)
{
return
PostJSON
(
"/datamodeler/easyDataModelerInheritance/inheriteDataModel"
,
payload
);
}
export
function
getConfigPrivilege
()
{
return
GetJSON
(
"/datamodeler/easyDataModelerPrivilegeProvider/getConfigPrivilege"
);
}
export
function
getDesignPrivilege
()
{
return
GetJSON
(
"/datamodeler/easyDataModelerPrivilegeProvider/getDesignPrivilege"
);
}
\ No newline at end of file
src/util/Component/PermissionButton.jsx
0 → 100644
View file @
d6496c28
import
React
,
{
useMemo
}
from
'react'
;
import
{
Button
,
Tooltip
}
from
'antd'
;
const
FC
=
(
props
)
=>
{
const
{
permissionKey
,
permissions
,
...
restProps
}
=
props
;
const
havePermission
=
useMemo
(()
=>
{
let
_havePermission
=
true
;
if
(
permissionKey
)
{
const
index
=
(
permissions
||
[]).
findIndex
(
item
=>
item
.
name
===
permissionKey
);
if
(
index
!==
-
1
)
{
_havePermission
=
permissions
[
index
].
enabled
??
true
;
}
}
return
_havePermission
;
},
[
permissionKey
,
permissions
])
return
(
<
Tooltip
title=
{
havePermission
?
''
:
'暂无权限'
}
>
<
Button
{
...
restProps
}
disabled=
{
!
havePermission
}
/>
</
Tooltip
>
)
}
export
default
FC
;
\ No newline at end of file
src/view/Manage/ModelConfig/Component/PartitionCURD.jsx
View file @
d6496c28
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
,
useContext
,
useMemo
}
from
'react'
;
import
{
Table
,
Button
,
Tooltip
,
Modal
,
Divider
}
from
'antd'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
import
UpdatePartitionModal
from
'./UpdatePartitionModal'
;
import
{
ModelConfigContext
}
from
'..'
;
import
PermissionButton
from
'../../../../util/Component/PermissionButton'
;
const
PartitionCURD
=
(
props
)
=>
{
...
...
@@ -14,14 +16,23 @@ const PartitionCURD = (props) => {
const
{
action
,
updataPartitionModalVisible
,
item
}
=
actionData
;
const
modelConfingContext
=
useContext
(
ModelConfigContext
);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
useEffect
(()
=>
{
getPartitions
();
},
[])
const
permissions
=
useMemo
(()
=>
{
const
index
=
(
modelConfingContext
?.
permissions
||
[]).
findIndex
(
item
=>
item
.
privilegedObjectId
===
'4'
);
if
(
index
!==
-
1
)
{
return
modelConfingContext
?.
permissions
[
index
].
optionList
;
}
return
[];
},
[
modelConfingContext
?.
permissions
])
const
columns
=
[
{
title
:
'序号'
,
...
...
@@ -111,25 +122,29 @@ const PartitionCURD = (props) => {
render
:
(
text
,
record
)
=>
{
return
(
<
div
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
}
}
>
<
Button
<
Permission
Button
type=
'link'
size=
'small'
onClick=
{
()
=>
{
editItem
(
record
);
}
}
style=
{
{
padding
:
0
}
}
permissionKey=
'编辑'
permissions=
{
permissions
}
>
编辑
</
Button
>
</
Permission
Button
>
<
div
style=
{
{
margin
:
'0 5px'
}
}
>
<
Divider
type=
'vertical'
/>
</
div
>
<
Button
<
Permission
Button
type=
'link'
size=
'small'
onClick=
{
()
=>
{
deleteItem
(
record
);
}
}
style=
{
{
padding
:
0
}
}
permissionKey=
'删除'
permissions=
{
permissions
}
>
删除
</
Button
>
</
Permission
Button
>
</
div
>
)
}
...
...
@@ -191,11 +206,13 @@ const PartitionCURD = (props) => {
return
(
<
div
>
<
div
className=
'd-flex mb-3'
style=
{
{
alignItems
:
'center'
}
}
>
<
Button
<
Permission
Button
onClick=
{
onAddClick
}
permissionKey=
'新增'
permissions=
{
permissions
}
>
新建
</
Button
>
</
Permission
Button
>
</
div
>
<
Table
loading=
{
loading
}
...
...
src/view/Manage/ModelConfig/Component/TemplateCURD.jsx
View file @
d6496c28
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
,
useContext
,
useMemo
}
from
'react'
;
import
{
Table
,
Button
,
Tooltip
,
Modal
,
Divider
,
Select
}
from
'antd'
;
import
{
Action
,
TemplateId
}
from
'../../../../util/constant'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
import
{
ModelConfigContext
}
from
'..'
;
import
PermissionButton
from
'../../../../util/Component/PermissionButton'
;
const
TemplateCURD
=
(
props
)
=>
{
const
[
constraints
,
setConstraints
]
=
useState
([]);
...
...
@@ -11,6 +13,7 @@ const TemplateCURD = (props) => {
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
currentConstraint
,
setCurrentConstraint
]
=
useState
(
undefined
);
const
modelConfingContext
=
useContext
(
ModelConfigContext
);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
useEffect
(()
=>
{
...
...
@@ -27,6 +30,16 @@ const TemplateCURD = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
currentConstraint
])
const
permissions
=
useMemo
(()
=>
{
const
index
=
(
modelConfingContext
?.
permissions
||
[]).
findIndex
(
item
=>
item
.
privilegedObjectId
===
'2'
);
if
(
index
!==
-
1
)
{
return
modelConfingContext
?.
permissions
[
index
].
optionList
;
}
return
[];
},
[
modelConfingContext
?.
permissions
])
const
storageChange
=
(
e
)
=>
{
if
(
e
.
key
===
'templateChange'
)
{
getTemplates
();
...
...
@@ -89,25 +102,29 @@ const TemplateCURD = (props) => {
render
:
(
text
,
record
)
=>
{
return
(
<
div
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
}
}
>
<
Button
<
Permission
Button
type=
'link'
size=
'small'
onClick=
{
()
=>
{
editItem
(
record
);
}
}
style=
{
{
padding
:
0
}
}
permissionKey=
'编辑'
permissions=
{
permissions
}
>
编辑
</
Button
>
</
Permission
Button
>
<
div
style=
{
{
margin
:
'0 5px'
}
}
>
<
Divider
type=
'vertical'
/>
</
div
>
<
Button
<
Permission
Button
type=
'link'
size=
'small'
onClick=
{
()
=>
{
deleteItem
(
record
);
}
}
style=
{
{
padding
:
0
}
}
permissionKey=
'删除'
permissions=
{
permissions
}
>
删除
</
Button
>
</
Permission
Button
>
</
div
>
)
}
...
...
@@ -176,11 +193,13 @@ const TemplateCURD = (props) => {
return
(
<
div
>
<
div
className=
'd-flex mb-3'
style=
{
{
alignItems
:
'center'
,
justifyContent
:
'space-between'
}
}
>
<
Button
<
Permission
Button
onClick=
{
onAddClick
}
permissionKey=
'新增'
permissions=
{
permissions
}
>
新建
</
Button
>
</
Permission
Button
>
<
Select
placeholder=
'请选择规范'
allowClear
...
...
src/view/Manage/ModelConfig/Component/WordTemplate.jsx
View file @
d6496c28
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
,
useContext
,
useMemo
}
from
'react'
;
import
{
Button
,
Upload
,
Form
,
Row
,
Col
}
from
'antd'
;
import
{
DownloadOutlined
,
UploadOutlined
}
from
'@ant-design/icons'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
import
{
dispatchLatest
}
from
'../../../../model'
;
import
{
ModelConfigContext
}
from
'..'
;
import
PermissionButton
from
'../../../../util/Component/PermissionButton'
;
const
WordTemplate
=
(
props
)
=>
{
const
[
fileList
,
setFileList
]
=
useState
([]);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
modelConfingContext
=
useContext
(
ModelConfigContext
);
const
[
form
]
=
Form
.
useForm
();
const
permissions
=
useMemo
(()
=>
{
const
index
=
(
modelConfingContext
?.
permissions
||
[]).
findIndex
(
item
=>
item
.
privilegedObjectId
===
'1'
);
if
(
index
!==
-
1
)
{
return
modelConfingContext
?.
permissions
[
index
].
optionList
;
}
return
[];
},
[
modelConfingContext
?.
permissions
])
const
downloadTemplate
=
()
=>
{
window
.
open
(
"/api/datamodeler/easyDataModelerExport/word/downloadTemplate"
);
}
...
...
@@ -100,16 +113,28 @@ const WordTemplate = (props) => {
</
Form
.
Item
>
</
Col
>
<
Col
>
<
Button
className=
'ml-3'
icon=
{
<
DownloadOutlined
/>
}
onClick=
{
downloadTemplate
}
>
<
PermissionButton
className=
'ml-3'
icon=
{
<
DownloadOutlined
/>
}
onClick=
{
downloadTemplate
}
permissionKey=
'编辑'
permissions=
{
permissions
}
>
模版下载
</
Button
>
</
Permission
Button
>
</
Col
>
</
Row
>
</
Form
.
Item
>
<
Form
.
Item
{
...
tailLayout
}
>
<
Button
type=
"primary"
htmlType=
"submit"
loading=
{
confirmLoading
}
>
<
PermissionButton
type=
"primary"
htmlType=
"submit"
loading=
{
confirmLoading
}
permissionKey=
'新增'
permissions=
{
permissions
}
>
确定
</
Button
>
</
Permission
Button
>
</
Form
.
Item
>
</
Form
>
)
...
...
src/view/Manage/ModelConfig/index.jsx
View file @
d6496c28
import
React
,
{
useState
}
from
'react'
;
import
{
Tabs
}
from
'antd'
;
import
React
,
{
use
Effect
,
use
State
}
from
'react'
;
import
{
Tabs
,
Spin
}
from
'antd'
;
import
{
dispatch
}
from
'../../../model'
;
import
WordTemplate
from
'./Component/WordTemplate'
;
import
TemplateCURD
from
'./Component/TemplateCURD'
;
import
ConstraintDetail
from
'./Component/ConstraintDetail'
;
...
...
@@ -10,30 +11,60 @@ import './index.less';
const
{
TabPane
}
=
Tabs
;
export
const
ModelConfigContext
=
React
.
createContext
({
permissions
:
undefined
,
});
const
ModelConfig
=
()
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
tabKey
,
setTabKey
]
=
useState
(
'1'
);
const
[
permissions
,
setPermissions
]
=
useState
(
undefined
);
useEffect
(()
=>
{
getPermissions
();
},
[])
const
getPermissions
=
()
=>
{
setLoading
(
true
);
dispatch
({
type
:
'datamodel.getConfigPrivilege'
,
callback
:
data
=>
{
setLoading
(
false
);
setPermissions
(
data
);
},
error
:
()
=>
{
setLoading
(
false
);
}
})
}
const
onTabChange
=
(
key
)
=>
{
setTabKey
(
key
);
}
return
(
<
div
className=
'model-config'
>
<
Tabs
activeKey=
{
tabKey
}
onChange=
{
onTabChange
}
>
<
TabPane
tab=
'Word模版配置'
key=
'1'
>
<
WordTemplate
/>
</
TabPane
>
<
TabPane
tab=
'数据表类型配置'
key=
'2'
>
<
TemplateCURD
/>
</
TabPane
>
<
TabPane
tab=
'规范配置'
key=
'3'
>
<
ConstraintDetail
/>
</
TabPane
>
<
TabPane
tab=
'分区配置'
key=
'4'
>
<
PartitionCURD
/>
</
TabPane
>
</
Tabs
>
</
div
>
<
ModelConfigContext
.
Provider
value=
{
{
permissions
}
}
>
<
div
className=
'model-config'
>
<
Spin
spinning=
{
loading
}
>
<
Tabs
activeKey=
{
tabKey
}
onChange=
{
onTabChange
}
>
<
TabPane
tab=
'Word模版配置'
key=
'1'
>
<
WordTemplate
/>
</
TabPane
>
<
TabPane
tab=
'数据表类型配置'
key=
'2'
>
<
TemplateCURD
/>
</
TabPane
>
<
TabPane
tab=
'规范配置'
key=
'3'
>
<
ConstraintDetail
/>
</
TabPane
>
<
TabPane
tab=
'分区配置'
key=
'4'
>
<
PartitionCURD
/>
</
TabPane
>
</
Tabs
>
</
Spin
>
</
div
>
</
ModelConfigContext
.
Provider
>
)
}
...
...
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