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
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
import { ConditionOperator } from 'gbformdesign/core'
|
|
2
|
-
|
|
3
|
-
const EMPTY_OPERATORS = [ConditionOperator.IS_EMPTY, ConditionOperator.IS_NOT_EMPTY]
|
|
4
|
-
|
|
5
|
-
export function isEmptyValue(value) {
|
|
6
|
-
if (value === null || value === undefined) return true
|
|
7
|
-
if (typeof value === 'string') return value.trim() === ''
|
|
8
|
-
if (Array.isArray(value)) return value.length === 0
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function normalizeComparable(value) {
|
|
13
|
-
if (value === null || value === undefined) return ''
|
|
14
|
-
return String(value).trim()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function toNumber(value) {
|
|
18
|
-
if (isEmptyValue(value)) return null
|
|
19
|
-
const num = Number(value)
|
|
20
|
-
return Number.isNaN(num) ? null : num
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function toTimestamp(value) {
|
|
24
|
-
if (isEmptyValue(value)) return null
|
|
25
|
-
const time = new Date(value).getTime()
|
|
26
|
-
return Number.isNaN(time) ? null : time
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function getVariableValue(data, variable) {
|
|
30
|
-
if (!variable) return undefined
|
|
31
|
-
if (data && Object.prototype.hasOwnProperty.call(data, variable)) {
|
|
32
|
-
return data[variable]
|
|
33
|
-
}
|
|
34
|
-
return String(variable)
|
|
35
|
-
.split('.')
|
|
36
|
-
.reduce((current, key) => (current == null ? undefined : current[key]), data)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Evaluates a single condition. Numeric and date operands are compared
|
|
41
|
-
* semantically when both sides can be parsed, otherwise as strings.
|
|
42
|
-
*/
|
|
43
|
-
export function evaluateCondition(condition, data = {}) {
|
|
44
|
-
if (!condition || !condition.variable) return false
|
|
45
|
-
const actual = getVariableValue(data, condition.variable)
|
|
46
|
-
const expected = condition.value
|
|
47
|
-
const operator = condition.operator || ConditionOperator.EQUAL
|
|
48
|
-
|
|
49
|
-
if (operator === ConditionOperator.IS_EMPTY) return isEmptyValue(actual)
|
|
50
|
-
if (operator === ConditionOperator.IS_NOT_EMPTY) return !isEmptyValue(actual)
|
|
51
|
-
|
|
52
|
-
if (operator === ConditionOperator.CONTAINS) {
|
|
53
|
-
if (Array.isArray(actual)) return actual.map(normalizeComparable).includes(normalizeComparable(expected))
|
|
54
|
-
if (isEmptyValue(actual)) return false
|
|
55
|
-
return String(actual).includes(String(expected ?? ''))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (operator === ConditionOperator.NOT_CONTAINS) {
|
|
59
|
-
if (Array.isArray(actual)) return !actual.map(normalizeComparable).includes(normalizeComparable(expected))
|
|
60
|
-
if (isEmptyValue(actual)) return true
|
|
61
|
-
return !String(actual).includes(String(expected ?? ''))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const actualNumber = toNumber(actual)
|
|
65
|
-
const expectedNumber = toNumber(expected)
|
|
66
|
-
const useNumeric =
|
|
67
|
-
actualNumber !== null && expectedNumber !== null && !Array.isArray(actual)
|
|
68
|
-
|
|
69
|
-
if (useNumeric) {
|
|
70
|
-
switch (operator) {
|
|
71
|
-
case ConditionOperator.EQUAL:
|
|
72
|
-
return actualNumber === expectedNumber
|
|
73
|
-
case ConditionOperator.NOT_EQUAL:
|
|
74
|
-
return actualNumber !== expectedNumber
|
|
75
|
-
case ConditionOperator.GREATER_THAN:
|
|
76
|
-
return actualNumber > expectedNumber
|
|
77
|
-
case ConditionOperator.LESS_THAN:
|
|
78
|
-
return actualNumber < expectedNumber
|
|
79
|
-
case ConditionOperator.GREATER_THAN_OR_EQUAL:
|
|
80
|
-
return actualNumber >= expectedNumber
|
|
81
|
-
case ConditionOperator.LESS_THAN_OR_EQUAL:
|
|
82
|
-
return actualNumber <= expectedNumber
|
|
83
|
-
default:
|
|
84
|
-
break
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const actualDate = toTimestamp(actual)
|
|
89
|
-
const expectedDate = toTimestamp(expected)
|
|
90
|
-
const useDate =
|
|
91
|
-
actualDate !== null &&
|
|
92
|
-
expectedDate !== null &&
|
|
93
|
-
typeof actual === 'string' &&
|
|
94
|
-
typeof expected === 'string' &&
|
|
95
|
-
/^\d{4}-\d{2}-\d{2}/.test(actual) &&
|
|
96
|
-
/^\d{4}-\d{2}-\d{2}/.test(expected)
|
|
97
|
-
|
|
98
|
-
const left = useDate ? actualDate : normalizeComparable(actual)
|
|
99
|
-
const right = useDate ? expectedDate : normalizeComparable(expected)
|
|
100
|
-
|
|
101
|
-
switch (operator) {
|
|
102
|
-
case ConditionOperator.EQUAL:
|
|
103
|
-
return left === right
|
|
104
|
-
case ConditionOperator.NOT_EQUAL:
|
|
105
|
-
return left !== right
|
|
106
|
-
case ConditionOperator.GREATER_THAN:
|
|
107
|
-
return left > right
|
|
108
|
-
case ConditionOperator.LESS_THAN:
|
|
109
|
-
return left < right
|
|
110
|
-
case ConditionOperator.GREATER_THAN_OR_EQUAL:
|
|
111
|
-
return left >= right
|
|
112
|
-
case ConditionOperator.LESS_THAN_OR_EQUAL:
|
|
113
|
-
return left <= right
|
|
114
|
-
default:
|
|
115
|
-
return false
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Conditions are linked by the `logic` field of the preceding condition,
|
|
121
|
-
* matching the designer UI where the connector appears after each row.
|
|
122
|
-
*/
|
|
123
|
-
export function evaluateConditionGroup(conditions, data = {}) {
|
|
124
|
-
if (!Array.isArray(conditions) || conditions.length === 0) return true
|
|
125
|
-
let result = evaluateCondition(conditions[0], data)
|
|
126
|
-
for (let i = 1; i < conditions.length; i += 1) {
|
|
127
|
-
const previous = conditions[i - 1]
|
|
128
|
-
const current = evaluateCondition(conditions[i], data)
|
|
129
|
-
result = previous.logic === 'OR' ? result || current : result && current
|
|
130
|
-
}
|
|
131
|
-
return result
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function selectBranchNode(branchNode, data = {}) {
|
|
135
|
-
if (!branchNode || !Array.isArray(branchNode.branchList)) return null
|
|
136
|
-
let fallback = null
|
|
137
|
-
for (const branch of branchNode.branchList) {
|
|
138
|
-
if (branch.isDefaultCondition) {
|
|
139
|
-
fallback = branch
|
|
140
|
-
continue
|
|
141
|
-
}
|
|
142
|
-
if (evaluateConditionGroup(branch.conditions, data)) return branch
|
|
143
|
-
}
|
|
144
|
-
return fallback
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function selectInclusiveBranches(branchNode, data = {}) {
|
|
148
|
-
if (!branchNode || !Array.isArray(branchNode.branchList)) return []
|
|
149
|
-
const selected = []
|
|
150
|
-
let fallback = null
|
|
151
|
-
for (const branch of branchNode.branchList) {
|
|
152
|
-
if (branch.isDefaultBranch) {
|
|
153
|
-
fallback = branch
|
|
154
|
-
continue
|
|
155
|
-
}
|
|
156
|
-
if (evaluateConditionGroup(branch.conditions, data)) selected.push(branch)
|
|
157
|
-
}
|
|
158
|
-
if (selected.length === 0 && fallback) selected.push(fallback)
|
|
159
|
-
return selected
|
|
160
|
-
}
|
|
1
|
+
import { ConditionOperator } from 'gbformdesign/core'
|
|
2
|
+
|
|
3
|
+
const EMPTY_OPERATORS = [ConditionOperator.IS_EMPTY, ConditionOperator.IS_NOT_EMPTY]
|
|
4
|
+
|
|
5
|
+
export function isEmptyValue(value) {
|
|
6
|
+
if (value === null || value === undefined) return true
|
|
7
|
+
if (typeof value === 'string') return value.trim() === ''
|
|
8
|
+
if (Array.isArray(value)) return value.length === 0
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function normalizeComparable(value) {
|
|
13
|
+
if (value === null || value === undefined) return ''
|
|
14
|
+
return String(value).trim()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function toNumber(value) {
|
|
18
|
+
if (isEmptyValue(value)) return null
|
|
19
|
+
const num = Number(value)
|
|
20
|
+
return Number.isNaN(num) ? null : num
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function toTimestamp(value) {
|
|
24
|
+
if (isEmptyValue(value)) return null
|
|
25
|
+
const time = new Date(value).getTime()
|
|
26
|
+
return Number.isNaN(time) ? null : time
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getVariableValue(data, variable) {
|
|
30
|
+
if (!variable) return undefined
|
|
31
|
+
if (data && Object.prototype.hasOwnProperty.call(data, variable)) {
|
|
32
|
+
return data[variable]
|
|
33
|
+
}
|
|
34
|
+
return String(variable)
|
|
35
|
+
.split('.')
|
|
36
|
+
.reduce((current, key) => (current == null ? undefined : current[key]), data)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Evaluates a single condition. Numeric and date operands are compared
|
|
41
|
+
* semantically when both sides can be parsed, otherwise as strings.
|
|
42
|
+
*/
|
|
43
|
+
export function evaluateCondition(condition, data = {}) {
|
|
44
|
+
if (!condition || !condition.variable) return false
|
|
45
|
+
const actual = getVariableValue(data, condition.variable)
|
|
46
|
+
const expected = condition.value
|
|
47
|
+
const operator = condition.operator || ConditionOperator.EQUAL
|
|
48
|
+
|
|
49
|
+
if (operator === ConditionOperator.IS_EMPTY) return isEmptyValue(actual)
|
|
50
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) return !isEmptyValue(actual)
|
|
51
|
+
|
|
52
|
+
if (operator === ConditionOperator.CONTAINS) {
|
|
53
|
+
if (Array.isArray(actual)) return actual.map(normalizeComparable).includes(normalizeComparable(expected))
|
|
54
|
+
if (isEmptyValue(actual)) return false
|
|
55
|
+
return String(actual).includes(String(expected ?? ''))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (operator === ConditionOperator.NOT_CONTAINS) {
|
|
59
|
+
if (Array.isArray(actual)) return !actual.map(normalizeComparable).includes(normalizeComparable(expected))
|
|
60
|
+
if (isEmptyValue(actual)) return true
|
|
61
|
+
return !String(actual).includes(String(expected ?? ''))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const actualNumber = toNumber(actual)
|
|
65
|
+
const expectedNumber = toNumber(expected)
|
|
66
|
+
const useNumeric =
|
|
67
|
+
actualNumber !== null && expectedNumber !== null && !Array.isArray(actual)
|
|
68
|
+
|
|
69
|
+
if (useNumeric) {
|
|
70
|
+
switch (operator) {
|
|
71
|
+
case ConditionOperator.EQUAL:
|
|
72
|
+
return actualNumber === expectedNumber
|
|
73
|
+
case ConditionOperator.NOT_EQUAL:
|
|
74
|
+
return actualNumber !== expectedNumber
|
|
75
|
+
case ConditionOperator.GREATER_THAN:
|
|
76
|
+
return actualNumber > expectedNumber
|
|
77
|
+
case ConditionOperator.LESS_THAN:
|
|
78
|
+
return actualNumber < expectedNumber
|
|
79
|
+
case ConditionOperator.GREATER_THAN_OR_EQUAL:
|
|
80
|
+
return actualNumber >= expectedNumber
|
|
81
|
+
case ConditionOperator.LESS_THAN_OR_EQUAL:
|
|
82
|
+
return actualNumber <= expectedNumber
|
|
83
|
+
default:
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const actualDate = toTimestamp(actual)
|
|
89
|
+
const expectedDate = toTimestamp(expected)
|
|
90
|
+
const useDate =
|
|
91
|
+
actualDate !== null &&
|
|
92
|
+
expectedDate !== null &&
|
|
93
|
+
typeof actual === 'string' &&
|
|
94
|
+
typeof expected === 'string' &&
|
|
95
|
+
/^\d{4}-\d{2}-\d{2}/.test(actual) &&
|
|
96
|
+
/^\d{4}-\d{2}-\d{2}/.test(expected)
|
|
97
|
+
|
|
98
|
+
const left = useDate ? actualDate : normalizeComparable(actual)
|
|
99
|
+
const right = useDate ? expectedDate : normalizeComparable(expected)
|
|
100
|
+
|
|
101
|
+
switch (operator) {
|
|
102
|
+
case ConditionOperator.EQUAL:
|
|
103
|
+
return left === right
|
|
104
|
+
case ConditionOperator.NOT_EQUAL:
|
|
105
|
+
return left !== right
|
|
106
|
+
case ConditionOperator.GREATER_THAN:
|
|
107
|
+
return left > right
|
|
108
|
+
case ConditionOperator.LESS_THAN:
|
|
109
|
+
return left < right
|
|
110
|
+
case ConditionOperator.GREATER_THAN_OR_EQUAL:
|
|
111
|
+
return left >= right
|
|
112
|
+
case ConditionOperator.LESS_THAN_OR_EQUAL:
|
|
113
|
+
return left <= right
|
|
114
|
+
default:
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Conditions are linked by the `logic` field of the preceding condition,
|
|
121
|
+
* matching the designer UI where the connector appears after each row.
|
|
122
|
+
*/
|
|
123
|
+
export function evaluateConditionGroup(conditions, data = {}) {
|
|
124
|
+
if (!Array.isArray(conditions) || conditions.length === 0) return true
|
|
125
|
+
let result = evaluateCondition(conditions[0], data)
|
|
126
|
+
for (let i = 1; i < conditions.length; i += 1) {
|
|
127
|
+
const previous = conditions[i - 1]
|
|
128
|
+
const current = evaluateCondition(conditions[i], data)
|
|
129
|
+
result = previous.logic === 'OR' ? result || current : result && current
|
|
130
|
+
}
|
|
131
|
+
return result
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function selectBranchNode(branchNode, data = {}) {
|
|
135
|
+
if (!branchNode || !Array.isArray(branchNode.branchList)) return null
|
|
136
|
+
let fallback = null
|
|
137
|
+
for (const branch of branchNode.branchList) {
|
|
138
|
+
if (branch.isDefaultCondition) {
|
|
139
|
+
fallback = branch
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
if (evaluateConditionGroup(branch.conditions, data)) return branch
|
|
143
|
+
}
|
|
144
|
+
return fallback
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function selectInclusiveBranches(branchNode, data = {}) {
|
|
148
|
+
if (!branchNode || !Array.isArray(branchNode.branchList)) return []
|
|
149
|
+
const selected = []
|
|
150
|
+
let fallback = null
|
|
151
|
+
for (const branch of branchNode.branchList) {
|
|
152
|
+
if (branch.isDefaultBranch) {
|
|
153
|
+
fallback = branch
|
|
154
|
+
continue
|
|
155
|
+
}
|
|
156
|
+
if (evaluateConditionGroup(branch.conditions, data)) selected.push(branch)
|
|
157
|
+
}
|
|
158
|
+
if (selected.length === 0 && fallback) selected.push(fallback)
|
|
159
|
+
return selected
|
|
160
|
+
}
|