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
00be8817
Commit
00be8817
authored
Jul 05, 2024
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限
parent
3a605525
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
80 deletions
+102
-80
auth-share.jsx
src/view/Manage/Model/Component/auth-share.jsx
+65
-32
auth-transfer.jsx
src/view/Manage/Model/Component/auth-transfer.jsx
+36
-47
update-branch.jsx
src/view/Manage/Model/Component/update-branch.jsx
+1
-1
No files found.
src/view/Manage/Model/Component/auth-share.jsx
View file @
00be8817
...
@@ -4,7 +4,6 @@ import produce from "immer"
...
@@ -4,7 +4,6 @@ import produce from "immer"
import
{
useDebounceEffect
}
from
"ahooks"
import
{
useDebounceEffect
}
from
"ahooks"
import
{
dispatch
}
from
'../../../../model'
import
{
dispatch
}
from
'../../../../model'
import
{
UsersItem
}
from
"./update-branch"
const
FC
=
(
props
)
=>
{
const
FC
=
(
props
)
=>
{
const
{
item
,
visible
,
onCancel
}
=
props
const
{
item
,
visible
,
onCancel
}
=
props
...
@@ -103,8 +102,6 @@ const FC = (props) => {
...
@@ -103,8 +102,6 @@ const FC = (props) => {
export
default
FC
export
default
FC
export
const
Basic
=
React
.
forwardRef
(
function
({
cooperators
,
item
},
ref
)
{
export
const
Basic
=
React
.
forwardRef
(
function
({
cooperators
,
item
},
ref
)
{
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
users
,
setUsers
]
=
React
.
useState
()
const
[
form
]
=
Form
.
useForm
()
const
[
form
]
=
Form
.
useForm
()
React
.
useImperativeHandle
(
ref
,
()
=>
({
React
.
useImperativeHandle
(
ref
,
()
=>
({
...
@@ -114,33 +111,60 @@ export const Basic = React.forwardRef(function ({ cooperators, item }, ref) {
...
@@ -114,33 +111,60 @@ export const Basic = React.forwardRef(function ({ cooperators, item }, ref) {
}),
[
form
])
}),
[
form
])
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
item
?.
id
)
{
getUsers
()
}
},
[
item
])
React
.
useEffect
(()
=>
{
if
((
cooperators
??[]).
length
>
0
)
{
if
((
cooperators
??[]).
length
>
0
)
{
form
.
setFieldsValue
({
cooperators
})
form
.
setFieldsValue
({
cooperators
})
}
}
},
[
cooperators
])
},
[
cooperators
])
return
(
<
Form
form=
{
form
}
labelCol=
{
{
span
:
3
}
}
wrapperCol=
{
{
span
:
21
}
}
autoComplete=
"off"
>
<
Form
.
Item
name=
'cooperators'
label=
'选择用户'
extra=
"权限共享后,您与共享用户均可编辑该模型"
>
<
UsersItem
modelId=
{
item
?.
id
}
/>
</
Form
.
Item
>
</
Form
>
)
})
//注意 这里使用name作为唯一标识 id有可能为空
const
UsersItem
=
({
modelId
,
value
,
onChange
,
readonly
=
false
})
=>
{
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
searchValue
,
setSearchValue
]
=
React
.
useState
()
const
[
options
,
setOptions
]
=
React
.
useState
()
useDebounceEffect
(()
=>
{
if
(
searchValue
)
{
getUsers
()
}
else
{
setOptions
()
}
},
[
searchValue
],
{
wait
:
300
})
const
getUsers
=
()
=>
{
const
getUsers
=
()
=>
{
setLoading
(
true
)
setLoading
(
true
)
dispatch
({
dispatch
({
type
:
'datamodel.getCooperatorCandidates'
,
type
:
'datamodel.getCooperatorCandidates'
,
payload
:
{
payload
:
{
id
:
item
?.
id
id
:
modelId
,
match
:
searchValue
,
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setLoading
(
false
)
setLoading
(
false
)
//id int转string
setOptions
(
const
newData
=
produce
((
data
??[]).
filter
(
item
=>
item
.
cooperatorCandidate
),
(
draft
)
=>
{
(
data
??[]).
map
(
item
=>
(
{
draft
.
forEach
(
item
=>
{
label
:
`
${
item
.
dname
}
(
${
item
.
name
}
)`
,
item
.
id
=
`
${
item
.
id
}
`
value
:
`
${
item
.
dname
}
(
${
item
.
name
}
)`
,
})
...
item
}
)
})
)
setUsers
(
newData
)
)
},
},
error
:
()
=>
{
error
:
()
=>
{
setLoading
(
false
)
setLoading
(
false
)
...
@@ -149,19 +173,28 @@ export const Basic = React.forwardRef(function ({ cooperators, item }, ref) {
...
@@ -149,19 +173,28 @@ export const Basic = React.forwardRef(function ({ cooperators, item }, ref) {
}
}
return
(
return
(
<
Form
<>
form=
{
form
}
{
labelCol=
{
{
span
:
3
}
}
readonly
?
<
span
>
{
value
?.
map
(
item
=>
`${item.dname}(${item.name})`
).
toString
()
}
</
span
>
:
<
Select
loading=
{
loading
}
mode=
'multiple'
allowClear
wrapperCol=
{
{
span
:
21
}
}
placeholder=
'请选择用户'
autoComplete=
"off"
value=
{
(
value
??[]).
map
(
item
=>
`${item.dname}(${item.name})`
)
}
>
searchValue=
{
searchValue
}
<
Form
.
Item
onSearch=
{
(
val
)
=>
{
name=
'cooperators'
setSearchValue
(
val
)
label=
'选择用户'
}
}
extra=
"权限共享后,您与共享用户均可编辑该模型"
onClear=
{
()
=>
{
>
setSearchValue
()
<
UsersItem
loading=
{
loading
}
users=
{
users
}
/>
}
}
</
Form
.
Item
>
filterOption=
{
false
}
</
Form
>
options=
{
options
}
onChange=
{
(
val
)
=>
{
onChange
?.([
...(
value
??[]).
filter
(
item
=>
(
val
??[]).
indexOf
(
`${item.dname}(${item.name})`
)
!==
-
1
),
...(
options
??[]).
filter
(
item
=>
(
val
??[]).
indexOf
(
item
.
value
)
!==
-
1
)
])
}
}
/>
}
</>
)
)
}
)
}
src/view/Manage/Model/Component/auth-transfer.jsx
View file @
00be8817
...
@@ -102,8 +102,6 @@ const FC = (props) => {
...
@@ -102,8 +102,6 @@ const FC = (props) => {
export
default
FC
export
default
FC
export
const
Basic
=
React
.
forwardRef
(
function
({
owner
,
item
},
ref
)
{
export
const
Basic
=
React
.
forwardRef
(
function
({
owner
,
item
},
ref
)
{
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
users
,
setUsers
]
=
React
.
useState
()
const
[
form
]
=
Form
.
useForm
()
const
[
form
]
=
Form
.
useForm
()
React
.
useImperativeHandle
(
ref
,
()
=>
({
React
.
useImperativeHandle
(
ref
,
()
=>
({
...
@@ -113,40 +111,11 @@ export const Basic = React.forwardRef(function ({ owner, item }, ref) {
...
@@ -113,40 +111,11 @@ export const Basic = React.forwardRef(function ({ owner, item }, ref) {
}),
[
form
])
}),
[
form
])
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
item
?.
id
)
{
getUsers
()
}
},
[
item
])
React
.
useEffect
(()
=>
{
if
(
owner
)
{
if
(
owner
)
{
form
.
setFieldsValue
({
owner
})
form
.
setFieldsValue
({
owner
})
}
}
},
[
owner
])
},
[
owner
])
const
getUsers
=
()
=>
{
setLoading
(
true
)
dispatch
({
type
:
'datamodel.getCooperatorCandidates'
,
payload
:
{
id
:
item
?.
id
},
callback
:
data
=>
{
setLoading
(
false
)
//id int转string
const
newData
=
produce
((
data
??[]).
filter
(
item
=>
item
.
cooperatorCandidate
),
(
draft
)
=>
{
draft
.
forEach
(
item
=>
{
item
.
id
=
`
${
item
.
id
}
`
})
})
setUsers
(
newData
)
},
error
:
()
=>
{
setLoading
(
false
)
}
})
}
return
(
return
(
<
Form
<
Form
form=
{
form
}
form=
{
form
}
...
@@ -160,31 +129,53 @@ export const Basic = React.forwardRef(function ({ owner, item }, ref) {
...
@@ -160,31 +129,53 @@ export const Basic = React.forwardRef(function ({ owner, item }, ref) {
extra=
"权限转移后,您将无法编辑该模型"
extra=
"权限转移后,您将无法编辑该模型"
rules=
{
[{
required
:
true
,
message
:
'请选择用户'
}]
}
rules=
{
[{
required
:
true
,
message
:
'请选择用户'
}]
}
>
>
<
UsersItem
loading=
{
loading
}
users=
{
users
}
/>
<
UsersItem
modelId=
{
item
?.
id
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
</
Form
>
</
Form
>
)
)
})
})
const
UsersItem
=
({
loading
,
users
,
value
,
onChange
})
=>
{
const
UsersItem
=
({
modelId
,
value
,
onChange
})
=>
{
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
searchValue
,
setSearchValue
]
=
React
.
useState
()
const
[
searchValue
,
setSearchValue
]
=
React
.
useState
()
const
[
options
,
setOptions
]
=
React
.
useState
()
const
[
options
,
setOptions
]
=
React
.
useState
()
useDebounceEffect
(()
=>
{
useDebounceEffect
(()
=>
{
setOptions
(
if
(
modelId
&&
searchValue
)
{
(
users
??[])
getUsers
()
.
filter
(
item
=>
!
searchValue
||
(
item
.
name
??
''
).
indexOf
(
searchValue
)
!==-
1
)
}
else
{
.
map
(
item
=>
({
setOptions
()
label
:
item
.
name
,
}
value
:
item
.
id
,
},
[
searchValue
],
{
wait
:
300
})
}))
)
const
getUsers
=
()
=>
{
},
[
searchValue
,
users
],
{
wait
:
300
})
setLoading
(
true
)
dispatch
({
type
:
'datamodel.getCooperatorCandidates'
,
payload
:
{
id
:
modelId
,
match
:
searchValue
,
},
callback
:
data
=>
{
setLoading
(
false
)
setOptions
(
(
data
??[]).
map
(
item
=>
({
label
:
`
${
item
.
dname
}
(
${
item
.
name
}
)`
,
value
:
`
${
item
.
dname
}
(
${
item
.
name
}
)`
,
...
item
}))
)
},
error
:
()
=>
{
setLoading
(
false
)
}
})
}
return
(
return
(
<
Select
loading=
{
loading
}
showSearch
allowClear
<
Select
loading=
{
loading
}
showSearch
allowClear
placeholder=
'请选择用户'
placeholder=
'请选择用户'
value=
{
(
options
??[]).
length
>
0
?
value
?.
id
:
undefined
}
value=
{
value
?
`${value.dname}(${value.name})`
:
undefined
}
searchValue=
{
searchValue
}
searchValue=
{
searchValue
}
onSearch=
{
(
val
)
=>
{
onSearch=
{
(
val
)
=>
{
setSearchValue
(
val
)
setSearchValue
(
val
)
...
@@ -196,11 +187,9 @@ const UsersItem = ({ loading, users, value, onChange }) => {
...
@@ -196,11 +187,9 @@ const UsersItem = ({ loading, users, value, onChange }) => {
options=
{
options
}
options=
{
options
}
onChange=
{
(
val
)
=>
{
onChange=
{
(
val
)
=>
{
if
(
val
)
{
if
(
val
)
{
const
index
=
(
users
??[]).
findIndex
(
item
=>
item
.
id
===
val
)
const
index
=
(
options
??[]).
findIndex
(
item
=>
item
.
value
===
val
)
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
onChange
?.(
users
[
index
])
onChange
?.(
options
[
index
])
}
else
{
onChange
?.()
}
}
}
else
{
}
else
{
onChange
?.()
onChange
?.()
...
...
src/view/Manage/Model/Component/update-branch.jsx
View file @
00be8817
...
@@ -253,7 +253,7 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
...
@@ -253,7 +253,7 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
})
})
//注意 这里使用name作为唯一标识 id有可能为空
//注意 这里使用name作为唯一标识 id有可能为空
export
const
UsersItem
=
({
value
,
onChange
,
readonly
=
false
})
=>
{
const
UsersItem
=
({
value
,
onChange
,
readonly
=
false
})
=>
{
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
loading
,
setLoading
]
=
React
.
useState
(
false
)
const
[
searchValue
,
setSearchValue
]
=
React
.
useState
()
const
[
searchValue
,
setSearchValue
]
=
React
.
useState
()
const
[
options
,
setOptions
]
=
React
.
useState
()
const
[
options
,
setOptions
]
=
React
.
useState
()
...
...
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