gbflowengine 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +271 -3
- package/dist/gbflowengine.css +1 -0
- package/dist/gbflowengine.js +18363 -0
- package/dist/gbflowengine.js.map +1 -0
- package/dist/gbflowengine.umd.cjs +5 -0
- package/dist/gbflowengine.umd.cjs.map +1 -0
- package/package.json +84 -6
- package/src/center/DefinitionInspect.vue +291 -0
- package/src/center/FlowCenter.vue +33 -0
- package/src/center/index.js +29 -0
- package/src/center/storage.js +748 -0
- package/src/core/flow/condition.js +160 -0
- package/src/core/flow/customNode.js +385 -0
- package/src/core/flow/defaults.js +124 -0
- package/src/core/flow/flowConstant.js +265 -0
- package/src/core/flow/flowNodeUtils.js +30 -0
- package/src/core/flow/index.js +47 -0
- package/src/core/flow/node.js +44 -0
- package/src/core/flow/nodeFactory.js +58 -0
- package/src/core/flow/prediction.js +325 -0
- package/src/core/flow/runtime/auto.js +83 -0
- package/src/core/flow/runtime/decide.js +329 -0
- package/src/core/flow/runtime/event.js +28 -0
- package/src/core/flow/runtime/execute.js +357 -0
- package/src/core/flow/runtime/helpers.js +52 -0
- package/src/core/flow/runtime/query.js +146 -0
- package/src/core/flow/runtime/reject.js +137 -0
- package/src/core/flow/runtime/token.js +269 -0
- package/src/core/flow/runtime.js +129 -0
- package/src/core/flow/schema.js +864 -0
- package/src/definition/FlowDefinitionDesigner.vue +338 -0
- package/src/definition/index.js +9 -0
- package/src/index.js +39 -0
- package/src/storage.js +200 -0
- package/src/testing/FlowTestPanel.vue +2502 -0
- package/src/testing/UserConfigDrawer.vue +376 -0
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -0
- package/src/testing/diagramModel.js +517 -0
- package/src/testing/index.js +23 -0
- package/src/testing/mock.js +246 -0
- package/src/testing/oaExecutors.js +51 -0
- package/src/testing/oaSeed.js +467 -0
- package/src/testing/sample.js +412 -0
- package/src/testing/seed.js +122 -0
- package/src/utils/format.js +27 -0
- package/src/visual/FlowCanvas.vue +441 -0
- package/src/visual/NodeProgressDetail.vue +43 -0
- package/src/visual/NodeStatusBadge.vue +17 -0
- package/src/visual/NodeWrap.vue +47 -0
- package/src/visual/ScWorkflow.vue +50 -0
- package/src/visual/SelectDialog.vue +460 -0
- package/src/visual/conditionHelpers.js +117 -0
- package/src/visual/index.js +6 -0
- package/src/visual/nodes/AddNode.vue +223 -0
- package/src/visual/nodes/ApproverNode.vue +348 -0
- package/src/visual/nodes/BranchNode.vue +442 -0
- package/src/visual/nodes/CustomNode.vue +339 -0
- package/src/visual/nodes/EndNode.vue +22 -0
- package/src/visual/nodes/PassNode.vue +101 -0
- package/src/visual/nodes/PromoterNode.vue +135 -0
- package/src/visual/nodes/RejectNode.vue +101 -0
- package/src/visual/nodes/SendNode.vue +152 -0
- package/src/visual/styles.scss +879 -0
- package/src/visual/useScNodeStatus.js +18 -0
- package/src/workbench/OaWorkbench.vue +1341 -0
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -0
- package/src/workbench/components/CategoryIcon.vue +74 -0
- package/src/workbench/components/NotificationIcon.vue +73 -0
- package/src/workbench/components/ProcessSteps.vue +557 -0
- package/src/workbench/components/ResubmitDialog.vue +227 -0
- package/src/workbench/components/SidebarNav.vue +138 -0
- package/src/workbench/components/StartFlowDialog.vue +1058 -0
- package/src/workbench/components/UserAvatar.vue +68 -0
- package/src/workbench/custom-tasks.js +130 -0
- package/src/workbench/model.js +1080 -0
- package/src/workbench/pages/DesignPage.vue +798 -0
- package/src/workbench/pages/HomePage.vue +1050 -0
- package/src/workbench/pages/MonitorPage.vue +1029 -0
- package/src/workbench/pages/NotificationsPage.vue +554 -0
- package/src/workbench/pages/RequestsPage.vue +644 -0
- package/src/workbench/pages/TaskCenterPage.vue +1155 -0
- package/src/workbench/pages/TemplatesPage.vue +680 -0
- package/src/workbench/persistence.js +89 -0
- package/src/workbench/shared.js +18 -0
- package/src/workbench/styles.scss +555 -0
- package/src/workbench/useWorkbench.js +955 -0
- package/types/center.d.ts +5 -0
- package/types/core.d.ts +479 -0
- package/types/definition.d.ts +4 -0
- package/types/index.d.ts +34 -0
- package/types/testing.d.ts +20 -0
- package/types/visual.d.ts +20 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="add-node-btn-box" v-if="!readonly">
|
|
3
|
+
<div class="add-node-btn">
|
|
4
|
+
<el-popover placement="right-start" :width="270" trigger="click" :hide-after="0" :show-after="0">
|
|
5
|
+
<template #reference>
|
|
6
|
+
<el-button type="primary" :icon="Plus" circle />
|
|
7
|
+
</template>
|
|
8
|
+
<div class="add-node-popover-body">
|
|
9
|
+
<ul>
|
|
10
|
+
<li v-if="allow.type1">
|
|
11
|
+
<div class="fc-add-icon" style="color: #ff943e" @click="addType(FlowNodeType.APPROVE)">
|
|
12
|
+
<el-icon><UserFilled /></el-icon>
|
|
13
|
+
</div>
|
|
14
|
+
<p>审批节点</p>
|
|
15
|
+
</li>
|
|
16
|
+
<li v-if="allow.type2">
|
|
17
|
+
<div class="fc-add-icon" style="color: #3296fa" @click="addType(FlowNodeType.CC)">
|
|
18
|
+
<el-icon><Promotion /></el-icon>
|
|
19
|
+
</div>
|
|
20
|
+
<p>抄送节点</p>
|
|
21
|
+
</li>
|
|
22
|
+
<li v-if="allow.type7">
|
|
23
|
+
<div class="fc-add-icon" style="color: #6f5cf1" @click="addType(FlowNodeType.CUSTOM)">
|
|
24
|
+
<el-icon><SetUp /></el-icon>
|
|
25
|
+
</div>
|
|
26
|
+
<p>自定义节点</p>
|
|
27
|
+
</li>
|
|
28
|
+
<li v-if="allow.type4">
|
|
29
|
+
<div class="fc-add-icon" style="color: #15bc83" @click="addType(FlowNodeType.BRANCH)">
|
|
30
|
+
<el-icon><Share /></el-icon>
|
|
31
|
+
</div>
|
|
32
|
+
<p>条件分支</p>
|
|
33
|
+
</li>
|
|
34
|
+
<li v-if="allow.type5">
|
|
35
|
+
<div class="fc-add-icon" style="color: #1bc47d" @click="addType(FlowNodeType.PARALLEL)">
|
|
36
|
+
<el-icon><Grid /></el-icon>
|
|
37
|
+
</div>
|
|
38
|
+
<p>并行分支</p>
|
|
39
|
+
</li>
|
|
40
|
+
<li v-if="allow.type6">
|
|
41
|
+
<div class="fc-add-icon" style="color: #ff8a80" @click="addType(FlowNodeType.INCLUSIVE)">
|
|
42
|
+
<el-icon><Connection /></el-icon>
|
|
43
|
+
</div>
|
|
44
|
+
<p>包容分支</p>
|
|
45
|
+
</li>
|
|
46
|
+
<template v-if="allowTerminal">
|
|
47
|
+
<li>
|
|
48
|
+
<div class="fc-add-icon" style="color: #1bc47d" @click="addType(FlowNodeType.PASS)">
|
|
49
|
+
<el-icon><Select /></el-icon>
|
|
50
|
+
</div>
|
|
51
|
+
<p>直接通过</p>
|
|
52
|
+
</li>
|
|
53
|
+
<li>
|
|
54
|
+
<div class="fc-add-icon" style="color: #f54a4a" @click="addType(FlowNodeType.REJECT)">
|
|
55
|
+
<el-icon><Close /></el-icon>
|
|
56
|
+
</div>
|
|
57
|
+
<p>直接拒绝</p>
|
|
58
|
+
</li>
|
|
59
|
+
</template>
|
|
60
|
+
</ul>
|
|
61
|
+
</div>
|
|
62
|
+
</el-popover>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="add-node-btn-box" v-else>
|
|
66
|
+
<div class="add-node-btn"></div>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<script setup>
|
|
71
|
+
import { computed, inject } from 'vue'
|
|
72
|
+
import {
|
|
73
|
+
Close,
|
|
74
|
+
Connection,
|
|
75
|
+
Grid,
|
|
76
|
+
Plus,
|
|
77
|
+
Promotion,
|
|
78
|
+
Select,
|
|
79
|
+
SetUp,
|
|
80
|
+
Share,
|
|
81
|
+
UserFilled
|
|
82
|
+
} from '@element-plus/icons-vue'
|
|
83
|
+
import {
|
|
84
|
+
FlowNodeType,
|
|
85
|
+
createCustomNodeConfig,
|
|
86
|
+
generateNodeId
|
|
87
|
+
} from '../../core/flow/index.js'
|
|
88
|
+
|
|
89
|
+
defineOptions({ name: 'ScAddNode' })
|
|
90
|
+
|
|
91
|
+
const props = defineProps({
|
|
92
|
+
modelValue: { type: Object, default: null },
|
|
93
|
+
parentNode: { type: Object, default: null },
|
|
94
|
+
readonly: { type: Boolean, default: false }
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const emit = defineEmits(['update:modelValue'])
|
|
98
|
+
|
|
99
|
+
const readonlyAll = inject('scReadonly', false)
|
|
100
|
+
|
|
101
|
+
const isReadonly = computed(() => props.readonly || readonlyAll.value === true)
|
|
102
|
+
|
|
103
|
+
// Parallel / inclusive are only offered outside conditions, matching the
|
|
104
|
+
// original designer's placement rules.
|
|
105
|
+
const allow = computed(() => ({
|
|
106
|
+
type1: true,
|
|
107
|
+
type2: true,
|
|
108
|
+
type4: true,
|
|
109
|
+
type5: props.parentNode?.type !== FlowNodeType.CONDITION,
|
|
110
|
+
type6: props.parentNode?.type !== FlowNodeType.CONDITION,
|
|
111
|
+
type7: true
|
|
112
|
+
}))
|
|
113
|
+
|
|
114
|
+
const allowTerminal = computed(() => {
|
|
115
|
+
const parent = props.parentNode
|
|
116
|
+
if (!parent) return false
|
|
117
|
+
if (![FlowNodeType.CONDITION, FlowNodeType.INCLUSIVE_BRANCH].includes(parent.type)) return false
|
|
118
|
+
const child = parent.childNode
|
|
119
|
+
return !child || child.type === FlowNodeType.END
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const createConditionNode = (name, isDefaultCondition = false) => ({
|
|
123
|
+
nodeId: generateNodeId(),
|
|
124
|
+
nodeName: name,
|
|
125
|
+
type: FlowNodeType.CONDITION,
|
|
126
|
+
conditions: [],
|
|
127
|
+
isDefaultCondition,
|
|
128
|
+
childNode: null
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const addType = (type) => {
|
|
132
|
+
let node = null
|
|
133
|
+
if (type === FlowNodeType.APPROVE) {
|
|
134
|
+
node = {
|
|
135
|
+
nodeId: generateNodeId(),
|
|
136
|
+
nodeName: '审批人',
|
|
137
|
+
type: FlowNodeType.APPROVE,
|
|
138
|
+
approverType: 'user',
|
|
139
|
+
signMode: 'and',
|
|
140
|
+
userList: [],
|
|
141
|
+
userNickNames: {},
|
|
142
|
+
deptNameMap: {},
|
|
143
|
+
roleList: [],
|
|
144
|
+
roleNameMap: {},
|
|
145
|
+
superiorLevel: 1,
|
|
146
|
+
allowTransfer: true,
|
|
147
|
+
rejectStrategy: 'terminate',
|
|
148
|
+
rejectTargetNodeId: null,
|
|
149
|
+
rejectRetryLimit: 0,
|
|
150
|
+
termAuto: false,
|
|
151
|
+
term: 0,
|
|
152
|
+
termMode: 0,
|
|
153
|
+
childNode: props.modelValue || null
|
|
154
|
+
}
|
|
155
|
+
} else if (type === FlowNodeType.CC) {
|
|
156
|
+
node = {
|
|
157
|
+
nodeId: generateNodeId(),
|
|
158
|
+
nodeName: '抄送人',
|
|
159
|
+
type: FlowNodeType.CC,
|
|
160
|
+
userList: [],
|
|
161
|
+
userNickNames: {},
|
|
162
|
+
deptNameMap: {},
|
|
163
|
+
allowInitiatorAddUsers: true,
|
|
164
|
+
childNode: props.modelValue || null
|
|
165
|
+
}
|
|
166
|
+
} else if (type === FlowNodeType.CUSTOM) {
|
|
167
|
+
node = {
|
|
168
|
+
nodeId: generateNodeId(),
|
|
169
|
+
nodeName: '自定义节点',
|
|
170
|
+
type: FlowNodeType.CUSTOM,
|
|
171
|
+
custom: createCustomNodeConfig(),
|
|
172
|
+
childNode: props.modelValue || null
|
|
173
|
+
}
|
|
174
|
+
} else if (type === FlowNodeType.BRANCH) {
|
|
175
|
+
node = {
|
|
176
|
+
nodeId: generateNodeId(),
|
|
177
|
+
nodeName: '条件分支',
|
|
178
|
+
type: FlowNodeType.BRANCH,
|
|
179
|
+
branchList: [createConditionNode('条件1'), createConditionNode('其他条件', true)],
|
|
180
|
+
childNode: props.modelValue || null
|
|
181
|
+
}
|
|
182
|
+
} else if (type === FlowNodeType.PARALLEL) {
|
|
183
|
+
node = {
|
|
184
|
+
nodeId: generateNodeId(),
|
|
185
|
+
nodeName: '并行分支',
|
|
186
|
+
type: FlowNodeType.PARALLEL,
|
|
187
|
+
branchList: [
|
|
188
|
+
{ nodeId: generateNodeId(), nodeName: '分支1', type: FlowNodeType.PARALLEL_BRANCH, branchIndex: 0, childNode: null },
|
|
189
|
+
{ nodeId: generateNodeId(), nodeName: '分支2', type: FlowNodeType.PARALLEL_BRANCH, branchIndex: 1, childNode: null }
|
|
190
|
+
],
|
|
191
|
+
childNode: props.modelValue || null
|
|
192
|
+
}
|
|
193
|
+
} else if (type === FlowNodeType.INCLUSIVE) {
|
|
194
|
+
node = {
|
|
195
|
+
nodeId: generateNodeId(),
|
|
196
|
+
nodeName: '包容分支',
|
|
197
|
+
type: FlowNodeType.INCLUSIVE,
|
|
198
|
+
branchList: [
|
|
199
|
+
{ nodeId: generateNodeId(), nodeName: '条件1', type: FlowNodeType.INCLUSIVE_BRANCH, branchIndex: 0, conditions: [], isDefaultBranch: false, childNode: null },
|
|
200
|
+
{ nodeId: generateNodeId(), nodeName: '其他分支', type: FlowNodeType.INCLUSIVE_BRANCH, branchIndex: 1, conditions: [], isDefaultBranch: true, childNode: null }
|
|
201
|
+
],
|
|
202
|
+
childNode: props.modelValue || null
|
|
203
|
+
}
|
|
204
|
+
} else if (type === FlowNodeType.PASS) {
|
|
205
|
+
node = {
|
|
206
|
+
nodeId: generateNodeId(),
|
|
207
|
+
nodeName: '直接通过',
|
|
208
|
+
type: FlowNodeType.PASS,
|
|
209
|
+
childNode: props.modelValue || null
|
|
210
|
+
}
|
|
211
|
+
} else if (type === FlowNodeType.REJECT) {
|
|
212
|
+
node = {
|
|
213
|
+
nodeId: generateNodeId(),
|
|
214
|
+
nodeName: '直接拒绝',
|
|
215
|
+
type: FlowNodeType.REJECT,
|
|
216
|
+
childNode: props.modelValue || null
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (!node) return
|
|
221
|
+
emit('update:modelValue', node)
|
|
222
|
+
}
|
|
223
|
+
</script>
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="node-wrap">
|
|
3
|
+
<div class="node-wrap-box" :class="statusClass" @click="show">
|
|
4
|
+
<div class="title" style="background: #ff943e">
|
|
5
|
+
<el-icon class="icon"><UserFilled /></el-icon>
|
|
6
|
+
<span>{{ nodeConfig.nodeName }}</span>
|
|
7
|
+
<NodeStatusBadge :status="statusInfo" />
|
|
8
|
+
<el-icon class="close" @click.stop="delNode()"><Close /></el-icon>
|
|
9
|
+
</div>
|
|
10
|
+
<div v-if="!statusInfo" class="content">
|
|
11
|
+
<span v-if="toText(nodeConfig)">{{ toText(nodeConfig) }}</span>
|
|
12
|
+
<span v-else class="placeholder">请选择</span>
|
|
13
|
+
<span class="sc-node-policy">{{ rejectPolicyText }}</span>
|
|
14
|
+
</div>
|
|
15
|
+
<NodeProgressDetail v-else :status="statusInfo" />
|
|
16
|
+
</div>
|
|
17
|
+
<AddNode v-model="nodeConfig.childNode" :parent-node="nodeConfig" :readonly="isReadonly" @update:model-value="updateChild" />
|
|
18
|
+
<el-drawer title="审批人设置" v-model="drawer" destroy-on-close append-to-body :size="500">
|
|
19
|
+
<template #header>
|
|
20
|
+
<div class="node-wrap-drawer__title">
|
|
21
|
+
<label v-if="!isEditTitle" @click="editTitle">
|
|
22
|
+
{{ form.nodeName }}
|
|
23
|
+
<el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
|
|
24
|
+
</label>
|
|
25
|
+
<el-input v-if="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle" />
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
<el-container>
|
|
29
|
+
<el-main style="padding: 0 20px 20px 20px">
|
|
30
|
+
<el-form label-position="top">
|
|
31
|
+
<el-form-item label="审批人员类型">
|
|
32
|
+
<el-select v-model="form.approverType" @change="changeSetType">
|
|
33
|
+
<el-option value="user" label="指定成员" />
|
|
34
|
+
<el-option value="superior_leader" label="主管" />
|
|
35
|
+
<el-option value="role" label="角色" />
|
|
36
|
+
</el-select>
|
|
37
|
+
</el-form-item>
|
|
38
|
+
|
|
39
|
+
<el-form-item v-if="form.approverType === 'user'" label="选择成员">
|
|
40
|
+
<el-button type="primary" :icon="Plus" round @click="selectHandle(1, userProxy)">选择人员</el-button>
|
|
41
|
+
<div class="tags-list">
|
|
42
|
+
<el-tag v-for="(user, index) in form.nodeAssigneeList" :key="user.id" closable @close="delUser(index)">
|
|
43
|
+
{{ user.name }}
|
|
44
|
+
</el-tag>
|
|
45
|
+
</div>
|
|
46
|
+
</el-form-item>
|
|
47
|
+
|
|
48
|
+
<el-form-item v-if="form.approverType === 'superior_leader'" label="指定主管">
|
|
49
|
+
发起人的第 <el-input-number v-model="form.superiorLevel" :min="1" /> 级主管
|
|
50
|
+
</el-form-item>
|
|
51
|
+
|
|
52
|
+
<el-form-item v-if="form.approverType === 'role'" label="选择角色">
|
|
53
|
+
<el-button type="primary" :icon="Plus" round @click="selectHandle(2, roleProxy)">选择角色</el-button>
|
|
54
|
+
<div class="tags-list">
|
|
55
|
+
<el-tag v-for="(role, index) in form.roleList" :key="role.id" type="info" closable @close="delRole(index)">
|
|
56
|
+
{{ role.name }}
|
|
57
|
+
</el-tag>
|
|
58
|
+
</div>
|
|
59
|
+
</el-form-item>
|
|
60
|
+
|
|
61
|
+
<el-divider />
|
|
62
|
+
<el-form-item label="多人审批时审批方式">
|
|
63
|
+
<el-radio-group v-model="form.signMode">
|
|
64
|
+
<p style="width: 100%"><el-radio value="and">会签 (可同时审批,每个人必须审批通过)</el-radio></p>
|
|
65
|
+
<p style="width: 100%"><el-radio value="or">或签 (有一人审批通过即可)</el-radio></p>
|
|
66
|
+
</el-radio-group>
|
|
67
|
+
</el-form-item>
|
|
68
|
+
|
|
69
|
+
<el-divider />
|
|
70
|
+
<el-form-item label="">
|
|
71
|
+
<el-checkbox v-model="form.allowTransfer" label="允许转交"></el-checkbox>
|
|
72
|
+
</el-form-item>
|
|
73
|
+
<el-form-item label="拒绝后处理">
|
|
74
|
+
<el-radio-group v-model="rejectMode">
|
|
75
|
+
<el-radio value="terminate">直接结束(不通过审批)</el-radio>
|
|
76
|
+
<el-radio value="return">退回重新审批</el-radio>
|
|
77
|
+
</el-radio-group>
|
|
78
|
+
</el-form-item>
|
|
79
|
+
<template v-if="rejectMode === 'return'">
|
|
80
|
+
<el-form-item label="退回方式">
|
|
81
|
+
<el-select v-model="form.rejectStrategy" @change="changeRejectStrategy">
|
|
82
|
+
<el-option label="退回上一步" :value="RejectStrategy.TO_PREVIOUS" />
|
|
83
|
+
<el-option label="退回发起人" :value="RejectStrategy.TO_INITIATOR" />
|
|
84
|
+
<el-option label="退回指定审批节点" :value="RejectStrategy.TO_SPECIFIED_NODE" />
|
|
85
|
+
</el-select>
|
|
86
|
+
</el-form-item>
|
|
87
|
+
<el-form-item v-if="form.rejectStrategy === 'to_specified'" label="退回目标节点">
|
|
88
|
+
<el-select v-model="form.rejectTargetNodeId" placeholder="请选择退回后要跳转的审批节点" clearable filterable>
|
|
89
|
+
<el-option
|
|
90
|
+
v-for="node in approveNodes"
|
|
91
|
+
:key="node.nodeId"
|
|
92
|
+
:label="`${node.nodeName}(${node.nodeId})`"
|
|
93
|
+
:value="node.nodeId"
|
|
94
|
+
/>
|
|
95
|
+
</el-select>
|
|
96
|
+
</el-form-item>
|
|
97
|
+
<el-form-item label="本节点允许退回次数">
|
|
98
|
+
<el-input-number v-model="form.rejectRetryLimit" :min="0" :max="99" />
|
|
99
|
+
<span style="margin-left: 8px; color: #94a3b8; font-size: 12px">
|
|
100
|
+
次(0 表示不限次数)
|
|
101
|
+
</span>
|
|
102
|
+
</el-form-item>
|
|
103
|
+
<el-alert
|
|
104
|
+
type="warning"
|
|
105
|
+
:closable="false"
|
|
106
|
+
show-icon
|
|
107
|
+
title="超过本节点允许的退回次数后,再次拒绝会直接终止流程并判定为不通过。"
|
|
108
|
+
/>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<el-divider />
|
|
112
|
+
<el-form-item label="">
|
|
113
|
+
<el-checkbox v-model="form.termAuto" label="超时自动审批"></el-checkbox>
|
|
114
|
+
</el-form-item>
|
|
115
|
+
<template v-if="form.termAuto">
|
|
116
|
+
<el-form-item label="审批期限(为 0 则不生效)">
|
|
117
|
+
<el-input-number v-model="form.term" :min="0" /> 小时
|
|
118
|
+
</el-form-item>
|
|
119
|
+
<el-form-item label="审批期限超时后执行">
|
|
120
|
+
<el-radio-group v-model="form.termMode">
|
|
121
|
+
<el-radio :value="0">自动通过</el-radio>
|
|
122
|
+
<el-radio :value="1">自动拒绝</el-radio>
|
|
123
|
+
</el-radio-group>
|
|
124
|
+
</el-form-item>
|
|
125
|
+
</template>
|
|
126
|
+
</el-form>
|
|
127
|
+
</el-main>
|
|
128
|
+
<el-footer>
|
|
129
|
+
<el-button type="primary" @click="save">保存</el-button>
|
|
130
|
+
<el-button @click="drawer = false">取消</el-button>
|
|
131
|
+
</el-footer>
|
|
132
|
+
</el-container>
|
|
133
|
+
</el-drawer>
|
|
134
|
+
</div>
|
|
135
|
+
</template>
|
|
136
|
+
|
|
137
|
+
<script setup>
|
|
138
|
+
import { computed, inject, ref } from 'vue'
|
|
139
|
+
import { Close, Edit, Plus, UserFilled } from '@element-plus/icons-vue'
|
|
140
|
+
import AddNode from './AddNode.vue'
|
|
141
|
+
import NodeStatusBadge from '../NodeStatusBadge.vue'
|
|
142
|
+
import NodeProgressDetail from '../NodeProgressDetail.vue'
|
|
143
|
+
import { useScNodeStatus } from '../useScNodeStatus.js'
|
|
144
|
+
import { RejectStrategy, traverseNodes } from '../../core/flow/index.js'
|
|
145
|
+
|
|
146
|
+
defineOptions({ name: 'ScApproverNode' })
|
|
147
|
+
|
|
148
|
+
const props = defineProps({
|
|
149
|
+
modelValue: { type: Object, required: true }
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const emit = defineEmits(['update:modelValue'])
|
|
153
|
+
|
|
154
|
+
const select = inject('select', null)
|
|
155
|
+
const readonly = inject('scReadonly', ref(false))
|
|
156
|
+
const flowRoot = inject('scFlowRoot', ref(null))
|
|
157
|
+
|
|
158
|
+
const isReadonly = computed(() => readonly.value === true)
|
|
159
|
+
const nodeConfig = computed(() => props.modelValue)
|
|
160
|
+
const { statusInfo, statusClass } = useScNodeStatus(nodeConfig)
|
|
161
|
+
|
|
162
|
+
const rejectPolicyText = computed(() => {
|
|
163
|
+
const strategy = nodeConfig.value.rejectStrategy || RejectStrategy.TERMINATE
|
|
164
|
+
if (strategy === RejectStrategy.TERMINATE) return '拒绝后结束流程,不通过审批'
|
|
165
|
+
const targetLabel =
|
|
166
|
+
{
|
|
167
|
+
[RejectStrategy.TO_PREVIOUS]: '退回上一步',
|
|
168
|
+
[RejectStrategy.TO_INITIATOR]: '退回发起人',
|
|
169
|
+
[RejectStrategy.TO_SPECIFIED_NODE]: '退回指定节点'
|
|
170
|
+
}[strategy] || '退回重新审批'
|
|
171
|
+
const retryLimit = Math.max(0, Math.floor(Number(nodeConfig.value.rejectRetryLimit) || 0))
|
|
172
|
+
const timeout =
|
|
173
|
+
nodeConfig.value.termAuto && Number(nodeConfig.value.term) > 0
|
|
174
|
+
? ` · 超时 ${nodeConfig.value.term}h 自动${nodeConfig.value.termMode === 1 ? '拒绝' : '通过'}`
|
|
175
|
+
: ''
|
|
176
|
+
return `拒绝后${targetLabel} · ${retryLimit > 0 ? `最多退回 ${retryLimit} 次` : '不限退回次数'}${timeout}`
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const drawer = ref(false)
|
|
180
|
+
const isEditTitle = ref(false)
|
|
181
|
+
const nodeTitle = ref(null)
|
|
182
|
+
const form = ref({})
|
|
183
|
+
|
|
184
|
+
const userProxy = computed({
|
|
185
|
+
get: () => form.value.nodeAssigneeList || [],
|
|
186
|
+
set: () => {}
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
const roleProxy = computed({
|
|
190
|
+
get: () => form.value.roleList || [],
|
|
191
|
+
set: () => {}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const approveNodes = computed(() => {
|
|
195
|
+
const result = []
|
|
196
|
+
traverseNodes(flowRoot.value, (node) => {
|
|
197
|
+
if (node.type === 'approve' && node.nodeId !== nodeConfig.value.nodeId) {
|
|
198
|
+
result.push({ nodeId: node.nodeId, nodeName: node.nodeName })
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
return result
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
const updateChild = (child) => {
|
|
205
|
+
const next = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
206
|
+
next.childNode = child
|
|
207
|
+
emit('update:modelValue', next)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const show = () => {
|
|
211
|
+
if (isReadonly.value) return
|
|
212
|
+
const source = nodeConfig.value
|
|
213
|
+
form.value = {
|
|
214
|
+
...JSON.parse(JSON.stringify(source)),
|
|
215
|
+
approverType: source.approverType || 'user',
|
|
216
|
+
signMode: source.signMode === 'or' ? 'or' : 'and',
|
|
217
|
+
superiorLevel: source.superiorLevel || 1,
|
|
218
|
+
allowTransfer: source.allowTransfer !== false,
|
|
219
|
+
rejectStrategy: source.rejectStrategy || RejectStrategy.TERMINATE,
|
|
220
|
+
rejectRetryLimit:
|
|
221
|
+
Number.isFinite(Number(source.rejectRetryLimit)) && Number(source.rejectRetryLimit) >= 0
|
|
222
|
+
? Math.floor(Number(source.rejectRetryLimit))
|
|
223
|
+
: 0,
|
|
224
|
+
termAuto: source.termAuto === true,
|
|
225
|
+
term: source.term || 0,
|
|
226
|
+
termMode: source.termMode === 1 ? 1 : 0,
|
|
227
|
+
nodeAssigneeList: (source.userList || []).map((id) => ({
|
|
228
|
+
id,
|
|
229
|
+
name: source.userNickNames?.[id] || `用户${id}`,
|
|
230
|
+
deptName: source.deptNameMap?.[id] || ''
|
|
231
|
+
})),
|
|
232
|
+
roleList: (source.roleList || []).map((id) => ({
|
|
233
|
+
id,
|
|
234
|
+
name: source.roleNameMap?.[id] || `角色${id}`
|
|
235
|
+
}))
|
|
236
|
+
}
|
|
237
|
+
isEditTitle.value = false
|
|
238
|
+
drawer.value = true
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const editTitle = () => {
|
|
242
|
+
isEditTitle.value = true
|
|
243
|
+
requestAnimationFrame(() => nodeTitle.value?.focus())
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const saveTitle = () => {
|
|
247
|
+
isEditTitle.value = false
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const selectHandle = (type, data) => {
|
|
251
|
+
select?.(type, data)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const delUser = (index) => {
|
|
255
|
+
form.value.nodeAssigneeList.splice(index, 1)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const delRole = (index) => {
|
|
259
|
+
form.value.roleList.splice(index, 1)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const changeSetType = () => {
|
|
263
|
+
form.value.nodeAssigneeList = form.value.nodeAssigneeList || []
|
|
264
|
+
form.value.roleList = form.value.roleList || []
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const rejectMode = computed({
|
|
268
|
+
get: () =>
|
|
269
|
+
form.value.rejectStrategy === RejectStrategy.TERMINATE ? 'terminate' : 'return',
|
|
270
|
+
set: (mode) => {
|
|
271
|
+
if (mode === 'terminate') {
|
|
272
|
+
form.value.rejectStrategy = RejectStrategy.TERMINATE
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
if (form.value.rejectStrategy === RejectStrategy.TERMINATE) {
|
|
276
|
+
form.value.rejectStrategy = RejectStrategy.TO_INITIATOR
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
const changeRejectStrategy = (value) => {
|
|
282
|
+
if (value !== RejectStrategy.TO_SPECIFIED_NODE) {
|
|
283
|
+
form.value.rejectTargetNodeId = null
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const save = () => {
|
|
288
|
+
const source = JSON.parse(JSON.stringify(nodeConfig.value))
|
|
289
|
+
const users = form.value.nodeAssigneeList || []
|
|
290
|
+
const roles = form.value.roleList || []
|
|
291
|
+
source.nodeName = form.value.nodeName
|
|
292
|
+
source.approverType = form.value.approverType
|
|
293
|
+
source.signMode = form.value.signMode
|
|
294
|
+
source.superiorLevel = form.value.superiorLevel
|
|
295
|
+
source.allowTransfer = form.value.allowTransfer
|
|
296
|
+
source.rejectStrategy = form.value.rejectStrategy
|
|
297
|
+
source.rejectTargetNodeId =
|
|
298
|
+
form.value.rejectStrategy === RejectStrategy.TO_SPECIFIED_NODE ? form.value.rejectTargetNodeId : null
|
|
299
|
+
source.rejectRetryLimit =
|
|
300
|
+
Number.isFinite(Number(form.value.rejectRetryLimit)) && Number(form.value.rejectRetryLimit) >= 0
|
|
301
|
+
? Math.floor(Number(form.value.rejectRetryLimit))
|
|
302
|
+
: 0
|
|
303
|
+
source.termAuto = form.value.termAuto
|
|
304
|
+
source.term = form.value.term
|
|
305
|
+
source.termMode = form.value.termMode
|
|
306
|
+
source.userList = users.map((user) => user.id)
|
|
307
|
+
source.userNickNames = users.reduce((result, user) => {
|
|
308
|
+
result[user.id] = user.name
|
|
309
|
+
return result
|
|
310
|
+
}, {})
|
|
311
|
+
source.deptNameMap = users.reduce((result, user) => {
|
|
312
|
+
if (user.deptName) result[user.id] = user.deptName
|
|
313
|
+
return result
|
|
314
|
+
}, {})
|
|
315
|
+
source.roleList = roles.map((role) => role.id)
|
|
316
|
+
source.roleNameMap = roles.reduce((result, role) => {
|
|
317
|
+
result[role.id] = role.name
|
|
318
|
+
return result
|
|
319
|
+
}, {})
|
|
320
|
+
emit('update:modelValue', source)
|
|
321
|
+
drawer.value = false
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const delNode = () => {
|
|
325
|
+
if (isReadonly.value) return
|
|
326
|
+
emit('update:modelValue', nodeConfig.value.childNode)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const toText = (node) => {
|
|
330
|
+
const approverType = node.approverType || 'user'
|
|
331
|
+
if (approverType === 'user') {
|
|
332
|
+
if (node.userList && node.userList.length > 0) {
|
|
333
|
+
return node.userList.map((id) => node.userNickNames?.[id] || `用户${id}`).join('、')
|
|
334
|
+
}
|
|
335
|
+
return false
|
|
336
|
+
}
|
|
337
|
+
if (approverType === 'superior_leader') {
|
|
338
|
+
return (node.superiorLevel || 1) == 1 ? '直接主管' : `发起人的第${node.superiorLevel}级主管`
|
|
339
|
+
}
|
|
340
|
+
if (approverType === 'role') {
|
|
341
|
+
if (node.roleList && node.roleList.length > 0) {
|
|
342
|
+
return '角色-' + node.roleList.map((id) => node.roleNameMap?.[id] || `角色${id}`).join('、')
|
|
343
|
+
}
|
|
344
|
+
return false
|
|
345
|
+
}
|
|
346
|
+
return false
|
|
347
|
+
}
|
|
348
|
+
</script>
|