仿钉钉设计器- 审批节点配置结构调整

This commit is contained in:
jason 2024-06-19 23:54:46 +08:00
parent 58fc91b810
commit ea1e51a655
3 changed files with 181 additions and 144 deletions

View File

@ -42,7 +42,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { SimpleFlowNode, NodeType, NODE_DEFAULT_NAME, ApproveMethodType, RejectHandlerType, CandidateStrategy } from './consts' import {
SimpleFlowNode,
NodeType,
NODE_DEFAULT_NAME,
ApproveMethodType,
RejectHandlerType,
CandidateStrategy
} from './consts'
import { generateUUID } from '@/utils' import { generateUUID } from '@/utils'
defineOptions({ defineOptions({
name: 'NodeHandler' name: 'NodeHandler'
@ -63,37 +70,47 @@ const props = defineProps({
const emits = defineEmits(['update:childNode']) const emits = defineEmits(['update:childNode'])
const addNode = (type: number) => { const addNode = (type: number) => {
popoverShow.value = false popoverShow.value = false
if (type === NodeType.USER_TASK_NODE) { if (type === NodeType.USER_TASK_NODE) {
const id = 'Activity_'+ generateUUID(); const id = 'Activity_' + generateUUID()
const data: SimpleFlowNode = { const data: SimpleFlowNode = {
id: id, id: id,
name: NODE_DEFAULT_NAME.get(NodeType.USER_TASK_NODE) as string, name: NODE_DEFAULT_NAME.get(NodeType.USER_TASK_NODE) as string,
showText: '', showText: '',
type: NodeType.USER_TASK_NODE, type: NodeType.USER_TASK_NODE,
// approveMethod: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE,
attributes: { candidateStrategy: CandidateStrategy.USER,
approveMethod: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE, candidateParam: undefined,
candidateStrategy: CandidateStrategy.USER, fieldsPermission: undefined,
candidateParam: undefined, //
fieldsPermission: undefined, timeoutHandler: {
// enable: false
timeoutHandler: { },
enable: false rejectHandler: {
}, type: RejectHandlerType.FINISH_PROCESS
rejectHandler: {
type: RejectHandlerType.FINISH_PROCESS
}
}, },
childNode: props.childNode childNode: props.childNode
//
// attributes: {
// approveMethod: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE,
// candidateStrategy: CandidateStrategy.USER,
// candidateParam: undefined,
// fieldsPermission: undefined,
// //
// timeoutHandler: {
// enable: false
// },
// rejectHandler: {
// type: RejectHandlerType.FINISH_PROCESS
// }
// },
} }
emits('update:childNode', data); emits('update:childNode', data)
} }
if (type === NodeType.COPY_TASK_NODE) { if (type === NodeType.COPY_TASK_NODE) {
const data: SimpleFlowNode = { const data: SimpleFlowNode = {
id: 'Activity_'+ generateUUID(), id: 'Activity_' + generateUUID(),
name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string, name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string,
showText: '', showText: '',
type: NodeType.COPY_TASK_NODE, type: NodeType.COPY_TASK_NODE,
@ -108,14 +125,14 @@ const addNode = (type: number) => {
emits('update:childNode', data) emits('update:childNode', data)
} }
if (type === NodeType.EXCLUSIVE_NODE) { if (type === NodeType.EXCLUSIVE_NODE) {
const data : SimpleFlowNode = { const data: SimpleFlowNode = {
name: '条件分支', name: '条件分支',
type: NodeType.EXCLUSIVE_NODE, type: NodeType.EXCLUSIVE_NODE,
id: 'GateWay_' + generateUUID(), id: 'GateWay_' + generateUUID(),
childNode: props.childNode, childNode: props.childNode,
conditionNodes: [ conditionNodes: [
{ {
id: 'Flow_'+ generateUUID(), id: 'Flow_' + generateUUID(),
name: '条件1', name: '条件1',
showText: '', showText: '',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
@ -126,7 +143,7 @@ const addNode = (type: number) => {
} }
}, },
{ {
id: 'Flow_'+ generateUUID(), id: 'Flow_' + generateUUID(),
name: '其它情况', name: '其它情况',
showText: '其它情况进入此流程', showText: '其它情况进入此流程',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
@ -141,25 +158,25 @@ const addNode = (type: number) => {
emits('update:childNode', data) emits('update:childNode', data)
} }
if (type === NodeType.PARALLEL_NODE_FORK) { if (type === NodeType.PARALLEL_NODE_FORK) {
const data : SimpleFlowNode = { const data: SimpleFlowNode = {
name: '并行分支', name: '并行分支',
type: NodeType.PARALLEL_NODE_FORK, type: NodeType.PARALLEL_NODE_FORK,
id: 'GateWay_' + generateUUID(), id: 'GateWay_' + generateUUID(),
childNode: props.childNode, childNode: props.childNode,
conditionNodes: [ conditionNodes: [
{ {
id: 'Flow_'+ generateUUID(), id: 'Flow_' + generateUUID(),
name: '并行1', name: '并行1',
showText: '无需配置条件同时执行', showText: '无需配置条件同时执行',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined
}, },
{ {
id: 'Flow_'+ generateUUID(), id: 'Flow_' + generateUUID(),
name: '并行2', name: '并行2',
showText: '无需配置条件同时执行', showText: '无需配置条件同时执行',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined
} }
] ]
} }

View File

@ -71,44 +71,40 @@ export enum RejectHandlerType {
* *
*/ */
RETURN_USER_TASK = 2 RETURN_USER_TASK = 2
} }
// 条件配置类型 用于条件节点配置 // 条件配置类型 用于条件节点配置
export enum ConditionConfigType { export enum ConditionConfigType {
/**
/**
* *
*/ */
EXPRESSION = 1, EXPRESSION = 1,
/** /**
* *
*/ */
RULE = 2 RULE = 2
} }
// 多人审批方式类型 用于审批节点 // 多人审批方式类型 用于审批节点
export enum ApproveMethodType { export enum ApproveMethodType {
/** /**
* *
*/ */
RRANDOM_SELECT_ONE_APPROVE = 1, RRANDOM_SELECT_ONE_APPROVE = 1,
/** /**
* () * ()
*/ */
APPROVE_BY_RATIO = 2, APPROVE_BY_RATIO = 2,
/** /**
* () * ()
*/ */
ANY_APPROVE = 3, ANY_APPROVE = 3,
/** /**
* *
*/ */
SEQUENTIAL_APPROVE = 4 SEQUENTIAL_APPROVE = 4
} }
// 候选人策略 用于审批节点。抄送节点 ) // 候选人策略 用于审批节点。抄送节点 )
@ -137,37 +133,67 @@ export enum CandidateStrategy {
* *
*/ */
START_USER_SELECT = 35, START_USER_SELECT = 35,
/** /**
* *
*/ */
START_USER = 36, START_USER = 36,
/** /**
* *
*/ */
USER_GROUP = 40, USER_GROUP = 40,
/** /**
* *
*/ */
EXPRESSION = 60 EXPRESSION = 60
} }
export type RejectHandler = {
type: RejectHandlerType
returnNodeId?: string
}
export type TimeoutHandler = {
//是否开启超时处理
enable: boolean
// 超时执行的动作
action?: number
// 超时时间设置
timeDuration?: string
// 执行动作是自动提醒, 最大提醒次数
maxRemindCount?: number
}
export type SimpleFlowNode = { export type SimpleFlowNode = {
id: string, id: string
type: NodeType, type: NodeType
name: string, name: string
showText?: string, showText?: string
attributes?: any, attributes?: any
// 孩子节点 // 孩子节点
childNode?: SimpleFlowNode, childNode?: SimpleFlowNode
// 条件节点 // 条件节点
conditionNodes?: SimpleFlowNode[] conditionNodes?: SimpleFlowNode[]
// 候选人策略
candidateStrategy?: number
// 候选人参数
candidateParam?: string
// 多人审批方式
approveMethod?: ApproveMethodType
//通过比例
approveRatio: number
// 表单权限
fieldsPermission?: any[]
// 审批任务超时处理
timeoutHandler?: TimeoutHandler
// 审批任务拒绝处理
rejectHandler?: RejectHandler
} }
// 条件组 // 条件组
export type ConditionGroup = { export type ConditionGroup = {
// 条件组的逻辑关系是否为且 // 条件组的逻辑关系是否为且
and : boolean, and: boolean
// 条件数组 // 条件数组
conditions: Condition[] conditions: Condition[]
} }
@ -175,84 +201,83 @@ export type ConditionGroup = {
// 条件 // 条件
export type Condition = { export type Condition = {
// 条件规则的逻辑关系是否为且 // 条件规则的逻辑关系是否为且
and : boolean, and: boolean
rules: ConditionRule[] rules: ConditionRule[]
} }
// 条件规则 // 条件规则
export type ConditionRule = { export type ConditionRule = {
type : number, type: number
opName: string, opName: string
opCode: string, opCode: string
leftSide: string, leftSide: string
rightSide: string rightSide: string
} }
export const NODE_DEFAULT_TEXT = new Map<number, string>()
export const NODE_DEFAULT_TEXT = new Map<number,string>()
NODE_DEFAULT_TEXT.set(NodeType.USER_TASK_NODE, '请配置审批人') NODE_DEFAULT_TEXT.set(NodeType.USER_TASK_NODE, '请配置审批人')
NODE_DEFAULT_TEXT.set(NodeType.COPY_TASK_NODE, '请配置抄送人') NODE_DEFAULT_TEXT.set(NodeType.COPY_TASK_NODE, '请配置抄送人')
NODE_DEFAULT_TEXT.set(NodeType.CONDITION_NODE, '请设置条件') NODE_DEFAULT_TEXT.set(NodeType.CONDITION_NODE, '请设置条件')
export const NODE_DEFAULT_NAME = new Map<number,string>() export const NODE_DEFAULT_NAME = new Map<number, string>()
NODE_DEFAULT_NAME.set(NodeType.USER_TASK_NODE, '审批人') NODE_DEFAULT_NAME.set(NodeType.USER_TASK_NODE, '审批人')
NODE_DEFAULT_NAME.set(NodeType.COPY_TASK_NODE, '抄送人') NODE_DEFAULT_NAME.set(NodeType.COPY_TASK_NODE, '抄送人')
NODE_DEFAULT_NAME.set(NodeType.CONDITION_NODE, '条件') NODE_DEFAULT_NAME.set(NodeType.CONDITION_NODE, '条件')
export const APPROVE_METHODS: DictDataVO [] = [ export const APPROVE_METHODS: DictDataVO[] = [
{ label: '随机挑选一人审批', value: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE }, { label: '随机挑选一人审批', value: ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE },
{ label: '多人会签(按通过比例%)', value: ApproveMethodType.APPROVE_BY_RATIO }, { label: '多人会签(按通过比例%)', value: ApproveMethodType.APPROVE_BY_RATIO },
{ label: '多人或签(一人通过或拒绝)', value: ApproveMethodType.ANY_APPROVE }, { label: '多人或签(一人通过或拒绝)', value: ApproveMethodType.ANY_APPROVE },
{ label: '依次审批(按顺序依次审批)', value: ApproveMethodType.SEQUENTIAL_APPROVE } { label: '依次审批(按顺序依次审批)', value: ApproveMethodType.SEQUENTIAL_APPROVE }
] ]
export const CONDITION_CONFIG_TYPES: DictDataVO [] = [ export const CONDITION_CONFIG_TYPES: DictDataVO[] = [
{ label: '条件表达式', value: 1 }, { label: '条件表达式', value: 1 },
{ label: '条件规则', value: 2 } { label: '条件规则', value: 2 }
] ]
// 时间单位类型 // 时间单位类型
export const TIME_UNIT_TYPES: DictDataVO [] = [ export const TIME_UNIT_TYPES: DictDataVO[] = [
{ label: '分钟', value: TimeUnitType.MINUTE }, { label: '分钟', value: TimeUnitType.MINUTE },
{ label: '小时', value: TimeUnitType.HOUR }, { label: '小时', value: TimeUnitType.HOUR },
{ label: '天', value: TimeUnitType.DAY }, { label: '天', value: TimeUnitType.DAY }
] ]
// 超时处理执行动作类型 // 超时处理执行动作类型
export const TIMEOUT_HANDLER_ACTION_TYPES: DictDataVO [] = [ export const TIMEOUT_HANDLER_ACTION_TYPES: DictDataVO[] = [
{ label: '自动提醒', value: 1 }, { label: '自动提醒', value: 1 },
{ label: '自动同意', value: 2 }, { label: '自动同意', value: 2 },
{ label: '自动拒绝', value: 3 }, { label: '自动拒绝', value: 3 }
] ]
export const REJECT_HANDLER_TYPES: DictDataVO [] = [ export const REJECT_HANDLER_TYPES: DictDataVO[] = [
{ label: '终止流程', value: RejectHandlerType.FINISH_PROCESS }, { label: '终止流程', value: RejectHandlerType.FINISH_PROCESS },
{ label: '驳回到指定节点', value: RejectHandlerType.RETURN_USER_TASK } { label: '驳回到指定节点', value: RejectHandlerType.RETURN_USER_TASK }
// { label: '结束任务', value: RejectHandlerType.FINISH_TASK } // { label: '结束任务', value: RejectHandlerType.FINISH_TASK }
] ]
// 比较运算符 // 比较运算符
export const COMPARISON_OPERATORS : DictDataVO = [ export const COMPARISON_OPERATORS: DictDataVO = [
{ {
value: '==', value: '==',
label: '等于', label: '等于'
}, },
{ {
value: '!=', value: '!=',
label: '不等于', label: '不等于'
}, },
{ {
value: '>', value: '>',
label: '大于', label: '大于'
}, },
{ {
value: '>=', value: '>=',
label: '大于等于', label: '大于等于'
}, },
{ {
value: '<', value: '<',
label: '小于', label: '小于'
}, },
{ {
value: '<=', value: '<=',
label: '小于等于', label: '小于等于'
} }
] ]

View File

@ -32,7 +32,7 @@
<el-form label-position="top"> <el-form label-position="top">
<el-form-item label="审批人设置" prop="candidateStrategy"> <el-form-item label="审批人设置" prop="candidateStrategy">
<el-radio-group <el-radio-group
v-model="currentNode.attributes.candidateStrategy" v-model="currentNode.candidateStrategy"
@change="changeCandidateStrategy" @change="changeCandidateStrategy"
> >
<el-radio <el-radio
@ -47,7 +47,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.candidateStrategy == CandidateStrategy.ROLE" v-if="currentNode.candidateStrategy == CandidateStrategy.ROLE"
label="指定角色" label="指定角色"
prop="candidateParam" prop="candidateParam"
> >
@ -62,8 +62,8 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if=" v-if="
currentNode.attributes.candidateStrategy == CandidateStrategy.DEPT_MEMBER || currentNode.candidateStrategy == CandidateStrategy.DEPT_MEMBER ||
currentNode.attributes.candidateStrategy == CandidateStrategy.DEPT_LEADER currentNode.candidateStrategy == CandidateStrategy.DEPT_LEADER
" "
label="指定部门" label="指定部门"
prop="candidateParam" prop="candidateParam"
@ -82,7 +82,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.candidateStrategy == CandidateStrategy.POST" v-if="currentNode.candidateStrategy == CandidateStrategy.POST"
label="指定岗位" label="指定岗位"
prop="candidateParam" prop="candidateParam"
span="24" span="24"
@ -97,7 +97,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.candidateStrategy == CandidateStrategy.USER" v-if="currentNode.candidateStrategy == CandidateStrategy.USER"
label="指定用户" label="指定用户"
prop="candidateParam" prop="candidateParam"
span="24" span="24"
@ -118,7 +118,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.candidateStrategy === CandidateStrategy.USER_GROUP" v-if="currentNode.candidateStrategy === CandidateStrategy.USER_GROUP"
label="指定用户组" label="指定用户组"
prop="candidateParam" prop="candidateParam"
> >
@ -132,7 +132,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.candidateStrategy === CandidateStrategy.EXPRESSION" v-if="currentNode.candidateStrategy === CandidateStrategy.EXPRESSION"
label="流程表达式" label="流程表达式"
prop="candidateParam" prop="candidateParam"
> >
@ -144,10 +144,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="多人审批方式" prop="approveMethod"> <el-form-item label="多人审批方式" prop="approveMethod">
<el-radio-group <el-radio-group v-model="currentNode.approveMethod" @change="approveMethodChanged">
v-model="currentNode.attributes.approveMethod"
@change="approveMethodChanged"
>
<div class="flex-col"> <div class="flex-col">
<div <div
v-for="(item, index) in APPROVE_METHODS" v-for="(item, index) in APPROVE_METHODS"
@ -165,14 +162,14 @@
{{ item.label }} {{ item.label }}
</el-radio> </el-radio>
<el-input-number <el-input-number
v-model="currentNode.attributes.approveRatio" v-model="currentNode.approveRatio"
:min="10" :min="10"
:max="100" :max="100"
:step="10" :step="10"
size="small" size="small"
v-if=" v-if="
item.value === ApproveMethodType.APPROVE_BY_RATIO && item.value === ApproveMethodType.APPROVE_BY_RATIO &&
currentNode.attributes.approveMethod === ApproveMethodType.APPROVE_BY_RATIO currentNode.approveMethod === ApproveMethodType.APPROVE_BY_RATIO
" "
/> />
</div> </div>
@ -181,7 +178,7 @@
</el-form-item> </el-form-item>
<el-divider content-position="left">审批人拒绝时</el-divider> <el-divider content-position="left">审批人拒绝时</el-divider>
<el-form-item prop="rejectHandler"> <el-form-item prop="rejectHandler">
<el-radio-group v-model="currentNode.attributes.rejectHandler.type"> <el-radio-group v-model="currentNode.rejectHandler!.type">
<div class="flex-col"> <div class="flex-col">
<div v-for="(item, index) in REJECT_HANDLER_TYPES" :key="index"> <div v-for="(item, index) in REJECT_HANDLER_TYPES" :key="index">
<el-radio :key="item.value" :value="item.value" :label="item.label" /> <el-radio :key="item.value" :value="item.value" :label="item.label" />
@ -191,12 +188,12 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.attributes.rejectHandler.type == RejectHandlerType.RETURN_USER_TASK" v-if="currentNode.rejectHandler!.type == RejectHandlerType.RETURN_USER_TASK"
label="驳回节点" label="驳回节点"
prop="rejectHandlerNode" prop="rejectHandlerNode"
> >
<el-select <el-select
v-model="currentNode.attributes.rejectHandler.returnNodeId" v-model="currentNode.rejectHandler!.returnNodeId"
clearable clearable
style="width: 100%" style="width: 100%"
> >
@ -211,7 +208,7 @@
<el-divider content-position="left">审批人超时未处理时</el-divider> <el-divider content-position="left">审批人超时未处理时</el-divider>
<el-form-item label="启用开关" prop="timeoutHandlerEnable"> <el-form-item label="启用开关" prop="timeoutHandlerEnable">
<el-switch <el-switch
v-model="currentNode.attributes.timeoutHandler.enable" v-model="currentNode.timeoutHandler!.enable"
active-text="开启" active-text="开启"
inactive-text="关闭" inactive-text="关闭"
@change="timeoutHandlerChange" @change="timeoutHandlerChange"
@ -220,9 +217,9 @@
<el-form-item <el-form-item
label="执行动作" label="执行动作"
prop="timeoutHandlerAction" prop="timeoutHandlerAction"
v-if="currentNode.attributes.timeoutHandler.enable" v-if="currentNode.timeoutHandler?.enable"
> >
<el-radio-group v-model="currentNode.attributes.timeoutHandler.action"> <el-radio-group v-model="currentNode.timeoutHandler!.action">
<el-radio-button <el-radio-button
v-for="item in TIMEOUT_HANDLER_ACTION_TYPES" v-for="item in TIMEOUT_HANDLER_ACTION_TYPES"
:key="item.value" :key="item.value"
@ -234,7 +231,7 @@
<el-form-item <el-form-item
label="超时时间设置" label="超时时间设置"
prop="timeoutHandlerTimeDuration" prop="timeoutHandlerTimeDuration"
v-if="currentNode.attributes.timeoutHandler.enable" v-if="currentNode.timeoutHandler?.enable"
> >
<span class="mr-2">当超过</span> <span class="mr-2">当超过</span>
<el-input-number <el-input-number
@ -262,13 +259,10 @@
<el-form-item <el-form-item
label="最大提醒次数" label="最大提醒次数"
prop="timeoutHandlerMaxRemindCount" prop="timeoutHandlerMaxRemindCount"
v-if=" v-if="currentNode.timeoutHandler?.enable && currentNode.timeoutHandler?.action === 1"
currentNode.attributes.timeoutHandler.enable &&
currentNode.attributes.timeoutHandler.action === 1
"
> >
<el-input-number <el-input-number
v-model="currentNode.attributes.timeoutHandler.maxRemindCount" v-model="currentNode.timeoutHandler!.maxRemindCount"
:min="1" :min="1"
:max="10" :max="10"
/> />
@ -289,7 +283,7 @@
</div> </div>
<div <div
class="field-setting-item" class="field-setting-item"
v-for="(item, index) in currentNode.attributes.fieldsPermission" v-for="(item, index) in currentNode.fieldsPermission"
:key="index" :key="index"
> >
<div class="field-setting-item-label"> {{ item.title }} </div> <div class="field-setting-item-label"> {{ item.title }} </div>
@ -371,9 +365,9 @@ const closeDrawer = () => {
settingVisible.value = false settingVisible.value = false
} }
const saveConfig = () => { const saveConfig = () => {
currentNode.value.attributes.candidateParam = candidateParamArray.value?.join(',') currentNode.value.candidateParam = candidateParamArray.value?.join(',')
if (currentNode.value.attributes.timeoutHandler.enable) { if (currentNode.value.timeoutHandler?.enable) {
currentNode.value.attributes.timeoutHandler.timeDuration = isoTimeDuration.value currentNode.value.timeoutHandler.timeDuration = isoTimeDuration.value
} }
currentNode.value.showText = getShowText() currentNode.value.showText = getShowText()
settingVisible.value = false settingVisible.value = false
@ -381,7 +375,7 @@ const saveConfig = () => {
const getShowText = (): string => { const getShowText = (): string => {
let showText = '' let showText = ''
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.USER) { if (currentNode.value.candidateStrategy === CandidateStrategy.USER) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = [] const candidateNames: string[] = []
userOptions?.value.forEach((item) => { userOptions?.value.forEach((item) => {
@ -393,7 +387,7 @@ const getShowText = (): string => {
} }
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.ROLE) { if (currentNode.value.candidateStrategy === CandidateStrategy.ROLE) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = [] const candidateNames: string[] = []
roleOptions?.value.forEach((item) => { roleOptions?.value.forEach((item) => {
@ -406,8 +400,8 @@ const getShowText = (): string => {
} }
// //
if ( if (
currentNode.value.attributes.candidateStrategy === CandidateStrategy.DEPT_MEMBER || currentNode.value.candidateStrategy === CandidateStrategy.DEPT_MEMBER ||
currentNode.value.attributes.candidateStrategy === CandidateStrategy.DEPT_LEADER currentNode.value.candidateStrategy === CandidateStrategy.DEPT_LEADER
) { ) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = [] const candidateNames: string[] = []
@ -416,7 +410,7 @@ const getShowText = (): string => {
candidateNames.push(item.name) candidateNames.push(item.name)
} }
}) })
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.DEPT_MEMBER) { if (currentNode.value.candidateStrategy === CandidateStrategy.DEPT_MEMBER) {
showText = `部门成员:${candidateNames.join(',')}` showText = `部门成员:${candidateNames.join(',')}`
} else { } else {
showText = `部门的负责人:${candidateNames.join(',')}` showText = `部门的负责人:${candidateNames.join(',')}`
@ -425,7 +419,7 @@ const getShowText = (): string => {
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.POST) { if (currentNode.value.candidateStrategy === CandidateStrategy.POST) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = [] const candidateNames: string[] = []
postOptions?.value.forEach((item) => { postOptions?.value.forEach((item) => {
@ -437,7 +431,7 @@ const getShowText = (): string => {
} }
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.USER_GROUP) { if (currentNode.value.candidateStrategy === CandidateStrategy.USER_GROUP) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = [] const candidateNames: string[] = []
userGroupOptions?.value.forEach((item) => { userGroupOptions?.value.forEach((item) => {
@ -450,16 +444,16 @@ const getShowText = (): string => {
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.START_USER_SELECT) { if (currentNode.value.candidateStrategy === CandidateStrategy.START_USER_SELECT) {
showText = `发起人自选` showText = `发起人自选`
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.START_USER) { if (currentNode.value.candidateStrategy === CandidateStrategy.START_USER) {
showText = `发起人自己` showText = `发起人自己`
} }
// //
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.EXPRESSION) { if (currentNode.value.candidateStrategy === CandidateStrategy.EXPRESSION) {
if (candidateParamArray.value?.length > 0) { if (candidateParamArray.value?.length > 0) {
showText = `流程表达式:${candidateParamArray.value[0]}` showText = `流程表达式:${candidateParamArray.value[0]}`
} }
@ -472,22 +466,23 @@ const open = () => {
// //
const setCurrentNode = (node: SimpleFlowNode) => { const setCurrentNode = (node: SimpleFlowNode) => {
currentNode.value = node currentNode.value = node
currentNode.value.attributes.fieldsPermission = currentNode.value.fieldsPermission =
node.attributes.fieldsPermission || getDefaultFieldsPermission(formFields?.value) node.fieldsPermission || getDefaultFieldsPermission(formFields?.value)
const strCandidateParam = node.attributes?.candidateParam const strCandidateParam = node?.candidateParam
if (strCandidateParam) { if (strCandidateParam) {
candidateParamArray.value = strCandidateParam.split(',').map((item) => +item) candidateParamArray.value = strCandidateParam.split(',').map((item) => +item)
} }
if (currentNode.value.attributes?.candidateStrategy === CandidateStrategy.START_USER) { if (
(candidateParamArray.value.length <= 1 &&
currentNode.value.candidateStrategy === CandidateStrategy.USER) ||
currentNode.value.candidateStrategy === CandidateStrategy.START_USER
) {
notAllowedMultiApprovers.value = true notAllowedMultiApprovers.value = true
} else { } else {
notAllowedMultiApprovers.value = false notAllowedMultiApprovers.value = false
} }
if ( if (currentNode.value.timeoutHandler?.enable && currentNode.value.timeoutHandler?.timeDuration) {
currentNode.value.attributes?.timeoutHandler?.enable && const strTimeDuration = currentNode.value.timeoutHandler.timeDuration
currentNode.value.attributes?.timeoutHandler?.timeDuration
) {
const strTimeDuration = currentNode.value.attributes.timeoutHandler.timeDuration
let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1) let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1) let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
timeDuration.value = parseInt(parseTime) timeDuration.value = parseInt(parseTime)
@ -503,10 +498,10 @@ defineExpose({ open, setCurrentNode }) // 暴露方法给父组件
const changeCandidateStrategy = () => { const changeCandidateStrategy = () => {
candidateParamArray.value = [] candidateParamArray.value = []
currentNode.value.attributes.approveMethod = ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE currentNode.value.approveMethod = ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE
if ( if (
currentNode.value.attributes.candidateStrategy === CandidateStrategy.START_USER || currentNode.value.candidateStrategy === CandidateStrategy.START_USER ||
currentNode.value.attributes.candidateStrategy === CandidateStrategy.USER currentNode.value.candidateStrategy === CandidateStrategy.USER
) { ) {
notAllowedMultiApprovers.value = true notAllowedMultiApprovers.value = true
} else { } else {
@ -517,10 +512,10 @@ const changeCandidateStrategy = () => {
const changedCandidateUsers = () => { const changedCandidateUsers = () => {
if ( if (
candidateParamArray.value?.length <= 1 && candidateParamArray.value?.length <= 1 &&
currentNode.value.attributes?.candidateStrategy === CandidateStrategy.USER currentNode.value.candidateStrategy === CandidateStrategy.USER
) { ) {
currentNode.value.attributes.approveMethod = ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE currentNode.value.approveMethod = ApproveMethodType.RRANDOM_SELECT_ONE_APPROVE
currentNode.value.attributes.rejectHandler.type = RejectHandlerType.FINISH_PROCESS currentNode.value.rejectHandler!.type = RejectHandlerType.FINISH_PROCESS
notAllowedMultiApprovers.value = true notAllowedMultiApprovers.value = true
} else { } else {
notAllowedMultiApprovers.value = false notAllowedMultiApprovers.value = false
@ -539,10 +534,10 @@ const blurEvent = () => {
currentNode.value.name || (NODE_DEFAULT_NAME.get(NodeType.USER_TASK_NODE) as string) currentNode.value.name || (NODE_DEFAULT_NAME.get(NodeType.USER_TASK_NODE) as string)
} }
const approveMethodChanged = () => { const approveMethodChanged = () => {
currentNode.value.attributes.rejectHandler.type = RejectHandlerType.FINISH_PROCESS currentNode.value.rejectHandler!.type = RejectHandlerType.FINISH_PROCESS
const approveMethod = currentNode.value.attributes?.approveMethod const approveMethod = currentNode.value?.approveMethod
if (approveMethod === ApproveMethodType.APPROVE_BY_RATIO) { if (approveMethod === ApproveMethodType.APPROVE_BY_RATIO) {
currentNode.value.attributes.approveRatio = 100 currentNode.value.approveRatio = 100
} }
} }
// 6 // 6
@ -565,11 +560,11 @@ const isoTimeDuration = computed(() => {
// //
const timeoutHandlerChange = () => { const timeoutHandlerChange = () => {
if (currentNode.value.attributes.timeoutHandler.enable) { if (currentNode.value.timeoutHandler?.enable) {
timeUnit.value = 2 timeUnit.value = 2
timeDuration.value = 6 timeDuration.value = 6
currentNode.value.attributes.timeoutHandler.action = 1 currentNode.value.timeoutHandler.action = 1
currentNode.value.attributes.timeoutHandler.maxRemindCount = 1 currentNode.value.timeoutHandler.maxRemindCount = 1
} }
} }