diff --git a/src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue b/src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue index eae04778..ba385145 100644 --- a/src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue +++ b/src/components/bpmnProcessDesigner/package/penal/custom-config/components/UserTaskCustomConfig.vue @@ -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>>([]) - - const formType = inject>('formType') // 表单类型 - - const formFields = inject>('formFields') // 流程表单字段 - - const getNodeConfigFormFields = (nodeFormFields?: Array>) => { - nodeFormFields = toRaw(nodeFormFields) - fieldsPermissionConfig.value = - cloneDeep(nodeFormFields) || getDefaultFieldsPermission(unref(formFields)) - } - // 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读 - const getDefaultFieldsPermission = (formFields?: string[]) => { - const defaultFieldsPermission: Array> = [] - if (formFields) { - formFields.forEach((fieldStr: string) => { - 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: 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([]) // 用户列表 onMounted(async () => { // 获得用户列表