gbflowengine 0.1.0 → 0.1.1
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/README.md +271 -271
- package/dist/gbflowengine.css +1 -1
- package/dist/gbflowengine.js +8232 -6913
- package/dist/gbflowengine.js.map +1 -1
- package/dist/gbflowengine.umd.cjs +2 -2
- package/dist/gbflowengine.umd.cjs.map +1 -1
- package/package.json +85 -84
- package/src/center/DefinitionInspect.vue +291 -291
- package/src/center/FlowCenter.vue +33 -33
- package/src/center/index.js +29 -29
- package/src/center/storage.js +748 -748
- package/src/core/flow/condition.js +160 -160
- package/src/core/flow/customNode.js +385 -385
- package/src/core/flow/defaults.js +124 -124
- package/src/core/flow/flowConstant.js +265 -265
- package/src/core/flow/flowNodeUtils.js +29 -29
- package/src/core/flow/index.js +47 -47
- package/src/core/flow/node.js +44 -44
- package/src/core/flow/nodeFactory.js +58 -58
- package/src/core/flow/prediction.js +325 -325
- package/src/core/flow/schema.js +864 -864
- package/src/definition/FlowDefinitionDesigner.vue +338 -338
- package/src/definition/index.js +9 -9
- package/src/index.js +39 -39
- package/src/storage.js +200 -200
- package/src/testing/FlowTestPanel.vue +2502 -2502
- package/src/testing/UserConfigDrawer.vue +376 -376
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
- package/src/testing/diagramModel.js +517 -517
- package/src/testing/index.js +23 -23
- package/src/testing/mock.js +246 -246
- package/src/testing/oaExecutors.js +51 -51
- package/src/testing/oaSeed.js +467 -467
- package/src/testing/sample.js +412 -412
- package/src/testing/seed.js +122 -122
- package/src/utils/format.js +27 -27
- package/src/visual/FlowCanvas.vue +440 -440
- package/src/visual/NodeProgressDetail.vue +43 -43
- package/src/visual/NodeStatusBadge.vue +17 -17
- package/src/visual/NodeWrap.vue +46 -46
- package/src/visual/ScWorkflow.vue +49 -49
- package/src/visual/SelectDialog.vue +459 -459
- package/src/visual/conditionHelpers.js +116 -116
- package/src/visual/index.js +6 -6
- package/src/visual/nodes/AddNode.vue +222 -222
- package/src/visual/nodes/ApproverNode.vue +347 -347
- package/src/visual/nodes/BranchNode.vue +441 -441
- package/src/visual/nodes/CustomNode.vue +339 -339
- package/src/visual/nodes/EndNode.vue +21 -21
- package/src/visual/nodes/PassNode.vue +100 -100
- package/src/visual/nodes/PromoterNode.vue +134 -134
- package/src/visual/nodes/RejectNode.vue +100 -100
- package/src/visual/nodes/SendNode.vue +151 -151
- package/src/visual/styles.scss +879 -879
- package/src/visual/useScNodeStatus.js +18 -18
- package/src/workbench/OaWorkbench.vue +1341 -1341
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
- package/src/workbench/components/CategoryIcon.vue +74 -74
- package/src/workbench/components/NotificationIcon.vue +73 -73
- package/src/workbench/components/ProcessSteps.vue +557 -557
- package/src/workbench/components/ResubmitDialog.vue +227 -227
- package/src/workbench/components/SidebarNav.vue +138 -138
- package/src/workbench/components/StartFlowDialog.vue +1058 -1058
- package/src/workbench/components/UserAvatar.vue +68 -68
- package/src/workbench/model.js +1080 -1080
- package/src/workbench/pages/DesignPage.vue +798 -798
- package/src/workbench/pages/HomePage.vue +1050 -1050
- package/src/workbench/pages/MonitorPage.vue +1029 -1029
- package/src/workbench/pages/NotificationsPage.vue +554 -554
- package/src/workbench/pages/RequestsPage.vue +644 -644
- package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
- package/src/workbench/pages/TemplatesPage.vue +680 -680
- package/src/workbench/styles.scss +555 -555
- package/types/center.d.ts +5 -5
- package/types/core.d.ts +479 -479
- package/types/definition.d.ts +4 -4
- package/types/index.d.ts +34 -34
- package/types/testing.d.ts +20 -20
- package/types/visual.d.ts +20 -20
package/src/testing/seed.js
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 预置实例:让流程中心/测试面板一进来就有数据,实例列表不为空。
|
|
3
|
-
*
|
|
4
|
-
* 这里全部走引擎的公开 API(createFlowRuntime + mock context),
|
|
5
|
-
* 不碰 FlowTestPanel 的内部状态,实例结构与面板自己创建时保持一致。
|
|
6
|
-
*/
|
|
7
|
-
import { createFlowRuntime } from '../core/flow/runtime.js'
|
|
8
|
-
import { createMockRuntimeContext, mockDepartments, mockRoles, mockUsers } from './mock.js'
|
|
9
|
-
import { createSampleDefinition } from './sample.js'
|
|
10
|
-
|
|
11
|
-
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
12
|
-
|
|
13
|
-
const definition = createSampleDefinition()
|
|
14
|
-
|
|
15
|
-
const userById = (id) => mockUsers.find((user) => String(user.id) === String(id)) || mockUsers[0]
|
|
16
|
-
|
|
17
|
-
function toInitiator(user) {
|
|
18
|
-
return {
|
|
19
|
-
id: user.id,
|
|
20
|
-
name: user.realName || user.username || String(user.id),
|
|
21
|
-
deptName: user.deptName || ''
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function pendingApprover(task) {
|
|
26
|
-
const approved = new Set((task.approvedBy || []).map((item) => String(item.id)))
|
|
27
|
-
return (task.approvers || []).find((approver) => !approved.has(String(approver.id))) || null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** 找到第一个审批节点(示例流程里它是「部门主管审批」) */
|
|
31
|
-
function firstApproveNode(node) {
|
|
32
|
-
if (!node) return null
|
|
33
|
-
if (node.type === 'approve') return node
|
|
34
|
-
if (Array.isArray(node.branchList)) {
|
|
35
|
-
for (const branch of node.branchList) {
|
|
36
|
-
const found = firstApproveNode(branch)
|
|
37
|
-
if (found) return found
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return firstApproveNode(node.childNode)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param {object} options
|
|
45
|
-
* @param {number} options.seq 序号(用于名称与 id)
|
|
46
|
-
* @param {number} options.initiatorId 发起人
|
|
47
|
-
* @param {object} options.data 表单数据
|
|
48
|
-
* @param {'running'|'completed'|'rejected'} options.outcome 期望的最终状态
|
|
49
|
-
* @param {number} options.minutesAgo 创建时间往前推几分钟
|
|
50
|
-
*/
|
|
51
|
-
function buildInstance({ seq, initiatorId, data, outcome = 'running', minutesAgo = 30 }) {
|
|
52
|
-
const initiator = userById(initiatorId)
|
|
53
|
-
const context = createMockRuntimeContext({
|
|
54
|
-
initiatorId: initiator.id,
|
|
55
|
-
users: mockUsers,
|
|
56
|
-
departments: mockDepartments,
|
|
57
|
-
roles: mockRoles
|
|
58
|
-
})
|
|
59
|
-
const instanceDefinition = clone(definition)
|
|
60
|
-
// 示例流程的拒绝策略是「退回发起人」,流程会继续运行;
|
|
61
|
-
// 这里把首个审批节点改成「终止流程」,好演示「已拒绝」状态。
|
|
62
|
-
if (outcome === 'rejected') {
|
|
63
|
-
const node = firstApproveNode(instanceDefinition.workflow)
|
|
64
|
-
if (node) node.rejectStrategy = 'terminate'
|
|
65
|
-
}
|
|
66
|
-
const runtime = createFlowRuntime({ workflow: instanceDefinition.workflow, context })
|
|
67
|
-
let state = runtime.start(data, initiator)
|
|
68
|
-
|
|
69
|
-
if (outcome === 'rejected') {
|
|
70
|
-
const task = state.tasks.find((item) => item.status === 'pending')
|
|
71
|
-
const approver = task && pendingApprover(task)
|
|
72
|
-
if (task && approver) state = runtime.reject(task.id, { user: approver, comment: '预算超标,退回补充材料' })
|
|
73
|
-
} else if (outcome === 'completed') {
|
|
74
|
-
let steps = 0
|
|
75
|
-
while (state.status === 'running' && steps < 50) {
|
|
76
|
-
const task = state.tasks.find((item) => item.status === 'pending')
|
|
77
|
-
const approver = task && pendingApprover(task)
|
|
78
|
-
if (!task || !approver) break
|
|
79
|
-
state = runtime.approve(task.id, { user: approver, comment: '演示数据自动推进' })
|
|
80
|
-
steps += 1
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const createdAt = new Date(Date.now() - minutesAgo * 60 * 1000).toISOString()
|
|
85
|
-
return {
|
|
86
|
-
id: `demo_${seq}_${initiator.id}`,
|
|
87
|
-
name: `${definition.meta.name} #${String(seq).padStart(2, '0')}`,
|
|
88
|
-
definition: instanceDefinition,
|
|
89
|
-
initiatorId: initiator.id,
|
|
90
|
-
initiator: toInitiator(initiator),
|
|
91
|
-
extraCcUsers: {},
|
|
92
|
-
createdAt,
|
|
93
|
-
updatedAt: state.endedAt || createdAt,
|
|
94
|
-
state
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function createDemoInstances() {
|
|
99
|
-
return [
|
|
100
|
-
buildInstance({
|
|
101
|
-
seq: 1,
|
|
102
|
-
initiatorId: 1,
|
|
103
|
-
minutesAgo: 15,
|
|
104
|
-
data: { amount: 8600, category: '普通采购', reason: '研发部显示器批量采购', urgent: '否', needInvoice: '是' },
|
|
105
|
-
outcome: 'running'
|
|
106
|
-
}),
|
|
107
|
-
buildInstance({
|
|
108
|
-
seq: 2,
|
|
109
|
-
initiatorId: 2,
|
|
110
|
-
minutesAgo: 180,
|
|
111
|
-
data: { amount: 12800, category: '特殊合同', reason: '设计外包合同签署', urgent: '是', needInvoice: '是' },
|
|
112
|
-
outcome: 'completed'
|
|
113
|
-
}),
|
|
114
|
-
buildInstance({
|
|
115
|
-
seq: 3,
|
|
116
|
-
initiatorId: 3,
|
|
117
|
-
minutesAgo: 320,
|
|
118
|
-
data: { amount: 46000, category: '市场推广', reason: '年度品牌推广预算', urgent: '否', needInvoice: '否' },
|
|
119
|
-
outcome: 'rejected'
|
|
120
|
-
})
|
|
121
|
-
]
|
|
122
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 预置实例:让流程中心/测试面板一进来就有数据,实例列表不为空。
|
|
3
|
+
*
|
|
4
|
+
* 这里全部走引擎的公开 API(createFlowRuntime + mock context),
|
|
5
|
+
* 不碰 FlowTestPanel 的内部状态,实例结构与面板自己创建时保持一致。
|
|
6
|
+
*/
|
|
7
|
+
import { createFlowRuntime } from '../core/flow/runtime.js'
|
|
8
|
+
import { createMockRuntimeContext, mockDepartments, mockRoles, mockUsers } from './mock.js'
|
|
9
|
+
import { createSampleDefinition } from './sample.js'
|
|
10
|
+
|
|
11
|
+
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
12
|
+
|
|
13
|
+
const definition = createSampleDefinition()
|
|
14
|
+
|
|
15
|
+
const userById = (id) => mockUsers.find((user) => String(user.id) === String(id)) || mockUsers[0]
|
|
16
|
+
|
|
17
|
+
function toInitiator(user) {
|
|
18
|
+
return {
|
|
19
|
+
id: user.id,
|
|
20
|
+
name: user.realName || user.username || String(user.id),
|
|
21
|
+
deptName: user.deptName || ''
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function pendingApprover(task) {
|
|
26
|
+
const approved = new Set((task.approvedBy || []).map((item) => String(item.id)))
|
|
27
|
+
return (task.approvers || []).find((approver) => !approved.has(String(approver.id))) || null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 找到第一个审批节点(示例流程里它是「部门主管审批」) */
|
|
31
|
+
function firstApproveNode(node) {
|
|
32
|
+
if (!node) return null
|
|
33
|
+
if (node.type === 'approve') return node
|
|
34
|
+
if (Array.isArray(node.branchList)) {
|
|
35
|
+
for (const branch of node.branchList) {
|
|
36
|
+
const found = firstApproveNode(branch)
|
|
37
|
+
if (found) return found
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return firstApproveNode(node.childNode)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {object} options
|
|
45
|
+
* @param {number} options.seq 序号(用于名称与 id)
|
|
46
|
+
* @param {number} options.initiatorId 发起人
|
|
47
|
+
* @param {object} options.data 表单数据
|
|
48
|
+
* @param {'running'|'completed'|'rejected'} options.outcome 期望的最终状态
|
|
49
|
+
* @param {number} options.minutesAgo 创建时间往前推几分钟
|
|
50
|
+
*/
|
|
51
|
+
function buildInstance({ seq, initiatorId, data, outcome = 'running', minutesAgo = 30 }) {
|
|
52
|
+
const initiator = userById(initiatorId)
|
|
53
|
+
const context = createMockRuntimeContext({
|
|
54
|
+
initiatorId: initiator.id,
|
|
55
|
+
users: mockUsers,
|
|
56
|
+
departments: mockDepartments,
|
|
57
|
+
roles: mockRoles
|
|
58
|
+
})
|
|
59
|
+
const instanceDefinition = clone(definition)
|
|
60
|
+
// 示例流程的拒绝策略是「退回发起人」,流程会继续运行;
|
|
61
|
+
// 这里把首个审批节点改成「终止流程」,好演示「已拒绝」状态。
|
|
62
|
+
if (outcome === 'rejected') {
|
|
63
|
+
const node = firstApproveNode(instanceDefinition.workflow)
|
|
64
|
+
if (node) node.rejectStrategy = 'terminate'
|
|
65
|
+
}
|
|
66
|
+
const runtime = createFlowRuntime({ workflow: instanceDefinition.workflow, context })
|
|
67
|
+
let state = runtime.start(data, initiator)
|
|
68
|
+
|
|
69
|
+
if (outcome === 'rejected') {
|
|
70
|
+
const task = state.tasks.find((item) => item.status === 'pending')
|
|
71
|
+
const approver = task && pendingApprover(task)
|
|
72
|
+
if (task && approver) state = runtime.reject(task.id, { user: approver, comment: '预算超标,退回补充材料' })
|
|
73
|
+
} else if (outcome === 'completed') {
|
|
74
|
+
let steps = 0
|
|
75
|
+
while (state.status === 'running' && steps < 50) {
|
|
76
|
+
const task = state.tasks.find((item) => item.status === 'pending')
|
|
77
|
+
const approver = task && pendingApprover(task)
|
|
78
|
+
if (!task || !approver) break
|
|
79
|
+
state = runtime.approve(task.id, { user: approver, comment: '演示数据自动推进' })
|
|
80
|
+
steps += 1
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const createdAt = new Date(Date.now() - minutesAgo * 60 * 1000).toISOString()
|
|
85
|
+
return {
|
|
86
|
+
id: `demo_${seq}_${initiator.id}`,
|
|
87
|
+
name: `${definition.meta.name} #${String(seq).padStart(2, '0')}`,
|
|
88
|
+
definition: instanceDefinition,
|
|
89
|
+
initiatorId: initiator.id,
|
|
90
|
+
initiator: toInitiator(initiator),
|
|
91
|
+
extraCcUsers: {},
|
|
92
|
+
createdAt,
|
|
93
|
+
updatedAt: state.endedAt || createdAt,
|
|
94
|
+
state
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function createDemoInstances() {
|
|
99
|
+
return [
|
|
100
|
+
buildInstance({
|
|
101
|
+
seq: 1,
|
|
102
|
+
initiatorId: 1,
|
|
103
|
+
minutesAgo: 15,
|
|
104
|
+
data: { amount: 8600, category: '普通采购', reason: '研发部显示器批量采购', urgent: '否', needInvoice: '是' },
|
|
105
|
+
outcome: 'running'
|
|
106
|
+
}),
|
|
107
|
+
buildInstance({
|
|
108
|
+
seq: 2,
|
|
109
|
+
initiatorId: 2,
|
|
110
|
+
minutesAgo: 180,
|
|
111
|
+
data: { amount: 12800, category: '特殊合同', reason: '设计外包合同签署', urgent: '是', needInvoice: '是' },
|
|
112
|
+
outcome: 'completed'
|
|
113
|
+
}),
|
|
114
|
+
buildInstance({
|
|
115
|
+
seq: 3,
|
|
116
|
+
initiatorId: 3,
|
|
117
|
+
minutesAgo: 320,
|
|
118
|
+
data: { amount: 46000, category: '市场推广', reason: '年度品牌推广预算', urgent: '否', needInvoice: '否' },
|
|
119
|
+
outcome: 'rejected'
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}
|
package/src/utils/format.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const pad = (part) => String(part).padStart(2, '0')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Formats an ISO timestamp as `YYYY-MM-DD HH:mm` (or `MM-DD HH:mm` when short).
|
|
5
|
-
* Invalid values are returned as their string form so imported data stays visible.
|
|
6
|
-
*/
|
|
7
|
-
export function formatDateTime(value, { short = false, dateOnly = false } = {}) {
|
|
8
|
-
if (!value) return ''
|
|
9
|
-
const date = new Date(value)
|
|
10
|
-
if (Number.isNaN(date.getTime())) return String(value)
|
|
11
|
-
const day = short
|
|
12
|
-
? `${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
|
13
|
-
: `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
|
14
|
-
return dateOnly ? day : `${day} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Human-readable rendering for form variable values in detail panels. */
|
|
18
|
-
export function formatFieldValue(value) {
|
|
19
|
-
if (value === null || value === undefined || value === '') return '—'
|
|
20
|
-
if (Array.isArray(value)) return value.length ? value.join('、') : '—'
|
|
21
|
-
if (typeof value === 'boolean') return value ? '是' : '否'
|
|
22
|
-
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(value)) {
|
|
23
|
-
return formatDateTime(value, { dateOnly: true })
|
|
24
|
-
}
|
|
25
|
-
if (typeof value === 'object') return JSON.stringify(value)
|
|
26
|
-
return String(value)
|
|
27
|
-
}
|
|
1
|
+
const pad = (part) => String(part).padStart(2, '0')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats an ISO timestamp as `YYYY-MM-DD HH:mm` (or `MM-DD HH:mm` when short).
|
|
5
|
+
* Invalid values are returned as their string form so imported data stays visible.
|
|
6
|
+
*/
|
|
7
|
+
export function formatDateTime(value, { short = false, dateOnly = false } = {}) {
|
|
8
|
+
if (!value) return ''
|
|
9
|
+
const date = new Date(value)
|
|
10
|
+
if (Number.isNaN(date.getTime())) return String(value)
|
|
11
|
+
const day = short
|
|
12
|
+
? `${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
|
13
|
+
: `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
|
14
|
+
return dateOnly ? day : `${day} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Human-readable rendering for form variable values in detail panels. */
|
|
18
|
+
export function formatFieldValue(value) {
|
|
19
|
+
if (value === null || value === undefined || value === '') return '—'
|
|
20
|
+
if (Array.isArray(value)) return value.length ? value.join('、') : '—'
|
|
21
|
+
if (typeof value === 'boolean') return value ? '是' : '否'
|
|
22
|
+
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(value)) {
|
|
23
|
+
return formatDateTime(value, { dateOnly: true })
|
|
24
|
+
}
|
|
25
|
+
if (typeof value === 'object') return JSON.stringify(value)
|
|
26
|
+
return String(value)
|
|
27
|
+
}
|