| | |
| | | import { cloneDeep } from 'lodash-es' |
| | | import { TaskStatusEnum } from '@/api/bpm/task' |
| | | import * as RoleApi from '@/api/system/role' |
| | | import * as DeptApi from '@/api/system/dept' |
| | |
| | | NODE_DEFAULT_NAME, |
| | | AssignStartUserHandlerType, |
| | | AssignEmptyHandlerType, |
| | | FieldPermissionType, |
| | | FieldPermissionType |
| | | } from './consts' |
| | | import { parseFormFields } from '@/components/FormCreate/src/utils/index' |
| | | export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlowNode> { |
| | |
| | | |
| | | const getNodeConfigFormFields = (nodeFormFields?: Array<Record<string, string>>) => { |
| | | nodeFormFields = toRaw(nodeFormFields) |
| | | fieldsPermissionConfig.value = |
| | | cloneDeep(nodeFormFields) || getDefaultFieldsPermission(unref(formFields)) |
| | | if (!nodeFormFields || nodeFormFields.length === 0) { |
| | | fieldsPermissionConfig.value = getDefaultFieldsPermission(unref(formFields)) |
| | | } else { |
| | | fieldsPermissionConfig.value = mergeFieldsPermission(nodeFormFields, unref(formFields)) |
| | | } |
| | | } |
| | | // 合并已经设置的表单字段权限,当前流程表单字段 (可能新增,或删除了字段) |
| | | const mergeFieldsPermission = ( |
| | | formFieldsPermisson: Array<Record<string, string>>, |
| | | formFields?: string[] |
| | | ) => { |
| | | let mergedFieldsPermission: Array<Record<string, any>> = [] |
| | | if (formFields) { |
| | | mergedFieldsPermission = parseFormCreateFields(formFields).map((item) => { |
| | | const found = formFieldsPermisson.find( |
| | | (fieldPermission) => fieldPermission.field == item.field |
| | | ) |
| | | return { |
| | | field: item.field, |
| | | title: item.title, |
| | | permission: found ? found.permission : defaultPermission |
| | | } |
| | | }) |
| | | } |
| | | return mergedFieldsPermission |
| | | } |
| | | |
| | | // 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读 |
| | | const getDefaultFieldsPermission = (formFields?: string[]) => { |
| | | let defaultFieldsPermission: Array<Record<string, any>> = [] |