workflow-editor 0.9.68-dw → 0.9.68

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 (120) hide show
  1. package/lib/workflow-editor.css +1 -1
  2. package/lib/workflow-editor.umd.min.js +10 -10
  3. package/package.json +2 -2
  4. package/packages/index.js +34 -0
  5. package/packages/plugins/formValidatorUtil.js +533 -0
  6. package/packages/plugins/index.js +8 -0
  7. package/packages/workflow-editor/index.js +14 -0
  8. package/packages/workflow-editor/src/api.js +7 -0
  9. package/packages/workflow-editor/src/assets/wf-editor-icons.js +2 -0
  10. package/packages/workflow-editor/src/constant.js +8 -0
  11. package/packages/workflow-editor/src/json-object-templates/auto-task.js +70 -0
  12. package/packages/workflow-editor/src/json-object-templates/copy-task.js +72 -0
  13. package/packages/workflow-editor/src/json-object-templates/decision.js +11 -0
  14. package/packages/workflow-editor/src/json-object-templates/end.js +14 -0
  15. package/packages/workflow-editor/src/json-object-templates/fork.js +10 -0
  16. package/packages/workflow-editor/src/json-object-templates/human-decision.js +9 -0
  17. package/packages/workflow-editor/src/json-object-templates/human-task.js +199 -0
  18. package/packages/workflow-editor/src/json-object-templates/join.js +10 -0
  19. package/packages/workflow-editor/src/json-object-templates/process.js +98 -0
  20. package/packages/workflow-editor/src/json-object-templates/start.js +13 -0
  21. package/packages/workflow-editor/src/json-object-templates/subprocess.js +31 -0
  22. package/packages/workflow-editor/src/json-object-templates/transition.js +26 -0
  23. package/packages/workflow-editor/src/main/admin-save-dialog.vue +66 -0
  24. package/packages/workflow-editor/src/main/canvas.vue +483 -0
  25. package/packages/workflow-editor/src/main/context-menu.vue +132 -0
  26. package/packages/workflow-editor/src/main/icon-svg.vue +32 -0
  27. package/packages/workflow-editor/src/main/selection-region.vue +66 -0
  28. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +38 -0
  29. package/packages/workflow-editor/src/main/tache-name-input.vue +19 -0
  30. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +35 -0
  31. package/packages/workflow-editor/src/main/toolbox.vue +60 -0
  32. package/packages/workflow-editor/src/main/wf-history-canvas.vue +304 -0
  33. package/packages/workflow-editor/src/process-json.js +623 -0
  34. package/packages/workflow-editor/src/process-service.js +31 -0
  35. package/packages/workflow-editor/src/properties-editors/auto-task/basic-properties.vue +81 -0
  36. package/packages/workflow-editor/src/properties-editors/auto-task/permission-settings.vue +155 -0
  37. package/packages/workflow-editor/src/properties-editors/auto-task.vue +73 -0
  38. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +556 -0
  39. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +276 -0
  40. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +34 -0
  41. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +239 -0
  42. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +67 -0
  43. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +241 -0
  44. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +23 -0
  45. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +116 -0
  46. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +75 -0
  47. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +125 -0
  48. package/packages/workflow-editor/src/properties-editors/common/notice-reminder.vue +72 -0
  49. package/packages/workflow-editor/src/properties-editors/common/notice.vue +101 -0
  50. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +185 -0
  51. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +83 -0
  52. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +65 -0
  53. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +355 -0
  54. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +63 -0
  55. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +148 -0
  56. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +275 -0
  57. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +386 -0
  58. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +209 -0
  59. package/packages/workflow-editor/src/properties-editors/common/variables.vue +135 -0
  60. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +90 -0
  61. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +155 -0
  62. package/packages/workflow-editor/src/properties-editors/copy-task.vue +94 -0
  63. package/packages/workflow-editor/src/properties-editors/decision.vue +90 -0
  64. package/packages/workflow-editor/src/properties-editors/fork.vue +72 -0
  65. package/packages/workflow-editor/src/properties-editors/human-decision.vue +44 -0
  66. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +60 -0
  67. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +160 -0
  68. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +291 -0
  69. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +249 -0
  70. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +392 -0
  71. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +241 -0
  72. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +220 -0
  73. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +204 -0
  74. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +59 -0
  75. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +207 -0
  76. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +390 -0
  77. package/packages/workflow-editor/src/properties-editors/human-task.vue +109 -0
  78. package/packages/workflow-editor/src/properties-editors/join.vue +44 -0
  79. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +273 -0
  80. package/packages/workflow-editor/src/properties-editors/process/events.vue +76 -0
  81. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +60 -0
  82. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +95 -0
  83. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +28 -0
  84. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +81 -0
  85. package/packages/workflow-editor/src/properties-editors/process.vue +115 -0
  86. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +199 -0
  87. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +26 -0
  88. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +206 -0
  89. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +64 -0
  90. package/packages/workflow-editor/src/properties-editors/subprocess.vue +79 -0
  91. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +53 -0
  92. package/packages/workflow-editor/src/properties-editors/transition.vue +74 -0
  93. package/packages/workflow-editor/src/properties-editors/user-condition.js +183 -0
  94. package/packages/workflow-editor/src/store/getters.js +27 -0
  95. package/packages/workflow-editor/src/store/workflow-editor.js +125 -0
  96. package/packages/workflow-editor/src/taches/auto-task.vue +99 -0
  97. package/packages/workflow-editor/src/taches/common-methods.js +21 -0
  98. package/packages/workflow-editor/src/taches/copy-task.vue +99 -0
  99. package/packages/workflow-editor/src/taches/custom-task.vue +88 -0
  100. package/packages/workflow-editor/src/taches/decision.vue +102 -0
  101. package/packages/workflow-editor/src/taches/end.vue +76 -0
  102. package/packages/workflow-editor/src/taches/fork.vue +102 -0
  103. package/packages/workflow-editor/src/taches/human-decision.vue +102 -0
  104. package/packages/workflow-editor/src/taches/human-task.vue +113 -0
  105. package/packages/workflow-editor/src/taches/join.vue +91 -0
  106. package/packages/workflow-editor/src/taches/joint.vue +177 -0
  107. package/packages/workflow-editor/src/taches/start.vue +76 -0
  108. package/packages/workflow-editor/src/taches/subprocess.vue +99 -0
  109. package/packages/workflow-editor/src/taches/tache-resizer.vue +80 -0
  110. package/packages/workflow-editor/src/transitions/broken-line.vue +91 -0
  111. package/packages/workflow-editor/src/transitions/curve-line.vue +91 -0
  112. package/packages/workflow-editor/src/transitions/straight-line.vue +26 -0
  113. package/packages/workflow-editor/src/transitions/transition.vue +212 -0
  114. package/packages/workflow-editor/src/transitions/virtual-transition.vue +43 -0
  115. package/packages/workflow-editor/src/util.js +489 -0
  116. package/packages/workflow-editor/src/workflow-editor.vue +607 -0
  117. package/packages/workflow-editor/src/workflow-history.vue +153 -0
  118. package/src/i18n/i18n.js +1 -1
  119. package/src/i18n/langs/cn.js +43 -24
  120. package/src/i18n/langs/en.js +23 -7
@@ -0,0 +1,291 @@
1
+ // import modulePageService from '@/subsystems/mms/api/module-page'
2
+ import { getI18n } from '../../../../workflow-editor/src/util'
3
+ const utiljs = {
4
+ // 格式化json
5
+ xmlToData(xmlData) {
6
+ const tableData = []
7
+ if (xmlData) {
8
+ const arr = xmlData.split(' ')
9
+ if (arr && arr.length > 0) {
10
+ let num = 1
11
+ let leftBracket = ''
12
+ let propName = ''
13
+ let operator = ''
14
+ let propValue = ''
15
+ let rightBracket = ''
16
+ let logicOperator = ''
17
+ let propValueType = null
18
+ for (var i = 0; i < arr.length; i++) {
19
+ var str = arr[i]
20
+ if (str.indexOf('(') !== -1) {
21
+ if (this.operationArr) {
22
+ this.operationArr.push([])
23
+ }
24
+ leftBracket = ''
25
+ propName = ''
26
+ operator = ''
27
+ propValue = ''
28
+ rightBracket = ''
29
+ logicOperator = ''
30
+ const leftarr = str.split('${field[')
31
+ leftBracket = leftarr[0]
32
+ propName = leftarr[1].replace(']}', '')
33
+ if (this.operationArr) {
34
+ const operatorsArr = this.getOperators(this.fieldMap[propName])
35
+ this.operationArr[num - 1] = operatorsArr
36
+ }
37
+ continue
38
+ }
39
+ if (str.indexOf('(') === -1 && str.indexOf('${field[') !== -1) {
40
+ if (this.operationArr) {
41
+ this.operationArr.push([])
42
+ }
43
+ leftBracket = ''
44
+ propName = ''
45
+ operator = ''
46
+ propValue = ''
47
+ rightBracket = ''
48
+ logicOperator = ''
49
+ propName = str.replace('${field[', '').replace(']}', '')
50
+ if (this.operationArr) {
51
+ const operatorsArr = this.getOperators(this.fieldMap[propName])
52
+ this.operationArr[num - 1] = operatorsArr
53
+ }
54
+ continue
55
+ }
56
+ if (str.indexOf('operator.') !== -1 && str.indexOf('condition.') === -1) {
57
+ operator = str
58
+ continue
59
+ }
60
+ if (operator !== '' && propValue === '') {
61
+ if (str.indexOf(')') !== -1) {
62
+ if (str.indexOf(')))') !== -1) {
63
+ propValue = str.replace(')))', '')
64
+ rightBracket = ')))'
65
+ } else if (str.indexOf('))') !== -1) {
66
+ propValue = str.replace('))', '')
67
+ rightBracket = '))'
68
+ } else if (str.indexOf(')') !== -1) {
69
+ propValue = str.replace(')', '')
70
+ rightBracket = ')'
71
+ }
72
+ } else {
73
+ propValue = str
74
+ }
75
+ if (propValue && propValue !== '') {
76
+ if (propValue.indexOf('${task.') !== -1) {
77
+ propValueType = 'task'
78
+ } else if (propValue.indexOf('${context.') !== -1) {
79
+ propValueType = 'context'
80
+ } else if (propValue.indexOf('${obj.') !== -1) {
81
+ propValueType = 'obj'
82
+ } else if (propValue.indexOf('${subObj.') !== -1) {
83
+ propValueType = 'subObj'
84
+ } else if (propValue.indexOf('${request.') !== -1) {
85
+ propValueType = 'request'
86
+ } else if (propValue.indexOf('${input.') !== -1) {
87
+ propValueType = 'input'
88
+ } else if (propValue.indexOf('${custom.') !== -1) {
89
+ propValueType = 'custom'
90
+ }
91
+ }
92
+ continue
93
+ }
94
+ if (str.indexOf('condition.') !== -1) {
95
+ logicOperator = str
96
+ tableData.push({
97
+ id: num,
98
+ leftBracket: leftBracket,
99
+ propName: propName,
100
+ operator: operator,
101
+ propValue: propValue,
102
+ rightBracket: rightBracket,
103
+ logicOperator: logicOperator,
104
+ propValueType: propValueType
105
+ })
106
+ num += 1
107
+ } else if (propValue && propValue !== '') {
108
+ if (!logicOperator || logicOperator === '') {
109
+ logicOperator = 'condition.operator.or'
110
+ tableData.push({
111
+ id: num,
112
+ leftBracket: leftBracket,
113
+ propName: propName,
114
+ operator: operator,
115
+ propValue: propValue,
116
+ rightBracket: rightBracket,
117
+ logicOperator: logicOperator,
118
+ propValueType: propValueType
119
+ })
120
+ num += 1
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return tableData
127
+ },
128
+ getOperatorsArr(conditionList) {
129
+ if (conditionList && conditionList.length > 0) {
130
+ for (var i = 0; i < conditionList.length; i++) {
131
+ this.operationArr.push([])
132
+ const item = conditionList[i]
133
+ const operatorsArr = this.getOperators(this.fieldMap[item.propName])
134
+ this.operationArr[i] = operatorsArr
135
+ }
136
+ }
137
+ },
138
+ getRetunrOperatorsArr(conditionList, fieldMap) {
139
+ const operationArr = []
140
+ if (conditionList && conditionList.length > 0) {
141
+ for (var i = 0; i < conditionList.length; i++) {
142
+ operationArr.push([])
143
+ const item = conditionList[i]
144
+ const operatorsArr = this.getOperators(fieldMap[item.propName])
145
+ operationArr[i] = operatorsArr
146
+ }
147
+ }
148
+ return operationArr
149
+ },
150
+ dataToXml(tableData) {
151
+ let stringData = ''
152
+ if (tableData && tableData.length > 0) {
153
+ for (var i = 0; i < tableData.length; i++) {
154
+ var item = tableData[i]
155
+ let logicOperator = logicOperator = item.logicOperator
156
+ if (i === tableData.length - 1) {
157
+ logicOperator = ''
158
+ }
159
+
160
+ stringData = stringData + item.leftBracket + '${field[' + item.propName + ']} ' + item.operator + ' ' + item.propValue + item.rightBracket + ' ' + logicOperator + ' '
161
+ }
162
+ }
163
+ return stringData
164
+ },
165
+ formatConditionList(conditionList) {
166
+ let returnStr = ''
167
+ if (conditionList) {
168
+ if (typeof (conditionList) === 'string') {
169
+ // 先进行转换再解析
170
+ const dataList = this.xmlToData(conditionList)
171
+ returnStr = this.formatConditionListTwo(dataList)
172
+ } else {
173
+ returnStr = this.formatConditionListTwo(conditionList)
174
+ }
175
+ }
176
+ if (returnStr && returnStr !== '') {
177
+ const endStr = returnStr.substring(returnStr.length - 1)
178
+ if (endStr === '者' || endStr === '且') {
179
+ returnStr = returnStr.substring(0, returnStr.length - 2)
180
+ }
181
+ }
182
+ return returnStr
183
+ },
184
+ formatConditionListTwo(conditionList) {
185
+ let returnStr = ''
186
+ if (conditionList && conditionList.length > 0) {
187
+ for (var i = 0; i < conditionList.length; i++) {
188
+ const item = conditionList[i]
189
+ if (item && item.propName) {
190
+ const operatorsArr = this.getOperators(this.fieldMap[item.propName])
191
+ if (operatorsArr && operatorsArr.length > 0) {
192
+ const operator = operatorsArr.filter(operItem => {
193
+ return operItem.name === item.operator
194
+ })
195
+ returnStr += item.leftBracket
196
+ if (this.fieldMap[item.propName] && this.fieldMap[item.propName].label) {
197
+ returnStr += this.fieldMap[item.propName].label + ' '
198
+ }
199
+
200
+ if (operator && operator.length > 0) {
201
+ returnStr += operator[0].label + ' '
202
+ }
203
+ returnStr += item.propValue + item.rightBracket + ' '
204
+ if (item.logicOperator) {
205
+ if (item.logicOperator === 'or') {
206
+ returnStr += '或者'
207
+ } else {
208
+ returnStr += '并且'
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ return returnStr
216
+ },
217
+ // 实时根据类型改变连接符
218
+ getOperators(item) {
219
+ if (item) {
220
+ if (item.type === 'INTEGER' || item.type === 'LONG' || item.type === 'DOUBLE' || item.type === 'FLOAT') {
221
+ return [{
222
+ name: 'operator.number.gt',
223
+ label: getI18n().t('workflowEditor.process.greaterThan')
224
+ }, {
225
+ name: 'operator.number.lt',
226
+ label: getI18n().t('workflowEditor.process.lessThan')
227
+ }, {
228
+ name: 'operator.number.eq',
229
+ label: getI18n().t('workflowEditor.process.beEqualTo')
230
+ }, {
231
+ name: 'operator.number.le',
232
+ label: getI18n().t('workflowEditor.process.notGreaterThan')
233
+ }, {
234
+ name: 'operator.number.ge',
235
+ label: getI18n().t('workflowEditor.process.notLessThan')
236
+ }, {
237
+ name: 'operator.number.ne',
238
+ label: getI18n().t('workflowEditor.process.notEqualTo')
239
+ }]
240
+ } else if (item.type === 'DATE' || item.type === 'TIME') {
241
+ return [{
242
+ name: 'operator.date.gt',
243
+ label: getI18n().t('workflowEditor.process.laterThan')
244
+ }, {
245
+ name: 'operator.date.lt',
246
+ label: getI18n().t('workflowEditor.process.earlierThan')
247
+ }, {
248
+ name: 'operator.date.eq',
249
+ label: getI18n().t('workflowEditor.process.beEqualTo')
250
+ }, {
251
+ name: 'operator.date.le',
252
+ label: getI18n().t('workflowEditor.process.noLaterThan')
253
+ }, {
254
+ name: 'operator.date.ge',
255
+ label: getI18n().t('workflowEditor.process.noEarlierThan')
256
+ }]
257
+ } else if (item.type === 'TEXT') {
258
+ return [{
259
+ name: 'operator.text.eq',
260
+ label: getI18n().t('workflowEditor.process.beEqualTo')
261
+ }, {
262
+ name: 'operator.text.neq',
263
+ label: getI18n().t('workflowEditor.process.notEqualTo')
264
+ }, {
265
+ name: 'operator.text.contain',
266
+ label: getI18n().t('workflowEditor.process.contain')
267
+ }, {
268
+ name: 'operator.text.contain.not',
269
+ label: getI18n().t('workflowEditor.process.notIncluded')
270
+ }]
271
+ } else {
272
+ return [{
273
+ name: 'operator.text.eq',
274
+ label: getI18n().t('workflowEditor.process.beEqualTo')
275
+ }, {
276
+ name: 'operator.text.neq',
277
+ label: getI18n().t('workflowEditor.process.notEqualTo')
278
+ }]
279
+ }
280
+ } else {
281
+ return [{
282
+ name: 'operator.text.eq',
283
+ label: getI18n().t('workflowEditor.process.beEqualTo')
284
+ }, {
285
+ name: 'operator.text.neq',
286
+ label: getI18n().t('workflowEditor.process.notEqualTo')
287
+ }]
288
+ }
289
+ }
290
+ }
291
+ export default utiljs
@@ -0,0 +1,249 @@
1
+ <template>
2
+ <div>
3
+ <el-row>
4
+ <el-button type="primary" size="mini" plain icon="el-icon-circle-plus-outline" @click="add">
5
+ {{ $t('workflowEditorPublicModel.add') }}
6
+ </el-button>
7
+ <el-button type="primary" size="mini" plain icon="el-icon-delete" @click="remove">
8
+ {{ $t('workflowEditorPublicModel.delete') }}
9
+ </el-button>
10
+ <el-table
11
+ ref="table"
12
+ :data="actions"
13
+ row-key="type"
14
+ border
15
+ highlight-current-row
16
+ style="width: 100%"
17
+ @current-change="handleCurrentChange"
18
+ >
19
+ <el-table-column
20
+ type="index"
21
+ />
22
+ <el-table-column
23
+ :label="$t('workflowEditor.task.operationType')"
24
+ width="180"
25
+ >
26
+ <template slot-scope="scope">
27
+ <el-select v-model="scope.row.type" @change="isDuplicated">
28
+ <el-option
29
+ v-for="item in actionTypes"
30
+ :key="item.id"
31
+ :value="item.type"
32
+ :label="item.label"
33
+ />
34
+ </el-select>
35
+ </template>
36
+ </el-table-column>
37
+ <el-table-column
38
+ prop="label"
39
+ :label="$t('workflowEditor.task.name')"
40
+ width="180"
41
+ >
42
+ <template slot-scope="scope">
43
+ <el-input v-model="scope.row.label" />
44
+ </template>
45
+ </el-table-column>
46
+ <el-table-column
47
+ prop="visible"
48
+ :label="$t('workflowEditor.task.visibleOrNot')"
49
+ >
50
+ <template slot-scope="scope">
51
+ <el-checkbox v-model="scope.row.visible" />
52
+ </template>
53
+ </el-table-column>
54
+ <el-table-column
55
+ prop="condition"
56
+ :label="$t('workflowEditor.task.condition')"
57
+ >
58
+ <template slot-scope="scope">
59
+ <el-input
60
+ :value="formatCondition(scope.row.condition)"
61
+ type="textarea"
62
+ autosize
63
+ @focus="selectCondition(scope.row)"
64
+ />
65
+ </template>
66
+ </el-table-column>
67
+ </el-table>
68
+ </el-row>
69
+ <additional-condition-dialog v-if="showAdditionalCondition" v-model="currentRow.condition" @close="showAdditionalCondition=false" />
70
+ </div>
71
+ </template>
72
+ <script>
73
+ import { getI18n } from '../../../../workflow-editor/src/util'
74
+ import AdditionalConditionDialog from './additional-condition-dialog'
75
+ import { parseCondition, displayCondition } from '../common/additional-condition-utils'
76
+ export default {
77
+ name: 'CustomActions',
78
+ components: {
79
+ AdditionalConditionDialog
80
+ },
81
+ props: {
82
+ value: {
83
+ type: Object,
84
+ default: null
85
+ }
86
+ },
87
+ data() {
88
+ const actions = []
89
+ let count = 1
90
+ if (this.value.action) {
91
+ if (Array.isArray(this.value.action)) {
92
+ for (const action of this.value.action) {
93
+ actions.push({
94
+ ...action,
95
+ id: count
96
+ })
97
+ count++
98
+ }
99
+ } else {
100
+ actions.push({
101
+ ...this.value.action,
102
+ id: count
103
+ })
104
+ count++
105
+ }
106
+ }
107
+ return {
108
+ actions,
109
+ actionTypes: [{
110
+ type: 'SAVE',
111
+ label: getI18n().t('workflowEditor.task.save')
112
+ }, {
113
+ type: 'SUBMIT',
114
+ label: getI18n().t('workflowEditor.task.submission')
115
+ }, {
116
+ type: 'APPROVE',
117
+ label: getI18n().t('workflowEditor.task.agree')
118
+ }, {
119
+ type: 'REFUSE',
120
+ label: getI18n().t('workflowEditor.task.disagree')
121
+ }, {
122
+ type: 'AGREEMENT',
123
+ label: getI18n().t('workflowEditor.task.favor')
124
+ }, {
125
+ type: 'OPPOSE',
126
+ label: getI18n().t('workflowEditor.task.opposition')
127
+ }, {
128
+ type: 'KIKEN',
129
+ label: getI18n().t('workflowEditor.task.waiver')
130
+ }, {
131
+ type: 'DRAW',
132
+ label: getI18n().t('workflowEditor.task.receive')
133
+ }, {
134
+ type: 'ABANDON_DRAW',
135
+ label: getI18n().t('workflowEditor.task.giveUp')
136
+ }, {
137
+ type: 'ADD_SIGN',
138
+ label: getI18n().t('workflowEditor.task.additionalSignature')
139
+ }, {
140
+ type: 'REMOVE_SIGN',
141
+ label: getI18n().t('workflowEditor.task.reductionOfSignature')
142
+ }, {
143
+ type: 'ASSIGN_TASK',
144
+ label: getI18n().t('workflowEditor.task.assignTask')
145
+ }, {
146
+ type: 'COPY',
147
+ label: getI18n().t('workflowEditor.task.copyTask')
148
+ }, {
149
+ type: 'GET_BACK_BUTTON',
150
+ label: getI18n().t('workflowEditor.task.retrieveTask')
151
+ }, {
152
+ type: 'READED',
153
+ label: getI18n().t('workflowEditor.task.readTask')
154
+ }, {
155
+ type: 'EXPORT_REPORT',
156
+ label: getI18n().t('workflowEditor.task.exportReport')
157
+ }],
158
+ currentRow: null,
159
+ count,
160
+ showAdditionalCondition: false
161
+ }
162
+ },
163
+ mounted() {
164
+ if (this.actions.length > 0) {
165
+ this.selectRow(this.actions[this.actions.length - 1])
166
+ }
167
+ this.$watch('actions', function(newVal, oldVal) {
168
+ const actions = []
169
+ for (const action of this.actions) {
170
+ const row = {
171
+ ...action
172
+ }
173
+ delete row['id']
174
+ actions.push(row)
175
+ }
176
+ this.$emit('input', { action: actions })
177
+ }, {
178
+ deep: true
179
+ })
180
+ },
181
+ methods: {
182
+ selectRow(row) {
183
+ this.$refs.table.setCurrentRow(row)
184
+ },
185
+ getRowIndex(row) {
186
+ for (let i = 0; i < this.actions.length; i++) {
187
+ if (this.actions[i].id === row.id) {
188
+ return i
189
+ }
190
+ }
191
+ return -1
192
+ },
193
+ handleCurrentChange(val) {
194
+ this.currentRow = val
195
+ },
196
+ isDuplicated(val) {
197
+ const index = this.getRowIndex(this.currentRow)
198
+ console.log('index:' + index)
199
+ for (let i = 0; i < this.actions.length; i++) {
200
+ if (i === index) continue
201
+ if (this.actions[i].type === val) {
202
+ this.$alert(this.$t('workflowEditorMessage.duplicateOperationTypeWithLinePleaseReselect', { row: (i + 1) }))
203
+ this.currentRow.type = ''
204
+ }
205
+ }
206
+ },
207
+ add() {
208
+ for (let i = 0; i < this.actions.length; i++) {
209
+ const action = this.actions[i]
210
+ if (action.type === '' || action.label === '') {
211
+ this.$alert(this.$t('workflowEditorMessage.theOperationTypeOrNameInLineIsEmpty', { row: (i + 1) }))
212
+ return
213
+ }
214
+ }
215
+ const newRow = {
216
+ id: this.count,
217
+ type: '',
218
+ label: '',
219
+ visible: true,
220
+ condition: ''
221
+ }
222
+ this.actions.push(newRow)
223
+ this.selectRow(newRow)
224
+ this.count++
225
+ },
226
+ remove() {
227
+ let index = this.getRowIndex(this.currentRow)
228
+ this.actions.splice(index, 1)
229
+ if (this.actions.length > 0) {
230
+ index = (index <= (this.actions.length - 1) ? index : (this.actions.length - 1))
231
+ this.$refs.table.setCurrentRow(this.actions[index])
232
+ }
233
+ },
234
+ formatCondition(value) {
235
+ if (value === '' || !value) return this.$t('workflowEditor.task.nothing')
236
+ const conditions = []
237
+ parseCondition(conditions, value)
238
+ return displayCondition(conditions)
239
+ },
240
+ selectCondition(row) {
241
+ this.selectRow(row)
242
+ if (!this.currentRow) {
243
+ this.$set(this.currentRow, 'condition', '')
244
+ }
245
+ this.showAdditionalCondition = true
246
+ }
247
+ }
248
+ }
249
+ </script>