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
7cb68da5
authored
Jul 26, 2024
by
jason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
仿钉钉流程设计器- 复杂表单字段解析
parent
3a5c93fa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
src/components/SimpleProcessDesignerV2/src/node.ts
+30
-4
No files found.
src/components/SimpleProcessDesignerV2/src/node.ts
View file @
7cb68da5
...
...
@@ -39,20 +39,46 @@ export function useFormFieldsPermission() {
fieldsPermissionConfig
.
value
=
cloneDeep
(
nodeFormFields
)
||
getDefaultFieldsPermission
(
unref
(
formFields
))
}
//
获取默认的表单权限。 所有字段
只读
//
默认的表单权限: 获取表单的所有字段,设置字段默认权限为
只读
const
getDefaultFieldsPermission
=
(
formFields
?:
string
[])
=>
{
const
defaultFieldsPermission
:
Array
<
Record
<
string
,
string
>>
=
[]
if
(
formFields
)
{
formFields
.
forEach
((
fieldStr
:
string
)
=>
{
const
{
field
,
title
}
=
JSON
.
parse
(
fieldStr
)
defaultFieldsPermission
.
push
({
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
:
'1'
// 只读
})
// 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
defaultFieldsPermission
}
return
{
...
...
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