Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fe2ac97f
authored
Dec 11, 2024
by
Lesan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 使用Simple设计器的useFormFieldsPermission
parent
4bd02085
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
67 deletions
+6
-67
src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue
+6
-67
No files found.
src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue
View file @
fe2ac97f
...
...
@@ -175,10 +175,11 @@ import {
DEFAULT_BUTTON_SETTING
,
FieldPermissionType
,
APPROVE_TYPE
,
ApproveType
ApproveType
,
ButtonSetting
}
from
'@/components/SimpleProcessDesignerV2/src/consts'
import
*
as
UserApi
from
'@/api/system/user'
import
{
cloneDeep
}
from
'lodash-es
'
import
{
useFormFieldsPermission
}
from
'@/components/SimpleProcessDesignerV2/src/node
'
defineOptions
({
name
:
'ElementCustomConfig4UserTask'
})
const
props
=
defineProps
({
...
...
@@ -206,8 +207,7 @@ const assignEmptyUserIds = ref()
// 操作按钮
const
buttonsSettingEl
=
ref
()
const
{
buttonsSetting
,
btnDisplayNameEdit
,
changeBtnDisplayName
,
btnDisplayNameBlurEvent
}
=
useButtonsSetting
()
const
{
btnDisplayNameEdit
,
changeBtnDisplayName
,
btnDisplayNameBlurEvent
}
=
useButtonsSetting
()
// 字段权限
const
fieldsPermissionEl
=
ref
([])
...
...
@@ -300,6 +300,8 @@ const resetCustomConfigList = () => {
)
fieldsPermissionEl
.
value
=
[]
getNodeConfigFormFields
()
// 由于默认添加了发起人元素,这里需要删掉
fieldsPermissionConfig
.
value
=
fieldsPermissionConfig
.
value
.
slice
(
1
)
fieldsPermissionConfig
.
value
.
forEach
((
element
)
=>
{
element
.
permission
=
fieldsPermissionList
?.
find
((
obj
)
=>
obj
.
field
===
element
.
field
)?.
permission
??
'1'
...
...
@@ -454,69 +456,6 @@ function useButtonsSetting() {
}
}
// 表单字段权限设置
function
useFormFieldsPermission
(
defaultPermission
)
{
// 字段权限配置. 需要有 field, title, permissioin 属性
const
fieldsPermissionConfig
=
ref
<
Array
<
Record
<
string
,
string
>>>
([])
const
formType
=
inject
<
Ref
<
number
>>
(
'formType'
)
// 表单类型
const
formFields
=
inject
<
Ref
<
string
[]
>>
(
'formFields'
)
// 流程表单字段
const
getNodeConfigFormFields
=
(
nodeFormFields
?:
Array
<
Record
<
string
,
string
>>
)
=>
{
nodeFormFields
=
toRaw
(
nodeFormFields
)
fieldsPermissionConfig
.
value
=
cloneDeep
(
nodeFormFields
)
||
getDefaultFieldsPermission
(
unref
(
formFields
))
}
// 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读
const
getDefaultFieldsPermission
=
(
formFields
?:
string
[])
=>
{
const
defaultFieldsPermission
:
Array
<
Record
<
string
,
string
>>
=
[]
if
(
formFields
)
{
formFields
.
forEach
((
fieldStr
:
string
)
=>
{
parseFieldsSetDefaultPermission
(
JSON
.
parse
(
fieldStr
),
defaultFieldsPermission
)
})
}
return
defaultFieldsPermission
}
// 解析字段。赋给默认权限
const
parseFieldsSetDefaultPermission
=
(
rule
:
Record
<
string
,
any
>
,
fieldsPermission
:
Array
<
Record
<
string
,
string
>>
,
parentTitle
:
string
=
''
)
=>
{
const
{
/**type,*/
field
,
title
:
tempTitle
,
children
}
=
rule
if
(
field
&&
tempTitle
)
{
let
title
=
tempTitle
if
(
parentTitle
)
{
title
=
`
${
parentTitle
}
.
${
tempTitle
}
`
}
fieldsPermission
.
push
({
field
,
title
,
permission
:
defaultPermission
})
// TODO 子表单 需要处理子表单字段
// if (type === 'group' && rule.props?.rule && Array.isArray(rule.props.rule)) {
// // 解析子表单的字段
// rule.props.rule.forEach((item) => {
// parseFieldsSetDefaultPermission(item, fieldsPermission, title)
// })
// }
}
if
(
children
&&
Array
.
isArray
(
children
))
{
children
.
forEach
((
rule
)
=>
{
parseFieldsSetDefaultPermission
(
rule
,
fieldsPermission
)
})
}
}
return
{
formType
,
fieldsPermissionConfig
,
getNodeConfigFormFields
}
}
const
userOptions
=
ref
<
UserApi
.
UserVO
[]
>
([])
// 用户列表
onMounted
(
async
()
=>
{
// 获得用户列表
...
...
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