【代码评审】工作流:表单选择审批人
parent
158708c1b1
commit
12bd71e70b
|
@ -185,7 +185,6 @@ export const useApiSelect = (option: ApiSelectProps) => {
|
|||
</el-select>
|
||||
)
|
||||
}
|
||||
// debugger
|
||||
return (
|
||||
<el-select
|
||||
class="w-1/1"
|
||||
|
|
|
@ -97,7 +97,7 @@ export interface SimpleFlowNode {
|
|||
// 是否默认的条件
|
||||
defaultFlow?: boolean
|
||||
// 活动的状态,用于前端节点状态展示
|
||||
activityStatus? : TaskStatusEnum
|
||||
activityStatus?: TaskStatusEnum
|
||||
}
|
||||
// 候选人策略枚举 ( 用于审批节点。抄送节点 )
|
||||
export enum CandidateStrategy {
|
||||
|
@ -145,14 +145,14 @@ export enum CandidateStrategy {
|
|||
* 指定用户组
|
||||
*/
|
||||
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_MULTI_LEVEL_DEPT_LEADER },
|
||||
{ label: '用户组', value: CandidateStrategy.USER_GROUP },
|
||||
{ label: '表单内用户字段', value: CandidateStrategy.USER_FIELD_ON_FORM },
|
||||
{ label: '表单内部门负责人', value: CandidateStrategy.DEPT_LEADER_ON_FORM },
|
||||
{ label: '表单内用户字段', value: CandidateStrategy.FORM_USER },
|
||||
{ label: '表单内部门负责人', value: CandidateStrategy.FORM_DEPT_LEADER },
|
||||
{ label: '流程表达式', value: CandidateStrategy.EXPRESSION }
|
||||
]
|
||||
// 审批节点 的审批类型
|
||||
|
|
|
@ -37,7 +37,7 @@ const parseFormCreateFields = (formFields?: string[]) => {
|
|||
})
|
||||
}
|
||||
// 固定添加发起人 ID 字段
|
||||
result.unshift( {
|
||||
result.unshift({
|
||||
field: ProcessVariableEnum.START_USER_ID,
|
||||
title: '发起人',
|
||||
type: 'UserSelect',
|
||||
|
@ -46,6 +46,7 @@ const parseFormCreateFields = (formFields?: string[]) => {
|
|||
return result
|
||||
}
|
||||
|
||||
// TODO @jason:parse 方法,是不是搞到 formCreate.ts。统一维护管理
|
||||
const parseFields = (
|
||||
rule: Record<string, any>,
|
||||
fields: Array<Record<string, any>>,
|
||||
|
@ -57,9 +58,10 @@ const parseFields = (
|
|||
if (parentTitle) {
|
||||
title = `${parentTitle}.${tempTitle}`
|
||||
}
|
||||
let required = false;
|
||||
if($required) {
|
||||
required = true;
|
||||
// TODO @jason:按照微信讨论的,非 $required 显示,但是 disable 不可选择
|
||||
let required = false
|
||||
if ($required) {
|
||||
required = true
|
||||
}
|
||||
fields.push({
|
||||
field,
|
||||
|
@ -82,7 +84,6 @@ const parseFields = (
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 表单数据权限配置,用于发起人节点 、审批节点、抄送节点
|
||||
*/
|
||||
|
@ -103,19 +104,17 @@ export function useFormFieldsPermission(defaultPermission: FieldPermissionType)
|
|||
const getDefaultFieldsPermission = (formFields?: string[]) => {
|
||||
let defaultFieldsPermission: Array<Record<string, any>> = []
|
||||
if (formFields) {
|
||||
defaultFieldsPermission = parseFormCreateFields(formFields).map( item => {
|
||||
defaultFieldsPermission = parseFormCreateFields(formFields).map((item) => {
|
||||
return {
|
||||
field: item.field,
|
||||
title: item.title,
|
||||
permission: defaultPermission
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
return defaultFieldsPermission
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取表单的所有字段,作为下拉框选项
|
||||
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 item = formFieldOptions.find((item) => item.field === configForm.value?.userFieldOnForm)
|
||||
showText = `表单用户:${item?.title}`
|
||||
}
|
||||
|
||||
// 表单内部门负责人
|
||||
if (configForm.value?.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM) {
|
||||
if (configForm.value?.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER) {
|
||||
showText = `表单内部门负责人`
|
||||
}
|
||||
|
||||
|
@ -338,7 +337,7 @@ export function useNodeForm(nodeType: NodeType) {
|
|||
case CandidateStrategy.USER_GROUP:
|
||||
candidateParam = configForm.value.userGroups!.join(',')
|
||||
break
|
||||
case CandidateStrategy.USER_FIELD_ON_FORM:
|
||||
case CandidateStrategy.FORM_USER:
|
||||
candidateParam = configForm.value.userFieldOnForm!
|
||||
break
|
||||
case CandidateStrategy.EXPRESSION:
|
||||
|
@ -361,7 +360,7 @@ export function useNodeForm(nodeType: NodeType) {
|
|||
break
|
||||
}
|
||||
// 表单内部门的负责人
|
||||
case CandidateStrategy.DEPT_LEADER_ON_FORM: {
|
||||
case CandidateStrategy.FORM_DEPT_LEADER: {
|
||||
// 候选人参数格式: | 分隔 。左边为表单内部门字段。 右边为部门层级
|
||||
const deptFieldOnForm = configForm.value.deptFieldOnForm!
|
||||
candidateParam = deptFieldOnForm.concat('|' + configForm.value.deptLevel + '')
|
||||
|
@ -396,7 +395,7 @@ export function useNodeForm(nodeType: NodeType) {
|
|||
case CandidateStrategy.USER_GROUP:
|
||||
configForm.value.userGroups = candidateParam.split(',').map((item) => +item)
|
||||
break
|
||||
case CandidateStrategy.USER_FIELD_ON_FORM:
|
||||
case CandidateStrategy.FORM_USER:
|
||||
configForm.value.userFieldOnForm = candidateParam
|
||||
break
|
||||
case CandidateStrategy.EXPRESSION:
|
||||
|
@ -420,7 +419,7 @@ export function useNodeForm(nodeType: NodeType) {
|
|||
break
|
||||
}
|
||||
// 表单内的部门负责人
|
||||
case CandidateStrategy.DEPT_LEADER_ON_FORM: {
|
||||
case CandidateStrategy.FORM_DEPT_LEADER: {
|
||||
// 候选人参数格式: | 分隔 。左边为表单内的部门字段。 右边为部门层级
|
||||
const paramArray = candidateParam.split('|')
|
||||
configForm.value.deptFieldOnForm = paramArray[0]
|
||||
|
@ -512,22 +511,22 @@ export function useNodeName2(node: Ref<SimpleFlowNode>, nodeType: NodeType) {
|
|||
/**
|
||||
* @description 根据节点任务状态,获取节点任务状态样式
|
||||
*/
|
||||
export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined) : string {
|
||||
export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): string {
|
||||
if (!taskStatus) {
|
||||
return ''
|
||||
}
|
||||
if (taskStatus === TaskStatusEnum.APPROVE ) {
|
||||
if (taskStatus === TaskStatusEnum.APPROVE) {
|
||||
return 'status-pass'
|
||||
}
|
||||
if (taskStatus === TaskStatusEnum.RUNNING ) {
|
||||
if (taskStatus === TaskStatusEnum.RUNNING) {
|
||||
return 'status-running'
|
||||
}
|
||||
if (taskStatus === TaskStatusEnum.REJECT ) {
|
||||
if (taskStatus === TaskStatusEnum.REJECT) {
|
||||
return 'status-reject'
|
||||
}
|
||||
if (taskStatus === TaskStatusEnum.CANCEL ) {
|
||||
if (taskStatus === TaskStatusEnum.CANCEL) {
|
||||
return 'status-cancel'
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
return ''
|
||||
}
|
||||
|
|
|
@ -124,13 +124,13 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.FORM_USER"
|
||||
label="表单内用户字段"
|
||||
prop="userFieldOnForm"
|
||||
>
|
||||
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="(item,idx) in userFieldOnFormOptions"
|
||||
v-for="(item, idx) in userFieldOnFormOptions"
|
||||
:key="idx"
|
||||
:label="item.title"
|
||||
:value="item.field"
|
||||
|
@ -138,13 +138,13 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM"
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER"
|
||||
label="表单内部门字段"
|
||||
prop="deptFieldOnForm"
|
||||
>
|
||||
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="(item,idx) in deptFieldOnFormOptions"
|
||||
v-for="(item, idx) in deptFieldOnFormOptions"
|
||||
:key="idx"
|
||||
:label="item.title"
|
||||
:value="item.field"
|
||||
|
@ -155,8 +155,9 @@
|
|||
v-if="
|
||||
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM
|
||||
configForm.candidateStrategy ==
|
||||
CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER
|
||||
"
|
||||
:label="deptLevelLabel!"
|
||||
prop="deptLevel"
|
||||
|
@ -288,20 +289,15 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.COPY_
|
|||
// 激活的 Tab 标签页
|
||||
const activeTabName = ref('user')
|
||||
// 表单字段权限配置
|
||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
||||
FieldPermissionType.READ
|
||||
)
|
||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } =
|
||||
useFormFieldsPermission(FieldPermissionType.READ)
|
||||
// 表单内用户字段选项, 必须是必填和用户选择器
|
||||
const userFieldOnFormOptions = computed(() => {
|
||||
return formFieldOptions.filter(
|
||||
(item) => item.required && item.type === 'UserSelect'
|
||||
)
|
||||
return formFieldOptions.filter((item) => item.required && item.type === 'UserSelect')
|
||||
})
|
||||
// 表单内部门字段选项, 必须是必填和部门选择器
|
||||
const deptFieldOnFormOptions = computed(() => {
|
||||
return formFieldOptions.filter(
|
||||
(item) => item.required && item.type === 'DeptSelect'
|
||||
)
|
||||
return formFieldOptions.filter((item) => item.required && item.type === 'DeptSelect')
|
||||
})
|
||||
// 抄送人表单配置
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
@ -332,9 +328,7 @@ const {
|
|||
const configForm = tempConfigForm as Ref<CopyTaskFormType>
|
||||
// 抄送人策略, 去掉发起人自选 和 发起人自己
|
||||
const copyUserStrategies = computed(() => {
|
||||
return CANDIDATE_STRATEGY.filter(
|
||||
(item) => item.value !== CandidateStrategy.START_USER
|
||||
)
|
||||
return CANDIDATE_STRATEGY.filter((item) => item.value !== CandidateStrategy.START_USER)
|
||||
})
|
||||
// 改变抄送人设置策略
|
||||
const changeCandidateStrategy = () => {
|
||||
|
|
|
@ -138,13 +138,13 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.USER_FIELD_ON_FORM"
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.FORM_USER"
|
||||
label="表单内用户字段"
|
||||
prop="userFieldOnForm"
|
||||
>
|
||||
<el-select v-model="configForm.userFieldOnForm" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="(item,idx) in userFieldOnFormOptions"
|
||||
v-for="(item, idx) in userFieldOnFormOptions"
|
||||
:key="idx"
|
||||
:label="item.title"
|
||||
:value="item.field"
|
||||
|
@ -152,13 +152,13 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM"
|
||||
v-if="configForm.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER"
|
||||
label="表单内部门字段"
|
||||
prop="deptFieldOnForm"
|
||||
>
|
||||
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="(item,idx) in deptFieldOnFormOptions"
|
||||
v-for="(item, idx) in deptFieldOnFormOptions"
|
||||
:key="idx"
|
||||
:label="item.title"
|
||||
:value="item.field"
|
||||
|
@ -169,8 +169,9 @@
|
|||
v-if="
|
||||
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM
|
||||
configForm.candidateStrategy ==
|
||||
CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
|
||||
configForm.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER
|
||||
"
|
||||
:label="deptLevelLabel!"
|
||||
prop="deptLevel"
|
||||
|
@ -496,10 +497,10 @@ const deptLevelLabel = computed(() => {
|
|||
let label = '部门负责人来源'
|
||||
if (configForm.value.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER) {
|
||||
label = label + '(指定部门向上)'
|
||||
} else if (configForm.value.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM) {
|
||||
} else if (configForm.value.candidateStrategy == CandidateStrategy.FORM_DEPT_LEADER) {
|
||||
label = label + '(表单内部门向上)'
|
||||
} else {
|
||||
label = label + '(发起人部门向上)'
|
||||
label = label + '(发起人部门向上)'
|
||||
}
|
||||
return label
|
||||
})
|
||||
|
@ -512,20 +513,15 @@ const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.USER_
|
|||
// 激活的 Tab 标签页
|
||||
const activeTabName = ref('user')
|
||||
// 表单字段权限设置
|
||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } = useFormFieldsPermission(
|
||||
FieldPermissionType.READ
|
||||
)
|
||||
const { formType, fieldsPermissionConfig, formFieldOptions, getNodeConfigFormFields } =
|
||||
useFormFieldsPermission(FieldPermissionType.READ)
|
||||
// 表单内用户字段选项, 必须是必填和用户选择器
|
||||
const userFieldOnFormOptions = computed(() => {
|
||||
return formFieldOptions.filter(
|
||||
(item) => item.required && item.type === 'UserSelect'
|
||||
)
|
||||
return formFieldOptions.filter((item) => item.required && item.type === 'UserSelect')
|
||||
})
|
||||
// 表单内部门字段选项, 必须是必填和部门选择器
|
||||
const deptFieldOnFormOptions = computed(() => {
|
||||
return formFieldOptions.filter(
|
||||
(item) => item.required && item.type === 'DeptSelect'
|
||||
)
|
||||
return formFieldOptions.filter((item) => item.required && item.type === 'DeptSelect')
|
||||
})
|
||||
// 操作按钮设置
|
||||
const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
|
||||
|
@ -577,6 +573,7 @@ const changeCandidateStrategy = () => {
|
|||
configForm.value.postIds = []
|
||||
configForm.value.userGroups = []
|
||||
configForm.value.deptLevel = 1
|
||||
// TODO @jason:是不是 userFieldOnForm => formUser;deptFieldOnForm => formDeptLeader;原因是:想通前缀,好管理点
|
||||
configForm.value.userFieldOnForm = ''
|
||||
configForm.value.deptFieldOnForm = ''
|
||||
configForm.value.approveMethod = ApproveMethodType.SEQUENTIAL_APPROVE
|
||||
|
|
Loading…
Reference in New Issue