【功能优化】条件节点:条件增加发起人选项
parent
0924f50266
commit
756addd423
|
@ -147,7 +147,7 @@ export enum CandidateStrategy {
|
||||||
USER_GROUP = 40,
|
USER_GROUP = 40,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单内成员字段
|
* 表单内用户字段
|
||||||
*/
|
*/
|
||||||
USER_FIELD_ON_FORM = 50,
|
USER_FIELD_ON_FORM = 50,
|
||||||
/**
|
/**
|
||||||
|
@ -429,7 +429,7 @@ export const CANDIDATE_STRATEGY: DictDataVO[] = [
|
||||||
{ label: '发起人部门负责人', value: CandidateStrategy.START_USER_DEPT_LEADER },
|
{ label: '发起人部门负责人', value: CandidateStrategy.START_USER_DEPT_LEADER },
|
||||||
{ label: '发起人连续部门负责人', value: CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER },
|
{ label: '发起人连续部门负责人', value: CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER },
|
||||||
{ label: '用户组', value: CandidateStrategy.USER_GROUP },
|
{ label: '用户组', value: CandidateStrategy.USER_GROUP },
|
||||||
{ label: '表单内成员字段', value: CandidateStrategy.USER_FIELD_ON_FORM },
|
{ label: '表单内用户字段', value: CandidateStrategy.USER_FIELD_ON_FORM },
|
||||||
{ label: '流程表达式', value: CandidateStrategy.EXPRESSION }
|
{ label: '流程表达式', value: CandidateStrategy.EXPRESSION }
|
||||||
]
|
]
|
||||||
// 审批节点 的审批类型
|
// 审批节点 的审批类型
|
||||||
|
@ -554,3 +554,13 @@ export const MULTI_LEVEL_DEPT: DictDataVO = [
|
||||||
{ label: '第 14 级部门', value: 14 },
|
{ label: '第 14 级部门', value: 14 },
|
||||||
{ label: '第 15 级部门', value: 15 }
|
{ label: '第 15 级部门', value: 15 }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程实例的变量枚举
|
||||||
|
*/
|
||||||
|
export enum ProcessVariableEnum {
|
||||||
|
/**
|
||||||
|
* 发起用户 ID
|
||||||
|
*/
|
||||||
|
START_USER_ID = 'PROCESS_START_USER_ID'
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ import {
|
||||||
NODE_DEFAULT_NAME,
|
NODE_DEFAULT_NAME,
|
||||||
AssignStartUserHandlerType,
|
AssignStartUserHandlerType,
|
||||||
AssignEmptyHandlerType,
|
AssignEmptyHandlerType,
|
||||||
FieldPermissionType
|
FieldPermissionType,
|
||||||
|
ProcessVariableEnum
|
||||||
} from './consts'
|
} from './consts'
|
||||||
export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlowNode> {
|
export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlowNode> {
|
||||||
const node = ref<SimpleFlowNode>(props.flowNode)
|
const node = ref<SimpleFlowNode>(props.flowNode)
|
||||||
|
@ -27,6 +28,61 @@ export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlo
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解析 formCreate 所有表单字段, 并返回
|
||||||
|
const parseFormCreateFields = (formFields?: string[]) => {
|
||||||
|
const result: Array<Record<string, any>> = []
|
||||||
|
if (formFields) {
|
||||||
|
formFields.forEach((fieldStr: string) => {
|
||||||
|
parseFields(JSON.parse(fieldStr), result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 固定添加发起人 ID 字段
|
||||||
|
result.unshift( {
|
||||||
|
field: ProcessVariableEnum.START_USER_ID,
|
||||||
|
title: '发起人',
|
||||||
|
type: 'UserSelect',
|
||||||
|
required: true
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseFields = (
|
||||||
|
rule: Record<string, any>,
|
||||||
|
fields: Array<Record<string, any>>,
|
||||||
|
parentTitle: string = ''
|
||||||
|
) => {
|
||||||
|
const { type, field, $required, title: tempTitle, children } = rule
|
||||||
|
if (field && tempTitle) {
|
||||||
|
let title = tempTitle
|
||||||
|
if (parentTitle) {
|
||||||
|
title = `${parentTitle}.${tempTitle}`
|
||||||
|
}
|
||||||
|
let required = false;
|
||||||
|
if($required) {
|
||||||
|
required = true;
|
||||||
|
}
|
||||||
|
fields.push({
|
||||||
|
field,
|
||||||
|
title,
|
||||||
|
type,
|
||||||
|
required
|
||||||
|
})
|
||||||
|
// TODO 子表单 需要处理子表单字段
|
||||||
|
// if (type === 'group' && rule.props?.rule && Array.isArray(rule.props.rule)) {
|
||||||
|
// // 解析子表单的字段
|
||||||
|
// rule.props.rule.forEach((item) => {
|
||||||
|
// parseFields(item, fieldsPermission, title)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
if (children && Array.isArray(children)) {
|
||||||
|
children.forEach((rule) => {
|
||||||
|
parseFields(rule, fields)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 表单数据权限配置,用于发起人节点 、审批节点、抄送节点
|
* @description 表单数据权限配置,用于发起人节点 、审批节点、抄送节点
|
||||||
*/
|
*/
|
||||||
|
@ -57,51 +113,8 @@ export function useFormFieldsPermission(defaultPermission: FieldPermissionType)
|
||||||
}
|
}
|
||||||
return defaultFieldsPermission
|
return defaultFieldsPermission
|
||||||
}
|
}
|
||||||
// 解析 formCreate 所有表单字段, 并返回
|
|
||||||
const parseFormCreateFields = (formFields?: string[]) => {
|
|
||||||
const result: Array<Record<string, any>> = []
|
|
||||||
if (formFields) {
|
|
||||||
formFields.forEach((fieldStr: string) => {
|
|
||||||
parseFields(JSON.parse(fieldStr), result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
const parseFields = (
|
|
||||||
rule: Record<string, any>,
|
|
||||||
fields: Array<Record<string, any>>,
|
|
||||||
parentTitle: string = ''
|
|
||||||
) => {
|
|
||||||
const { type, field, $required, title: tempTitle, children } = rule
|
|
||||||
if (field && tempTitle) {
|
|
||||||
let title = tempTitle
|
|
||||||
if (parentTitle) {
|
|
||||||
title = `${parentTitle}.${tempTitle}`
|
|
||||||
}
|
|
||||||
let required = false;
|
|
||||||
if($required) {
|
|
||||||
required = true;
|
|
||||||
}
|
|
||||||
fields.push({
|
|
||||||
field,
|
|
||||||
title,
|
|
||||||
type,
|
|
||||||
required
|
|
||||||
})
|
|
||||||
// TODO 子表单 需要处理子表单字段
|
|
||||||
// if (type === 'group' && rule.props?.rule && Array.isArray(rule.props.rule)) {
|
|
||||||
// // 解析子表单的字段
|
|
||||||
// rule.props.rule.forEach((item) => {
|
|
||||||
// parseFields(item, fieldsPermission, title)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
if (children && Array.isArray(children)) {
|
|
||||||
children.forEach((rule) => {
|
|
||||||
parseFields(rule, fields)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取表单的所有字段,作为下拉框选项
|
// 获取表单的所有字段,作为下拉框选项
|
||||||
const formFieldOptions = parseFormCreateFields(unref(formFields))
|
const formFieldOptions = parseFormCreateFields(unref(formFields))
|
||||||
|
@ -117,50 +130,8 @@ export function useFormFieldsPermission(defaultPermission: FieldPermissionType)
|
||||||
* @description 获取表单的字段
|
* @description 获取表单的字段
|
||||||
*/
|
*/
|
||||||
export function useFormFields() {
|
export function useFormFields() {
|
||||||
// 解析后的表单字段
|
|
||||||
const formFields = inject<Ref<string[]>>('formFields') // 流程表单字段
|
const formFields = inject<Ref<string[]>>('formFields') // 流程表单字段
|
||||||
const parseFormFields = () => {
|
return parseFormCreateFields(unref(formFields))
|
||||||
const parsedFormFields: Array<Record<string, string>> = []
|
|
||||||
if (formFields) {
|
|
||||||
formFields.value.forEach((fieldStr: string) => {
|
|
||||||
parseField(JSON.parse(fieldStr), parsedFormFields)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return parsedFormFields
|
|
||||||
}
|
|
||||||
// 解析字段。
|
|
||||||
const parseField = (
|
|
||||||
rule: Record<string, any>,
|
|
||||||
parsedFormFields: Array<Record<string, string>>,
|
|
||||||
parentTitle: string = ''
|
|
||||||
) => {
|
|
||||||
const { field, title: tempTitle, children, type } = rule
|
|
||||||
if (field && tempTitle) {
|
|
||||||
let title = tempTitle
|
|
||||||
if (parentTitle) {
|
|
||||||
title = `${parentTitle}.${tempTitle}`
|
|
||||||
}
|
|
||||||
parsedFormFields.push({
|
|
||||||
field,
|
|
||||||
title,
|
|
||||||
type
|
|
||||||
})
|
|
||||||
// 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) => {
|
|
||||||
parseField(rule, parsedFormFields)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseFormFields()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UserTaskFormType = {
|
export type UserTaskFormType = {
|
||||||
|
@ -174,7 +145,7 @@ export type UserTaskFormType = {
|
||||||
userGroups?: number[] // 用户组
|
userGroups?: number[] // 用户组
|
||||||
postIds?: number[] // 岗位
|
postIds?: number[] // 岗位
|
||||||
expression?: string // 流程表达式
|
expression?: string // 流程表达式
|
||||||
userFieldOnForm?: string // 表单内成员字段
|
userFieldOnForm?: string // 表单内用户字段
|
||||||
approveRatio?: number
|
approveRatio?: number
|
||||||
rejectHandlerType?: RejectHandlerType
|
rejectHandlerType?: RejectHandlerType
|
||||||
returnNodeId?: string
|
returnNodeId?: string
|
||||||
|
@ -197,7 +168,7 @@ export type CopyTaskFormType = {
|
||||||
userIds?: number[] // 用户
|
userIds?: number[] // 用户
|
||||||
userGroups?: number[] // 用户组
|
userGroups?: number[] // 用户组
|
||||||
postIds?: number[] // 岗位
|
postIds?: number[] // 岗位
|
||||||
userFieldOnForm?: string // 表单内成员字段
|
userFieldOnForm?: string // 表单内用户字段
|
||||||
expression?: string // 流程表达式
|
expression?: string // 流程表达式
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +182,7 @@ export function useNodeForm(nodeType: NodeType) {
|
||||||
const deptOptions = inject<Ref<DeptApi.DeptVO[]>>('deptList') // 部门列表
|
const deptOptions = inject<Ref<DeptApi.DeptVO[]>>('deptList') // 部门列表
|
||||||
const userGroupOptions = inject<Ref<UserGroupApi.UserGroupVO[]>>('userGroupList') // 用户组列表
|
const userGroupOptions = inject<Ref<UserGroupApi.UserGroupVO[]>>('userGroupList') // 用户组列表
|
||||||
const deptTreeOptions = inject('deptTree') // 部门树
|
const deptTreeOptions = inject('deptTree') // 部门树
|
||||||
|
const formFields = inject<Ref<string[]>>('formFields') // 流程表单字段
|
||||||
const configForm = ref<UserTaskFormType | CopyTaskFormType>()
|
const configForm = ref<UserTaskFormType | CopyTaskFormType>()
|
||||||
if (nodeType === NodeType.USER_TASK_NODE) {
|
if (nodeType === NodeType.USER_TASK_NODE) {
|
||||||
configForm.value = {
|
configForm.value = {
|
||||||
|
@ -306,9 +278,11 @@ export function useNodeForm(nodeType: NodeType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单内成员字段
|
// 表单内用户字段
|
||||||
if (configForm.value?.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM) {
|
if (configForm.value?.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM) {
|
||||||
showText = `表单内用户字段`
|
const formFieldOptions = parseFormCreateFields(unref(formFields))
|
||||||
|
const item = formFieldOptions.find((item) => item.field === configForm.value?.userFieldOnForm)
|
||||||
|
showText = `表单用户:${item?.title}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发起人自选
|
// 发起人自选
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
||||||
label="表单内成员字段"
|
label="表单内用户字段"
|
||||||
prop="userFieldOnForm"
|
prop="userFieldOnForm"
|
||||||
>
|
>
|
||||||
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
||||||
|
@ -246,7 +246,7 @@ const activeTabName = ref('user')
|
||||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
||||||
FieldPermissionType.READ
|
FieldPermissionType.READ
|
||||||
)
|
)
|
||||||
// 表单内成员字段选项, 必须是必填和用户选择器
|
// 表单内用户字段选项, 必须是必填和用户选择器
|
||||||
const userFieldOnFormOptions = computed(() => {
|
const userFieldOnFormOptions = computed(() => {
|
||||||
return formFieldOptions.filter(
|
return formFieldOptions.filter(
|
||||||
(item) => item.required && item.type === 'UserSelect'
|
(item) => item.required && item.type === 'UserSelect'
|
||||||
|
@ -262,7 +262,7 @@ const formRules = reactive({
|
||||||
deptIds: [{ required: true, message: '部门不能为空', trigger: 'change' }],
|
deptIds: [{ required: true, message: '部门不能为空', trigger: 'change' }],
|
||||||
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
|
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
|
||||||
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
|
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
|
||||||
userFieldOnForm: [{ required: true, message: '表单内成员字段为空', trigger: 'change' }],
|
userFieldOnForm: [{ required: true, message: '表单内用户字段不能为空', trigger: 'change' }],
|
||||||
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }]
|
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
||||||
label="表单内成员字段"
|
label="表单内用户字段"
|
||||||
prop="userFieldOnForm"
|
prop="userFieldOnForm"
|
||||||
>
|
>
|
||||||
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
||||||
|
@ -499,7 +499,7 @@ const activeTabName = ref('user')
|
||||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
||||||
FieldPermissionType.READ
|
FieldPermissionType.READ
|
||||||
)
|
)
|
||||||
// 表单内成员字段选项, 必须是必填和用户选择器
|
// 表单内用户字段选项, 必须是必填和用户选择器
|
||||||
const userFieldOnFormOptions = computed(() => {
|
const userFieldOnFormOptions = computed(() => {
|
||||||
return formFieldOptions.filter(
|
return formFieldOptions.filter(
|
||||||
(item) => item.required && item.type === 'UserSelect'
|
(item) => item.required && item.type === 'UserSelect'
|
||||||
|
@ -518,7 +518,7 @@ const formRules = reactive({
|
||||||
roleIds: [{ required: true, message: '角色不能为空', trigger: 'change' }],
|
roleIds: [{ required: true, message: '角色不能为空', trigger: 'change' }],
|
||||||
deptIds: [{ required: true, message: '部门不能为空', trigger: 'change' }],
|
deptIds: [{ required: true, message: '部门不能为空', trigger: 'change' }],
|
||||||
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
|
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
|
||||||
userFieldOnForm: [{ required: true, message: '表单内成员字段为空', trigger: 'change' }],
|
userFieldOnForm: [{ required: true, message: '表单内用户字段不能为空', trigger: 'change' }],
|
||||||
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
|
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
|
||||||
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }],
|
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }],
|
||||||
approveMethod: [{ required: true, message: '多人审批方式不能为空', trigger: 'change' }],
|
approveMethod: [{ required: true, message: '多人审批方式不能为空', trigger: 'change' }],
|
||||||
|
|
Loading…
Reference in New Issue