From 7cb68da5b0ef11ea6221f51c33e3327917b12b3b Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Fri, 26 Jul 2024 21:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BF=E9=92=89=E9=92=89=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8-=20=E5=A4=8D=E6=9D=82=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=AD=97=E6=AE=B5=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleProcessDesignerV2/src/node.ts | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/components/SimpleProcessDesignerV2/src/node.ts b/src/components/SimpleProcessDesignerV2/src/node.ts index a2c47b1e..e41c9b83 100644 --- a/src/components/SimpleProcessDesignerV2/src/node.ts +++ b/src/components/SimpleProcessDesignerV2/src/node.ts @@ -39,21 +39,47 @@ export function useFormFieldsPermission() { fieldsPermissionConfig.value = cloneDeep(nodeFormFields) || getDefaultFieldsPermission(unref(formFields)) } - // 获取默认的表单权限。 所有字段只读 + // 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读 const getDefaultFieldsPermission = (formFields?: string[]) => { const defaultFieldsPermission: Array> = [] if (formFields) { formFields.forEach((fieldStr: string) => { - const { field, title } = JSON.parse(fieldStr) - defaultFieldsPermission.push({ - field, - title, - permission: '1' // 只读 - }) + parseFieldsSetDefaultPermission(JSON.parse(fieldStr), defaultFieldsPermission) }) } return defaultFieldsPermission } + // 解析字段。赋给默认权限 + const parseFieldsSetDefaultPermission = ( + rule: Record, + fieldsPermission: Array>, + 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 { formType,