workflow-editor 0.0.1 → 0.0.2-up

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.
Files changed (125) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +7 -0
  3. package/index.html +13 -0
  4. package/lib/workflow-editor.js +23979 -0
  5. package/package.json +30 -38
  6. package/packages/index.js +34 -0
  7. package/packages/plugins/formValidatorUtil.js +533 -0
  8. package/packages/plugins/index.js +8 -0
  9. package/packages/workflow-editor/index.js +14 -0
  10. package/packages/workflow-editor/src/api.js +7 -0
  11. package/packages/workflow-editor/src/assets/wf-editor-icons.js +2 -0
  12. package/packages/workflow-editor/src/constant.js +8 -0
  13. package/packages/workflow-editor/src/json-object-templates/auto-task.js +70 -0
  14. package/packages/workflow-editor/src/json-object-templates/copy-task.js +72 -0
  15. package/packages/workflow-editor/src/json-object-templates/decision.js +11 -0
  16. package/packages/workflow-editor/src/json-object-templates/end.js +14 -0
  17. package/packages/workflow-editor/src/json-object-templates/fork.js +10 -0
  18. package/packages/workflow-editor/src/json-object-templates/human-decision.js +9 -0
  19. package/packages/workflow-editor/src/json-object-templates/human-task.js +199 -0
  20. package/packages/workflow-editor/src/json-object-templates/join.js +10 -0
  21. package/packages/workflow-editor/src/json-object-templates/process.js +98 -0
  22. package/packages/workflow-editor/src/json-object-templates/start.js +13 -0
  23. package/packages/workflow-editor/src/json-object-templates/subprocess.js +31 -0
  24. package/packages/workflow-editor/src/json-object-templates/transition.js +26 -0
  25. package/packages/workflow-editor/src/main/admin-save-dialog.vue +66 -0
  26. package/packages/workflow-editor/src/main/canvas.vue +483 -0
  27. package/packages/workflow-editor/src/main/context-menu.vue +132 -0
  28. package/packages/workflow-editor/src/main/icon-svg.vue +32 -0
  29. package/packages/workflow-editor/src/main/selection-region.vue +66 -0
  30. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +38 -0
  31. package/packages/workflow-editor/src/main/tache-name-input.vue +19 -0
  32. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +35 -0
  33. package/packages/workflow-editor/src/main/toolbox.vue +60 -0
  34. package/packages/workflow-editor/src/main/wf-history-canvas.vue +304 -0
  35. package/packages/workflow-editor/src/process-json.js +623 -0
  36. package/packages/workflow-editor/src/process-service.js +31 -0
  37. package/packages/workflow-editor/src/properties-editors/auto-task/basic-properties.vue +81 -0
  38. package/packages/workflow-editor/src/properties-editors/auto-task/permission-settings.vue +155 -0
  39. package/packages/workflow-editor/src/properties-editors/auto-task.vue +73 -0
  40. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +531 -0
  41. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +276 -0
  42. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +34 -0
  43. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +239 -0
  44. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +67 -0
  45. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +241 -0
  46. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +23 -0
  47. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +116 -0
  48. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +75 -0
  49. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +125 -0
  50. package/packages/workflow-editor/src/properties-editors/common/notice-reminder.vue +72 -0
  51. package/packages/workflow-editor/src/properties-editors/common/notice.vue +101 -0
  52. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +185 -0
  53. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +83 -0
  54. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +65 -0
  55. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +347 -0
  56. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +63 -0
  57. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +148 -0
  58. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +233 -0
  59. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +386 -0
  60. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +209 -0
  61. package/packages/workflow-editor/src/properties-editors/common/variables.vue +135 -0
  62. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +90 -0
  63. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +155 -0
  64. package/packages/workflow-editor/src/properties-editors/copy-task.vue +94 -0
  65. package/packages/workflow-editor/src/properties-editors/decision.vue +90 -0
  66. package/packages/workflow-editor/src/properties-editors/fork.vue +72 -0
  67. package/packages/workflow-editor/src/properties-editors/human-decision.vue +44 -0
  68. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +60 -0
  69. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +160 -0
  70. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +291 -0
  71. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +249 -0
  72. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +392 -0
  73. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +241 -0
  74. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +220 -0
  75. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +204 -0
  76. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +59 -0
  77. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +207 -0
  78. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +390 -0
  79. package/packages/workflow-editor/src/properties-editors/human-task.vue +109 -0
  80. package/packages/workflow-editor/src/properties-editors/join.vue +44 -0
  81. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +273 -0
  82. package/packages/workflow-editor/src/properties-editors/process/events.vue +76 -0
  83. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +60 -0
  84. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +95 -0
  85. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +28 -0
  86. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +81 -0
  87. package/packages/workflow-editor/src/properties-editors/process.vue +115 -0
  88. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +199 -0
  89. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +26 -0
  90. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +206 -0
  91. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +64 -0
  92. package/packages/workflow-editor/src/properties-editors/subprocess.vue +79 -0
  93. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +53 -0
  94. package/packages/workflow-editor/src/properties-editors/transition.vue +74 -0
  95. package/packages/workflow-editor/src/properties-editors/user-condition.js +177 -0
  96. package/packages/workflow-editor/src/store/getters.js +27 -0
  97. package/packages/workflow-editor/src/store/workflow-editor.js +125 -0
  98. package/packages/workflow-editor/src/taches/auto-task.vue +99 -0
  99. package/packages/workflow-editor/src/taches/common-methods.js +21 -0
  100. package/packages/workflow-editor/src/taches/copy-task.vue +99 -0
  101. package/packages/workflow-editor/src/taches/custom-task.vue +88 -0
  102. package/packages/workflow-editor/src/taches/decision.vue +102 -0
  103. package/packages/workflow-editor/src/taches/end.vue +76 -0
  104. package/packages/workflow-editor/src/taches/fork.vue +102 -0
  105. package/packages/workflow-editor/src/taches/human-decision.vue +102 -0
  106. package/packages/workflow-editor/src/taches/human-task.vue +113 -0
  107. package/packages/workflow-editor/src/taches/join.vue +91 -0
  108. package/packages/workflow-editor/src/taches/joint.vue +177 -0
  109. package/packages/workflow-editor/src/taches/start.vue +76 -0
  110. package/packages/workflow-editor/src/taches/subprocess.vue +99 -0
  111. package/packages/workflow-editor/src/taches/tache-resizer.vue +80 -0
  112. package/packages/workflow-editor/src/transitions/broken-line.vue +91 -0
  113. package/packages/workflow-editor/src/transitions/curve-line.vue +91 -0
  114. package/packages/workflow-editor/src/transitions/straight-line.vue +26 -0
  115. package/packages/workflow-editor/src/transitions/transition.vue +212 -0
  116. package/packages/workflow-editor/src/transitions/virtual-transition.vue +43 -0
  117. package/packages/workflow-editor/src/util.js +489 -0
  118. package/packages/workflow-editor/src/workflow-editor.vue +606 -0
  119. package/packages/workflow-editor/src/workflow-history.vue +153 -0
  120. package/public/vite.svg +1 -0
  121. package/src/i18n/i18n.js +16 -0
  122. package/src/i18n/langs/cn.js +509 -0
  123. package/src/i18n/langs/en.js +551 -0
  124. package/vite.config.js +36 -0
  125. package/lib/super-ui.umd.min.js +0 -2
package/package.json CHANGED
@@ -1,38 +1,30 @@
1
- {
2
- "name": "workflow-editor",
3
- "version": "0.0.1",
4
- "description": "流程编辑器",
5
- "main": "lib/workflow-editor.umd.min.js",
6
- "private": false,
7
- "scripts": {
8
- "serve": "vue-cli-service serve",
9
- "build": "vue-cli-service build",
10
- "lib": "vue-cli-service build --target lib --name super-ui --dest lib packages/index.js",
11
- "lint": "vue-cli-service lint",
12
- "test:e2e": "vue-cli-service test:e2e",
13
- "test:unit": "vue-cli-service test:unit"
14
- },
15
- "dependencies": {
16
- "element-ui": "^2.4.5",
17
- "vue": "^2.5.22",
18
- "vue-router": "^3.0.1",
19
- "vuex": "^3.0.1"
20
- },
21
- "devDependencies": {
22
- "@vue/cli-plugin-babel": "^3.1.1",
23
- "@vue/cli-plugin-e2e-cypress": "^3.1.1",
24
- "@vue/cli-plugin-eslint": "^3.1.1",
25
- "@vue/cli-plugin-unit-mocha": "^3.1.1",
26
- "@vue/cli-service": "^3.1.1",
27
- "@vue/eslint-config-standard": "^4.0.0",
28
- "@vue/test-utils": "^1.0.0-beta.20",
29
- "babel-eslint": "^10.0.1",
30
- "chai": "^4.1.2",
31
- "eslint": "^5.8.0",
32
- "eslint-plugin-vue": "^5.0.0",
33
- "node-sass": "^4.9.0",
34
- "sass-loader": "^7.1.0",
35
- "vue-cli-plugin-element": "^1.0.1",
36
- "vue-template-compiler": "^2.5.21"
37
- }
38
- }
1
+ {
2
+ "name": "workflow-editor",
3
+ "private": false,
4
+ "version": "0.0.2-up",
5
+ "type": "module",
6
+ "main": "lib/workflow-editor.js",
7
+ "scripts": {
8
+ "lib": "vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "file-saver": "2.0.2",
13
+ "js-cookie": "^2.2.1",
14
+ "prismjs": "^1.16.0",
15
+ "xml-js": "^1.6.11"
16
+ },
17
+ "devDependencies": {
18
+ "@vitejs/plugin-vue": "^4.2.3",
19
+ "element-plus": "^2.4.1",
20
+ "imatrix-ui": "0.2.7-up",
21
+ "nprogress": "^0.2.0",
22
+ "sass": "^1.69.4",
23
+ "vite": "^4.4.5",
24
+ "vite-plugin-svg-icons": "^2.0.1",
25
+ "vue": "^3.3.4",
26
+ "vue-i18n": "^9.5.0",
27
+ "vue-router": "^4.2.5",
28
+ "vuex": "^4.1.0"
29
+ }
30
+ }
@@ -0,0 +1,34 @@
1
+ // 依次导入组件库的各个组件
2
+ import workflow from './workflow-editor'
3
+ import formValidator from './../packages/plugins/index'
4
+ const WorkflowEditor = workflow.WorkflowEditor
5
+ const WorkflowHistory = workflow.WorkflowHistory
6
+ const wfEditorStore = workflow.wfEditorStore
7
+
8
+ // 将所有组件都存储起来,方便后续统一注册
9
+ const components = [
10
+ WorkflowEditor,
11
+ WorkflowHistory
12
+ ]
13
+
14
+ // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
15
+ const install = function(Vue) {
16
+ if (install.installed) return
17
+ components.forEach(component => {
18
+ Vue.component(component.name, component)
19
+ })
20
+ // components.map(component => Vue.component(component.name, component))
21
+ Vue.use(formValidator)
22
+ }
23
+
24
+ // 判断是否是直接引入vue的js文件,即全局引用可自动安装所有组件
25
+ if (typeof window !== 'undefined' && window.Vue) {
26
+ install(window.Vue)
27
+ }
28
+
29
+ export default {
30
+ // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
31
+ install,
32
+ WorkflowEditor,
33
+ wfEditorStore
34
+ }
@@ -0,0 +1,533 @@
1
+ import Validator from 'async-validator'
2
+ import {
3
+ getI18n
4
+ } from '../workflow-editor/src/util'
5
+ import {
6
+ parseSubTablePermissionCondition
7
+ } from 'imatrix-ui/src/utils/calculator/calculator-util'
8
+ function getLeafPropRule(editField, dataTypeMap) {
9
+ const rule = {}
10
+ const dataType = editField.dataType
11
+ if (dataType === 'DATE' || dataType === 'TIME') {
12
+ // 对象的值需要是毫秒值数字
13
+ if (editField.valueType && editField.valueType === 'number') {
14
+ // 表示值是毫秒值
15
+ rule.type = 'number'
16
+ }
17
+ rule.message = editField.label + ' ' + getI18n().t('workflowEditorMessage.requiredAndMustBeADate')
18
+ } else if (dataType === 'INTEGER' || dataType === 'LONG') {
19
+ rule.type = 'number'
20
+ rule.message = editField.label + ' ' + getI18n().t('workflowEditorMessage.requiredAndMustBeAnInteger')
21
+ } else if (dataType === 'FLOAT' || dataType === 'DOUBLE') {
22
+ rule.pattern = new RegExp('^(-?\\d+)(\\.\\d+)?$')
23
+ rule.message = editField.label + ' ' + getI18n().t('workflowEditorMessage.requiredAndMustBeDecimal')
24
+ } else if (dataType === 'BOOLEAN') {
25
+ rule.message = editField.label + ' ' + getI18n().t('workflowEditorMessage.mustFill')
26
+ } else {
27
+ // if (entity[editField.name] || entity[editField.name] === 0) {
28
+ // if (typeof entity[editField.name] === 'number' && dataType === 'TEXT') {
29
+ // rule.type = 'number'
30
+ // }
31
+ // }
32
+ rule.message = editField.label + ' ' + getI18n().t('workflowEditorMessage.mustFill')
33
+ }
34
+ if (editField.canEdit) {
35
+ rule.required = true
36
+ // 失去焦点时触发
37
+ rule.trigger = 'blur'
38
+ }
39
+ if (editField.rowIndexes) {
40
+ // 子表时受控制的行记录下标
41
+ rule.rowIndexes = editField.rowIndexes
42
+ }
43
+ if (editField.condition) {
44
+ // 必填条件
45
+ rule.condition = editField.condition
46
+ }
47
+ dataTypeMap[editField.name] = editField.dataType
48
+ return rule
49
+ }
50
+
51
+ /**
52
+ * 获得对象验证规则
53
+ * @param {*} editField 字段信息
54
+ * @param {*} rules 验证规则
55
+ */
56
+ function setObjectPropRule(editField, rules, isSql, dataTypeMap) {
57
+ const rule = {}
58
+ let prop = editField.name
59
+ if (isSql === true) {
60
+ prop = underscoreName(prop)
61
+ }
62
+ if (!rules) {
63
+ rules = {}
64
+ }
65
+ const props = prop.split('.')
66
+ for (let num = 0; num < props.length; num++) {
67
+ const subProp = props[num]
68
+ let objectRule
69
+ if (num === props.length - 1) {
70
+ // 说明是最后一个
71
+ objectRule = getEndObjectRule(rule, props, subProp)
72
+ objectRule.fields[subProp] = getLeafPropRule(editField, dataTypeMap)
73
+ } else {
74
+ let lastObjectRule
75
+ if (num === 0) {
76
+ objectRule = rules
77
+ } else {
78
+ lastObjectRule = getLastObjectRule(rule, props, props[num - 1])
79
+ objectRule = lastObjectRule.fields
80
+ }
81
+ if (!objectRule[subProp]) {
82
+ objectRule[subProp] = {
83
+ type: 'object',
84
+ required: true,
85
+ fields: {}
86
+ }
87
+ }
88
+ if (num === 0) {
89
+ rule[subProp] = objectRule[subProp]
90
+ } else {
91
+ lastObjectRule.fields[subProp] = objectRule[subProp]
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ function getLastObjectRule(rule, props, currentProp) {
98
+ let lastObjectdRule
99
+ for (let i = 0; i < props.length; i++) {
100
+ const subProp = props[i]
101
+ if (i === 0) {
102
+ lastObjectdRule = rule[subProp]
103
+ } else {
104
+ lastObjectdRule = lastObjectdRule.fields[props[i]]
105
+ }
106
+ if (subProp === currentProp) {
107
+ break
108
+ }
109
+ }
110
+ return lastObjectdRule
111
+ }
112
+
113
+ function getEndObjectRule(rule, props, currentProp) {
114
+ let lastObjectdRule
115
+ for (let i = 0; i < props.length; i++) {
116
+ if (i === 0) {
117
+ lastObjectdRule = rule[props[i]]
118
+ } else {
119
+ lastObjectdRule = lastObjectdRule.fields[props[i]]
120
+ }
121
+ if (i !== props.length - 1) {
122
+ const leafSubProp = props[i + 1]
123
+ if (leafSubProp === currentProp) {
124
+ break
125
+ }
126
+ }
127
+ }
128
+ return lastObjectdRule
129
+ }
130
+
131
+ /**
132
+ * 获得主表及子表验证规则
133
+ * @param {editFieldInfos} editFieldInfos 编辑字段信息集合
134
+ * @param {entity} entity 当前表单数据model
135
+ * @param {isSql} isSql 是否是sql操作流程表单,如果是字段名需要修改为下划线命名规则
136
+ */
137
+ function getValidator(editFieldInfos, entity, isSql, additionalParamMap, taskParamMap, contextParameter) {
138
+ // console.log('workflowEditor-getValidator-editFieldInfos=', editFieldInfos, 'entity=', entity, 'isSql', isSql)
139
+ if (typeof (isSql) === 'undefined') {
140
+ isSql = false
141
+ }
142
+ // 主表验证规则
143
+ const rules = {}
144
+ // 子表验证规则,格式为:
145
+ // {prop:
146
+ // {subField1:{required: true},
147
+ // subField2:{required: true}
148
+ // }
149
+ // }
150
+ // 子表整个表的权限
151
+ // {
152
+ // 子表表名1:{required:true/false(必填/禁止编辑),message:'xxx子表必需录入数据'},
153
+ // 子表表名2:{required:true/false(必填/禁止编辑),message:'xxx子表必需录入数据'}
154
+ // }
155
+ const dataTypeMap = {}
156
+ const totalSubRules = {}
157
+ const subRules = {}
158
+ if (editFieldInfos) {
159
+ editFieldInfos.forEach(editField => {
160
+ const canEdit = editField.canEdit
161
+ // 必填
162
+ if (typeof (canEdit) !== 'undefined' && canEdit === true) {
163
+ let prop = editField.name
164
+ if (prop) {
165
+ if (isSql === true) {
166
+ prop = underscoreName(prop)
167
+ }
168
+ const condition = editField.condition
169
+ const parentFormData = null
170
+ let result = null
171
+ if (prop.indexOf('.') > 0 && prop.indexOf('$') === 0) {
172
+ // 当是子表记录时候 result设置为true 获取行记录校验条件
173
+ result = true
174
+ } else {
175
+ result = parseSubTablePermissionCondition(condition, dataTypeMap, parentFormData, entity, additionalParamMap, taskParamMap, contextParameter)
176
+ }
177
+ if (result !== undefined && result !== null && result === true) {
178
+ let rule = {}
179
+ if (prop.indexOf('.') > 0) {
180
+ if (prop.indexOf('$') === 0) {
181
+ // 表示是子表字段
182
+ setSubObjectFieldRule(editField, subRules, entity, isSql, dataTypeMap)
183
+ } else {
184
+ // 表示是主表的关联属性字段。
185
+ setMainObjectFieldRule(editField, rules, entity, isSql, dataTypeMap)
186
+ }
187
+ } else if (prop.indexOf('$') === 0) {
188
+ // 表示是子表整个表的权限
189
+ // 获得子表表名
190
+ const subTable = prop.substring(prop.indexOf('$') + 1)
191
+ totalSubRules[subTable] = {
192
+ required: true,
193
+ message: getI18n().t('workflowEditorMessage.subTableMustInputDatas', {
194
+ subTable: editField.label
195
+ })
196
+ }
197
+ } else {
198
+ // 表示是主表的直接属性
199
+ rule = getLeafPropRule(editField, dataTypeMap, entity)
200
+ rules[prop] = rule
201
+ }
202
+ }
203
+ }
204
+ }
205
+ })
206
+ }
207
+ // console.log('rules', rules, 'subRules=', subRules, 'totalSubRules=', totalSubRules)
208
+ const subRulesKeys = Object.keys(subRules)
209
+ if (subRulesKeys.length > 0 || Object.keys(totalSubRules).length > 0) {
210
+ // 表示有子表规则
211
+ return {
212
+ rules,
213
+ subRules,
214
+ totalSubRules,
215
+ dataTypeMap
216
+ }
217
+ } else {
218
+ // 表示只有主表规则
219
+ return rules
220
+ }
221
+ }
222
+
223
+ /**
224
+ * 设置主对象字段验证规则
225
+ */
226
+ function setMainObjectFieldRule(editField, rules, entity, isSql, dataTypeMap) {
227
+ // 例如:a.b.c
228
+ let prop = editField.name
229
+ if (isSql === true) {
230
+ prop = underscoreName(prop)
231
+ }
232
+ // 获得a
233
+ const mainProp = prop.substring(0, prop.indexOf('.'))
234
+ if (entity) {
235
+ if (!entity[mainProp]) {
236
+ entity[mainProp] = {}
237
+ }
238
+ const mainEntity = entity[mainProp]
239
+ // 说明这个字段是该表单的字段,才需要添加验证
240
+ // 不是该表单的字段的情况,可能是被数据表删除的字段,但是没有修改流程图表单字段权限设置导致的
241
+ // 获得b.c
242
+ const mainSubProp = prop.substring(prop.indexOf('.') + 1)
243
+ if (isNeedValidate(mainSubProp, mainEntity)) {
244
+ // 需要验证该字段,表示是表单的字段
245
+ setObjectPropRule(editField, rules, isSql, dataTypeMap)
246
+ }
247
+ }
248
+ }
249
+
250
+ /**
251
+ * 是否需要验证该属性,例如:b.c 或 a
252
+ * @param {*} mainSubProp 字段信息,例如:字段为:a.b.c,则mainSubProp应为b.c
253
+ * @param {*} mainEntity
254
+ */
255
+ function isNeedValidate(mainSubProp, mainEntity) {
256
+ // 表示由可以必填
257
+ if (mainSubProp.indexOf('.') > 0) {
258
+ let parentObject = mainEntity
259
+ const subProps = mainSubProp.split('.')
260
+ for (let num = 0; num < subProps.length - 1; num++) {
261
+ const subProp = subProps[num]
262
+ if (!parentObject || !parentObject[subProp]) {
263
+ // 当前对象不存在,不是该表单的字段,不需要验证
264
+ return false
265
+ }
266
+ // 重新给"父对象"赋值,为下次循环准备
267
+ parentObject = parentObject[subProp]
268
+ }
269
+ return true
270
+ } else {
271
+ return true
272
+ }
273
+ }
274
+
275
+ function setSubObjectFieldRule(editField, subRules, entity, isSql, dataTypeMap) {
276
+ let prop = editField.name
277
+ if (isSql === true) {
278
+ prop = underscoreName(prop)
279
+ }
280
+ // 获得主表字段名称
281
+ const mainProp = prop.substring(prop.indexOf('$') + 1, prop.indexOf('.'))
282
+ if (!entity) {
283
+ return
284
+ }
285
+ const tableData = entity[mainProp]
286
+ if (typeof (tableData) === 'undefined' || tableData === null || tableData.length === 0) {
287
+ // 表单中不存在该子表字段,不需要验证
288
+ return
289
+ }
290
+ // 获得子表字段名
291
+ const subProp = prop.substring(prop.indexOf('.') + 1)
292
+ // mainProp对应的所有子表字段验证规则信息
293
+ if (!subRules[mainProp]) {
294
+ subRules[mainProp] = {}
295
+ }
296
+ // 修改属性名为去掉$mainProp的字段名
297
+ // 此处要重新拷贝一份字段,否则会导致原字段的name信息被修改
298
+ const copyEditField = JSON.parse(JSON.stringify(editField))
299
+ copyEditField.name = subProp
300
+ if (subProp.indexOf('.') > 0) {
301
+ // 表示关联属性
302
+ const subEntity = tableData[0]
303
+ setMainObjectFieldRule(copyEditField, subRules[mainProp], subEntity, isSql, dataTypeMap)
304
+ } else {
305
+ // 表示是子表的直接属性
306
+ subRules[mainProp][subProp] = getLeafPropRule(copyEditField, dataTypeMap)
307
+ }
308
+ }
309
+
310
+ function validator(entity, validateRules, rowIndex, isSql, pageNum, pageRowIndex) {
311
+ return validatorEntity(entity, validateRules, rowIndex, true, isSql, pageNum, pageRowIndex)
312
+ }
313
+ /**
314
+ *
315
+ * @param {*} entity
316
+ * @param {*} validateRules
317
+ * @param {*} rowIndex
318
+ * @param {*} isShouldRepeateValdate 是否需要再次验证大写字段名
319
+ * @returns
320
+ */
321
+ function validatorEntity(entity, validateRules, rowIndex, isShouldRepeateValdate, isSql, pageNum, pageRowIndex) {
322
+ let result = false
323
+ const validator = new Validator(validateRules)
324
+
325
+ validator.validate(entity, {
326
+ first: true
327
+ },
328
+ (errors, fields) => {
329
+ let fieldName
330
+ if (errors) {
331
+ const message = errors[0]['message']
332
+ fieldName = errors[0]['field']
333
+ if (typeof (rowIndex) !== 'undefined' && rowIndex !== null) {
334
+ // 表示是子表字段验证失败
335
+ if (pageNum !== undefined && pageRowIndex !== undefined) {
336
+ // 表示子表分页时的验证提示信息
337
+ result = getI18n().t('workflowEditorMessage.pageRecordLine', {
338
+ pageNum: pageNum,
339
+ row: pageRowIndex
340
+ }) + ',' + message
341
+ } else {
342
+ result = getI18n().t('workflowEditorMessage.recordLine', {
343
+ row: (rowIndex + 1)
344
+ }) + ',' + message
345
+ }
346
+ } else {
347
+ // 表示是主表字段验证失败
348
+ result = message
349
+ }
350
+ } else {
351
+ result = true
352
+ }
353
+ if (fieldName && isShouldRepeateValdate === true) {
354
+ // 将实体中字段名改为大写,然后再验证一次该字段是否已填值。因为mysql中jdbc获得实体记录字段名是小写的,但是验证规则中字段名是大写的,所以会导致字段验证失败
355
+ const reg1 = /[A-Z]+/ // 大写字母
356
+ if (isSql !== undefined && isSql === true && reg1.test(fieldName) && entity[fieldName.toLowerCase()] !== undefined) {
357
+ const copyEntity = JSON.parse(JSON.stringify(entity))
358
+ copyEntity[fieldName.toUpperCase()] = entity[fieldName.toLowerCase()]
359
+ delete copyEntity[fieldName.toLowerCase()]
360
+ result = validatorEntity(copyEntity, validateRules, rowIndex, false, isSql, pageNum, pageRowIndex)
361
+ }
362
+ }
363
+ })
364
+
365
+ return result
366
+ }
367
+
368
+ /**
369
+ * 验证子表必填验证
370
+ * @param {*}} entity
371
+ * @param {*} subRules
372
+ * @param {*} subTablePageInfo 列表分页信息{列表编码: 每页显示多少条记录}
373
+ */
374
+ function validateSub(entity, subRules, totalSubRules, isSql, dataTypeMap, additionalParamMap, taskParamMap, contextParameter, subTablePageInfo) {
375
+ let copyTotalSubRules = {}
376
+ if (totalSubRules) {
377
+ copyTotalSubRules = JSON.parse(JSON.stringify(totalSubRules))
378
+ }
379
+ if (subRules) {
380
+ console.log('formValidator333--subRules=', subRules)
381
+ const subProps = Object.keys(subRules)
382
+ for (let i = 0; i < subProps.length; i++) {
383
+ const prop = subProps[i]
384
+ const subFieldRule = subRules[prop]
385
+ console.log('formValidator44--subFieldRule=', subFieldRule)
386
+ // 受控制的行下标集合
387
+ const subFieldProps = Object.keys(subFieldRule)
388
+ console.log('formValidator555--subFieldProps=', subFieldProps)
389
+ let subTableData = entity[prop]
390
+ if (!subTableData) {
391
+ // 如果子表集合数据不存在
392
+ subTableData = []
393
+ }
394
+ // 验证整个子表是否已填记录,如果是必填,但是没有子记录集合,则提示
395
+ const validateResult = validateTotalSubTable(copyTotalSubRules, entity, prop)
396
+ if (validateResult !== true) {
397
+ delete copyTotalSubRules[prop]
398
+ return validateResult
399
+ }
400
+ let pageSize
401
+ if (subTablePageInfo && subTablePageInfo[prop]) {
402
+ pageSize = subTablePageInfo[prop].pageSize
403
+ }
404
+ for (let j = 0; j < subTableData.length; j++) {
405
+ const rowData = subTableData[j]
406
+ const rowRule = packageRowRule(subFieldProps, subFieldRule, subTableData[j], dataTypeMap, entity, additionalParamMap, taskParamMap, contextParameter)
407
+ console.log('formValidator666--rowRule=', rowRule)
408
+ let pageNum
409
+ // 每页的记录下标,提示时使用
410
+ let pageRowIndex
411
+ if (pageSize !== undefined && pageSize > 0) {
412
+ pageNum = Math.ceil((j + 1) / pageSize)
413
+ pageRowIndex = (j + 1) - ((pageNum - 1) * pageSize)
414
+ }
415
+ const validateResult = validator(rowData, rowRule, j, isSql, pageNum, pageRowIndex)
416
+ if (validateResult !== true) {
417
+ // 表示验证失败,无需继续验证
418
+ return validateResult
419
+ }
420
+ }
421
+ }
422
+ }
423
+
424
+ for (const subTableName in copyTotalSubRules) {
425
+ const validateResult = validateTotalSubTable(copyTotalSubRules, entity, subTableName)
426
+ if (validateResult !== true) {
427
+ return validateResult
428
+ }
429
+ }
430
+ return true
431
+ }
432
+
433
+ function getEntityId(row) {
434
+ if (row && row.id) {
435
+ return row.id
436
+ } else if (row && row.ID) {
437
+ return row.ID
438
+ }
439
+ }
440
+
441
+ /**
442
+ * 封装行记录的验证规则
443
+ * @param {*}} subProps
444
+ * @param {*} subFieldRule
445
+ * @param {*} rowIndex
446
+ * @returns
447
+ */
448
+ function packageRowRule(subProps, subFieldRule, row, dataTypeMap, parentFormData, additionalParamMap, taskParamMap, contextParameter) {
449
+ const rowId = getEntityId(row)
450
+ const rowRule = {}
451
+ for (let n = 0; n < subProps.length; n++) {
452
+ const field = subProps[n]
453
+ const fieldRule = subFieldRule[field]
454
+ const condition = fieldRule.condition
455
+ const result = parseSubTablePermissionCondition(condition, dataTypeMap, parentFormData, row, additionalParamMap, taskParamMap, contextParameter)
456
+ if (result !== undefined && result !== null && result === true) {
457
+ // 表示由可以必填
458
+ if (rowId === undefined) {
459
+ // 表示是新建的记录,需要验证
460
+ rowRule[field] = fieldRule
461
+ } else {
462
+ // 表示是已保存的记录,验证id是否在可修改的集合内
463
+ const rowIndexes = fieldRule.rowIndexes
464
+ if (!rowIndexes || rowIndexes.indexOf(rowId) >= 0) {
465
+ // 表示该行记录的该字段需要做必填验证
466
+ rowRule[field] = fieldRule
467
+ }
468
+ }
469
+ }
470
+ }
471
+ return rowRule
472
+ }
473
+
474
+ // 验证整个子表是否已填记录
475
+ function validateTotalSubTable(totalSubRules, entity, subTableName) {
476
+ let subTableData = entity[subTableName]
477
+ if (!subTableData) {
478
+ // 如果子表集合数据不存在
479
+ subTableData = []
480
+ }
481
+ if (subTableData.length === 0 && totalSubRules && totalSubRules[subTableName] &&
482
+ totalSubRules[subTableName].required !== undefined && totalSubRules[subTableName].required === true) {
483
+ return totalSubRules[subTableName].message
484
+ }
485
+ return true
486
+ }
487
+
488
+ function formValidator(entity, validateRules, isSql, additionalParamMap, taskParamMap, contextParameter, subTablePageInfo) {
489
+ const validateRulesKeys = Object.keys(validateRules)
490
+ if (validateRulesKeys.indexOf('rules') >= 0 &&
491
+ validateRulesKeys.indexOf('subRules') >= 0 &&
492
+ validateRulesKeys.indexOf('totalSubRules') >= 0) {
493
+ // 表示是带有子表验证规则的
494
+ const rules = validateRules.rules
495
+ const subRules = validateRules.subRules
496
+ const totalSubRules = validateRules.totalSubRules
497
+ const dataTypeMap = validateRules.dataTypeMap
498
+ let validateResult = validator(entity, rules, null, isSql)
499
+ if (validateResult === true) {
500
+ if (subRules || totalSubRules) {
501
+ validateResult = validateSub(entity, subRules, totalSubRules, isSql, dataTypeMap, additionalParamMap, taskParamMap, contextParameter, subTablePageInfo)
502
+ }
503
+ }
504
+ return validateResult
505
+ } else {
506
+ // 表示没有子表验证规则
507
+ return validator(entity, validateRules, null, isSql)
508
+ }
509
+ }
510
+
511
+ // 驼峰命名改为下划线命名,例如:helloWord->hello_world
512
+ function underscoreName(name) {
513
+ // if (name.indexOf('_') > 0) {
514
+ // 如果包括下划线,表示是下划线命名,需要再转换
515
+ return name
516
+ // }
517
+ // return name.replace(/([A-Z])/g, '_$1').toLowerCase()
518
+ }
519
+ // 下划线命名改为驼峰命名,例如:hello_word->helloWorld
520
+ // function camelName(name) {
521
+ // if (name.indexOf('_') < 0) {
522
+ // // 如果不包括下划线不需要转换
523
+ // return name
524
+ // }
525
+ // return name.replace(/_(\w)/g, function(all, letter) {
526
+ // return letter.toUpperCase()
527
+ // })
528
+ // }
529
+
530
+ export default {
531
+ formValidator,
532
+ getValidator
533
+ }
@@ -0,0 +1,8 @@
1
+ import formValidatorService from './formValidatorUtil'
2
+
3
+ export default {
4
+ install: function(Vue, options) {
5
+ Vue.prototype.$formValidator = formValidatorService.formValidator
6
+ Vue.prototype.$getValidator = formValidatorService.getValidator
7
+ }
8
+ }
@@ -0,0 +1,14 @@
1
+ import WorkflowEditor from './src/workflow-editor'
2
+ import wfEditorStore from './src/store/workflow-editor'
3
+ import WorkflowHistory from './src/workflow-history'
4
+
5
+ WorkflowEditor.install = function(Vue) {
6
+ Vue.component(WorkflowEditor.name, WorkflowEditor)
7
+ Vue.component(WorkflowHistory.name, WorkflowHistory)
8
+ }
9
+
10
+ export default {
11
+ WorkflowEditor,
12
+ WorkflowHistory,
13
+ wfEditorStore
14
+ }
@@ -0,0 +1,7 @@
1
+ const apis = {
2
+ refresh() {
3
+ this.showHistory()
4
+ }
5
+ }
6
+
7
+ export default apis