【代码评审】工作流:表单选择审批人

pull/586/MERGE
YunaiV 2024-11-19 21:24:11 +08:00
parent 158708c1b1
commit 12bd71e70b
5 changed files with 54 additions and 65 deletions

View File

@ -185,7 +185,6 @@ export const useApiSelect = (option: ApiSelectProps) => {
</el-select> </el-select>
) )
} }
// debugger
return ( return (
<el-select <el-select
class="w-1/1" class="w-1/1"

View File

@ -97,7 +97,7 @@ export interface SimpleFlowNode {
// 是否默认的条件 // 是否默认的条件
defaultFlow?: boolean defaultFlow?: boolean
// 活动的状态,用于前端节点状态展示 // 活动的状态,用于前端节点状态展示
activityStatus? : TaskStatusEnum activityStatus?: TaskStatusEnum
} }
// 候选人策略枚举 用于审批节点。抄送节点 ) // 候选人策略枚举 用于审批节点。抄送节点 )
export enum CandidateStrategy { export enum CandidateStrategy {
@ -145,14 +145,14 @@ export enum CandidateStrategy {
* *
*/ */
USER_GROUP = 40, USER_GROUP = 40,
/** /**
* *
*/ */
USER_FIELD_ON_FORM = 50, FORM_USER = 50,
/** /**
* *
*/ */
DEPT_LEADER_ON_FORM = 51, FORM_DEPT_LEADER = 51,
/** /**
* *
*/ */
@ -432,8 +432,8 @@ 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.FORM_USER },
{ label: '表单内部门负责人', value: CandidateStrategy.DEPT_LEADER_ON_FORM }, { label: '表单内部门负责人', value: CandidateStrategy.FORM_DEPT_LEADER },
{ label: '流程表达式', value: CandidateStrategy.EXPRESSION } { label: '流程表达式', value: CandidateStrategy.EXPRESSION }
] ]
// 审批节点 的审批类型 // 审批节点 的审批类型

View File

@ -37,7 +37,7 @@ const parseFormCreateFields = (formFields?: string[]) => {
}) })
} }
// 固定添加发起人 ID 字段 // 固定添加发起人 ID 字段
result.unshift( { result.unshift({
field: ProcessVariableEnum.START_USER_ID, field: ProcessVariableEnum.START_USER_ID,
title: '发起人', title: '发起人',
type: 'UserSelect', type: 'UserSelect',
@ -46,6 +46,7 @@ const parseFormCreateFields = (formFields?: string[]) => {
return result return result
} }
// TODO @jasonparse 方法,是不是搞到 formCreate.ts。统一维护管理
const parseFields = ( const parseFields = (
rule: Record<string, any>, rule: Record<string, any>,
fields: Array<Record<string, any>>, fields: Array<Record<string, any>>,
@ -57,9 +58,10 @@ const parseFields = (
if (parentTitle) { if (parentTitle) {
title = `${parentTitle}.${tempTitle}` title = `${parentTitle}.${tempTitle}`
} }
let required = false; // TODO @jason按照微信讨论的非 $required 显示,但是 disable 不可选择
if($required) { let required = false
required = true; if ($required) {
required = true
} }
fields.push({ fields.push({
field, field,
@ -82,7 +84,6 @@ const parseFields = (
} }
} }
/** /**
* @description * @description
*/ */
@ -103,19 +104,17 @@ export function useFormFieldsPermission(defaultPermission: FieldPermissionType)
const getDefaultFieldsPermission = (formFields?: string[]) => { const getDefaultFieldsPermission = (formFields?: string[]) => {
let defaultFieldsPermission: Array<Record<string, any>> = [] let defaultFieldsPermission: Array<Record<string, any>> = []
if (formFields) { if (formFields) {
defaultFieldsPermission = parseFormCreateFields(formFields).map( item => { defaultFieldsPermission = parseFormCreateFields(formFields).map((item) => {
return { return {
field: item.field, field: item.field,
title: item.title, title: item.title,
permission: defaultPermission permission: defaultPermission
} }
}); })
} }
return defaultFieldsPermission return defaultFieldsPermission
} }
// 获取表单的所有字段,作为下拉框选项 // 获取表单的所有字段,作为下拉框选项
const formFieldOptions = parseFormCreateFields(unref(formFields)) const formFieldOptions = parseFormCreateFields(unref(formFields))
@ -281,14 +280,14 @@ export function useNodeForm(nodeType: NodeType) {
} }
// 表单内用户字段 // 表单内用户字段
if (configForm.value?.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM) { if (configForm.value?.candidateStrategy === CandidateStrategy.FORM_USER) {
const formFieldOptions = parseFormCreateFields(unref(formFields)) const formFieldOptions = parseFormCreateFields(unref(formFields))
const item = formFieldOptions.find((item) => item.field === configForm.value?.userFieldOnForm) const item = formFieldOptions.find((item) => item.field === configForm.value?.userFieldOnForm)
showText = `表单用户:${item?.title}` showText = `表单用户:${item?.title}`
} }
// 表单内部门负责人 // 表单内部门负责人
if (configForm.value?.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM) { if (configForm.value?.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER) {
showText = `表单内部门负责人` showText = `表单内部门负责人`
} }
@ -338,7 +337,7 @@ export function useNodeForm(nodeType: NodeType) {
case CandidateStrategy.USER_GROUP: case CandidateStrategy.USER_GROUP:
candidateParam = configForm.value.userGroups!.join(',') candidateParam = configForm.value.userGroups!.join(',')
break break
case CandidateStrategy.USER_FIELD_ON_FORM: case CandidateStrategy.FORM_USER:
candidateParam = configForm.value.userFieldOnForm! candidateParam = configForm.value.userFieldOnForm!
break break
case CandidateStrategy.EXPRESSION: case CandidateStrategy.EXPRESSION:
@ -361,7 +360,7 @@ export function useNodeForm(nodeType: NodeType) {
break break
} }
// 表单内部门的负责人 // 表单内部门的负责人
case CandidateStrategy.DEPT_LEADER_ON_FORM: { case CandidateStrategy.FORM_DEPT_LEADER: {
// 候选人参数格式: | 分隔 。左边为表单内部门字段。 右边为部门层级 // 候选人参数格式: | 分隔 。左边为表单内部门字段。 右边为部门层级
const deptFieldOnForm = configForm.value.deptFieldOnForm! const deptFieldOnForm = configForm.value.deptFieldOnForm!
candidateParam = deptFieldOnForm.concat('|' + configForm.value.deptLevel + '') candidateParam = deptFieldOnForm.concat('|' + configForm.value.deptLevel + '')
@ -396,7 +395,7 @@ export function useNodeForm(nodeType: NodeType) {
case CandidateStrategy.USER_GROUP: case CandidateStrategy.USER_GROUP:
configForm.value.userGroups = candidateParam.split(',').map((item) => +item) configForm.value.userGroups = candidateParam.split(',').map((item) => +item)
break break
case CandidateStrategy.USER_FIELD_ON_FORM: case CandidateStrategy.FORM_USER:
configForm.value.userFieldOnForm = candidateParam configForm.value.userFieldOnForm = candidateParam
break break
case CandidateStrategy.EXPRESSION: case CandidateStrategy.EXPRESSION:
@ -420,7 +419,7 @@ export function useNodeForm(nodeType: NodeType) {
break break
} }
// 表单内的部门负责人 // 表单内的部门负责人
case CandidateStrategy.DEPT_LEADER_ON_FORM: { case CandidateStrategy.FORM_DEPT_LEADER: {
// 候选人参数格式: | 分隔 。左边为表单内的部门字段。 右边为部门层级 // 候选人参数格式: | 分隔 。左边为表单内的部门字段。 右边为部门层级
const paramArray = candidateParam.split('|') const paramArray = candidateParam.split('|')
configForm.value.deptFieldOnForm = paramArray[0] configForm.value.deptFieldOnForm = paramArray[0]
@ -512,22 +511,22 @@ export function useNodeName2(node: Ref<SimpleFlowNode>, nodeType: NodeType) {
/** /**
* @description * @description
*/ */
export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined) : string { export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): string {
if (!taskStatus) { if (!taskStatus) {
return '' return ''
} }
if (taskStatus === TaskStatusEnum.APPROVE ) { if (taskStatus === TaskStatusEnum.APPROVE) {
return 'status-pass' return 'status-pass'
} }
if (taskStatus === TaskStatusEnum.RUNNING ) { if (taskStatus === TaskStatusEnum.RUNNING) {
return 'status-running' return 'status-running'
} }
if (taskStatus === TaskStatusEnum.REJECT ) { if (taskStatus === TaskStatusEnum.REJECT) {
return 'status-reject' return 'status-reject'
} }
if (taskStatus === TaskStatusEnum.CANCEL ) { if (taskStatus === TaskStatusEnum.CANCEL) {
return 'status-cancel' return 'status-cancel'
} }
return ''; return ''
} }

View File

@ -124,13 +124,13 @@
</el-select> </el-select>
</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.FORM_USER"
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%">
<el-option <el-option
v-for="(item,idx) in userFieldOnFormOptions" v-for="(item, idx) in userFieldOnFormOptions"
:key="idx" :key="idx"
:label="item.title" :label="item.title"
:value="item.field" :value="item.field"
@ -138,13 +138,13 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM" v-if="configForm.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER"
label="表单内部门字段" label="表单内部门字段"
prop="deptFieldOnForm" prop="deptFieldOnForm"
> >
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%"> <el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
<el-option <el-option
v-for="(item,idx) in deptFieldOnFormOptions" v-for="(item, idx) in deptFieldOnFormOptions"
:key="idx" :key="idx"
:label="item.title" :label="item.title"
:value="item.field" :value="item.field"
@ -155,8 +155,9 @@
v-if=" v-if="
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER || configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER || configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER || configForm.candidateStrategy ==
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER
" "
:label="deptLevelLabel!" :label="deptLevelLabel!"
prop="deptLevel" prop="deptLevel"
@ -288,20 +289,15 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.COPY_
// Tab // Tab
const activeTabName = ref('user') const activeTabName = ref('user')
// //
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission( const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } =
FieldPermissionType.READ useFormFieldsPermission(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'
)
}) })
// , // ,
const deptFieldOnFormOptions = computed(() => { const deptFieldOnFormOptions = computed(() => {
return formFieldOptions.filter( return formFieldOptions.filter((item) => item.required && item.type === 'DeptSelect')
(item) => item.required && item.type === 'DeptSelect'
)
}) })
// //
const formRef = ref() // Ref const formRef = ref() // Ref
@ -332,9 +328,7 @@ const {
const configForm = tempConfigForm as Ref<CopyTaskFormType> const configForm = tempConfigForm as Ref<CopyTaskFormType>
// //
const copyUserStrategies = computed(() => { const copyUserStrategies = computed(() => {
return CANDIDATE_STRATEGY.filter( return CANDIDATE_STRATEGY.filter((item) => item.value !== CandidateStrategy.START_USER)
(item) => item.value !== CandidateStrategy.START_USER
)
}) })
// //
const changeCandidateStrategy = () => { const changeCandidateStrategy = () => {

View File

@ -138,13 +138,13 @@
</el-select> </el-select>
</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.FORM_USER"
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%">
<el-option <el-option
v-for="(item,idx) in userFieldOnFormOptions" v-for="(item, idx) in userFieldOnFormOptions"
:key="idx" :key="idx"
:label="item.title" :label="item.title"
:value="item.field" :value="item.field"
@ -152,13 +152,13 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM" v-if="configForm.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER"
label="表单内部门字段" label="表单内部门字段"
prop="deptFieldOnForm" prop="deptFieldOnForm"
> >
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%"> <el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
<el-option <el-option
v-for="(item,idx) in deptFieldOnFormOptions" v-for="(item, idx) in deptFieldOnFormOptions"
:key="idx" :key="idx"
:label="item.title" :label="item.title"
:value="item.field" :value="item.field"
@ -169,8 +169,9 @@
v-if=" v-if="
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER || configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER || configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER || configForm.candidateStrategy ==
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
configForm.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER
" "
:label="deptLevelLabel!" :label="deptLevelLabel!"
prop="deptLevel" prop="deptLevel"
@ -496,10 +497,10 @@ const deptLevelLabel = computed(() => {
let label = '部门负责人来源' let label = '部门负责人来源'
if (configForm.value.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER) { if (configForm.value.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER) {
label = label + '(指定部门向上)' label = label + '(指定部门向上)'
} else if (configForm.value.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM) { } else if (configForm.value.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER) {
label = label + '(表单内部门向上)' label = label + '(表单内部门向上)'
} else { } else {
label = label + '(发起人部门向上)' label = label + '(发起人部门向上)'
} }
return label return label
}) })
@ -512,20 +513,15 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.USER_
// Tab // Tab
const activeTabName = ref('user') const activeTabName = ref('user')
// //
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission( const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } =
FieldPermissionType.READ useFormFieldsPermission(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'
)
}) })
// , // ,
const deptFieldOnFormOptions = computed(() => { const deptFieldOnFormOptions = computed(() => {
return formFieldOptions.filter( return formFieldOptions.filter((item) => item.required && item.type === 'DeptSelect')
(item) => item.required && item.type === 'DeptSelect'
)
}) })
// //
const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } = const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
@ -577,6 +573,7 @@ const changeCandidateStrategy = () => {
configForm.value.postIds = [] configForm.value.postIds = []
configForm.value.userGroups = [] configForm.value.userGroups = []
configForm.value.deptLevel = 1 configForm.value.deptLevel = 1
// TODO @jason userFieldOnForm => formUserdeptFieldOnForm => formDeptLeader
configForm.value.userFieldOnForm = '' configForm.value.userFieldOnForm = ''
configForm.value.deptFieldOnForm = '' configForm.value.deptFieldOnForm = ''
configForm.value.approveMethod = ApproveMethodType.SEQUENTIAL_APPROVE configForm.value.approveMethod = ApproveMethodType.SEQUENTIAL_APPROVE