resolver-egretimp-plus 0.1.13 → 0.1.15
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/dist/h5/index.js +18 -18
- package/dist/theme/element/index.css +1 -1
- package/dist/theme/element/src/index.scss +1 -0
- package/dist/web/index.js +2 -2
- package/package.json +1 -1
- package/src/bpm/bpmInstance.js +116 -30
- package/src/components/helper/eventOrchestration.js +15 -33
- package/src/components/packages-H5/CustomComponentTableH5.vue +6 -0
- package/src/index.jsx +15 -52
- package/src/theme/element/index.scss +1 -0
- package/src/utils/common.js +31 -0
- package/src/utils/respone.js +4 -3
package/package.json
CHANGED
package/src/bpm/bpmInstance.js
CHANGED
|
@@ -37,16 +37,21 @@ export const MESSAGE_TYPE = {
|
|
|
37
37
|
export let bpmInstance = null
|
|
38
38
|
|
|
39
39
|
export class Bpm {
|
|
40
|
+
params = {}
|
|
41
|
+
bpmConfigs = {}
|
|
40
42
|
eventData = null
|
|
41
43
|
postOptions = null
|
|
42
44
|
sdkInstance = null
|
|
43
45
|
postMessageData = null
|
|
44
46
|
actions = {}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
nativeMethods = {}
|
|
48
|
+
saveResponse = null
|
|
49
|
+
constructor(postMessageData, actions, bpmConfigs, params) {
|
|
47
50
|
this.postMessageData = postMessageData
|
|
48
51
|
this.actions = actions
|
|
49
|
-
|
|
52
|
+
this.bpmConfigs = bpmConfigs || {}
|
|
53
|
+
this.params = params || {}
|
|
54
|
+
this.setNativeMethods()
|
|
50
55
|
this.init()
|
|
51
56
|
}
|
|
52
57
|
init() {
|
|
@@ -55,8 +60,52 @@ export class Bpm {
|
|
|
55
60
|
}
|
|
56
61
|
window.addEventListener("message", this.messageListener.bind(this))
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
setNativeMethods() {
|
|
64
|
+
const { validate, dynamicMapComp, bpmSubmitBtn, toExecuteLoadServices } = this.params
|
|
65
|
+
const toSave = (cb, eventData) => {
|
|
66
|
+
const saveButton = dynamicMapComp[bpmSubmitBtn]
|
|
67
|
+
if (saveButton) {
|
|
68
|
+
const createAfterRequestService = (fn) => {
|
|
69
|
+
return async (ret) => {
|
|
70
|
+
const { saveAfter } = this.bpmConfigs
|
|
71
|
+
this.saveResponse = ret
|
|
72
|
+
try {
|
|
73
|
+
await saveAfter?.(ret, eventData)
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('saveAfter error, error:', error)
|
|
76
|
+
}
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
fn?.(ret)
|
|
79
|
+
}, 0);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (cb && typeof cb === 'function') {
|
|
83
|
+
saveButton?.vm?.click({
|
|
84
|
+
afterRequestService: createAfterRequestService((ret) => { cb(ret) })
|
|
85
|
+
})
|
|
86
|
+
} else {
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
saveButton?.vm?.click({
|
|
89
|
+
// 保存成功的回调
|
|
90
|
+
afterRequestService: createAfterRequestService((ret) => { resolve(ret) })
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
messageInstance?.warning?.('no set bpmSubmitBtn, or bpmSubmitBtn is invalid, at preset, bpmSubmitBtn:', props.bpmSubmitBtn)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const getDetail = () => {
|
|
99
|
+
const { getDetailReq } = this.bpmConfigs
|
|
100
|
+
const params = getDetailReq?.(this.saveResponse)
|
|
101
|
+
toExecuteLoadServices(true, true, { params })
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.nativeMethods = {
|
|
105
|
+
validate,
|
|
106
|
+
toSave,
|
|
107
|
+
getDetail
|
|
108
|
+
}
|
|
60
109
|
}
|
|
61
110
|
messageListener(event) {
|
|
62
111
|
console.log('message event===:', event)
|
|
@@ -86,19 +135,14 @@ export class Bpm {
|
|
|
86
135
|
eventData: this.eventData,
|
|
87
136
|
})
|
|
88
137
|
}
|
|
89
|
-
|
|
90
|
-
let action = this.actions?.[submitType]?.getForm
|
|
138
|
+
let action = this.actions?.[submitType]?.formAction
|
|
91
139
|
if (!action) {
|
|
92
|
-
action = ()
|
|
93
|
-
return defaultAction?.({
|
|
94
|
-
eventData: this.eventData
|
|
95
|
-
})
|
|
96
|
-
}
|
|
140
|
+
action = this.getDefaultAction(data)
|
|
97
141
|
}
|
|
98
142
|
if (action) {
|
|
99
|
-
let valid = action?.({
|
|
143
|
+
let valid = await action?.({
|
|
100
144
|
eventData: this.eventData,
|
|
101
|
-
|
|
145
|
+
nativeMethods: this.nativeMethods,
|
|
102
146
|
})
|
|
103
147
|
if (valid === false) {
|
|
104
148
|
return
|
|
@@ -106,30 +150,21 @@ export class Bpm {
|
|
|
106
150
|
}
|
|
107
151
|
this.postMessage(postMessageData)
|
|
108
152
|
} else if (MESSAGE_TYPE.PROCESS_ACTION_SUCCESS === messageType) {
|
|
109
|
-
let closeFlag =
|
|
110
|
-
closeFlag = [SUBMIT_TYPE.PROCESS_SHOW, SUBMIT_TYPE.BACK, SUBMIT_TYPE.DRAFT_HANDLE].includes(submitType)
|
|
153
|
+
let closeFlag = true
|
|
154
|
+
closeFlag = ![SUBMIT_TYPE.PROCESS_SHOW, SUBMIT_TYPE.BACK, SUBMIT_TYPE.DRAFT_HANDLE].includes(submitType)
|
|
111
155
|
|
|
112
|
-
|
|
113
|
-
const action = this.actions?.[submitType]?.success
|
|
156
|
+
let action = this.actions?.[submitType]?.successAction
|
|
114
157
|
if (!action) {
|
|
115
|
-
action = ()
|
|
116
|
-
return defaultAction?.({
|
|
117
|
-
eventData: this.eventData
|
|
118
|
-
})
|
|
119
|
-
}
|
|
158
|
+
action = this.getDefaultAction(data)
|
|
120
159
|
}
|
|
121
160
|
if (action) {
|
|
122
|
-
|
|
161
|
+
closeFlag = await action?.({
|
|
123
162
|
eventData: this.eventData,
|
|
124
|
-
postMessageData,
|
|
125
163
|
originCloseFlag: closeFlag,
|
|
126
|
-
|
|
164
|
+
nativeMethods: this.nativeMethods,
|
|
127
165
|
})
|
|
128
|
-
if (valid === false) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
166
|
}
|
|
132
|
-
this.postMessage(null, { closeFlag })
|
|
167
|
+
this.postMessage(null, { closeFlag: !!closeFlag })
|
|
133
168
|
}
|
|
134
169
|
}
|
|
135
170
|
setSaveMessage() {
|
|
@@ -175,6 +210,57 @@ export class Bpm {
|
|
|
175
210
|
}
|
|
176
211
|
}
|
|
177
212
|
}
|
|
213
|
+
getDefaultAction(eventData) {
|
|
214
|
+
const { messageType, submitType } = eventData
|
|
215
|
+
if (MESSAGE_TYPE.GET_FORM_DATA === messageType) {
|
|
216
|
+
switch (submitType) {
|
|
217
|
+
case SUBMIT_TYPE.SEND:
|
|
218
|
+
case SUBMIT_TYPE.SUBMIT:
|
|
219
|
+
case SUBMIT_TYPE.AGREE:
|
|
220
|
+
return (eventData) => {
|
|
221
|
+
const { validate, toSave, getDetail } = this.nativeMethods
|
|
222
|
+
return new Promise((resolve) => {
|
|
223
|
+
validate((valid) => {
|
|
224
|
+
if (valid) {
|
|
225
|
+
toSave((ret) => {
|
|
226
|
+
if (ret?.data?.success) {
|
|
227
|
+
getDetail()
|
|
228
|
+
resolve(true)
|
|
229
|
+
} else {
|
|
230
|
+
resolve(false)
|
|
231
|
+
}
|
|
232
|
+
}, eventData)
|
|
233
|
+
} else {
|
|
234
|
+
resolve(false)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
case SUBMIT_TYPE.NOTICE:
|
|
240
|
+
case SUBMIT_TYPE.GIVE:
|
|
241
|
+
case SUBMIT_TYPE.DRAFT_HANDLE:
|
|
242
|
+
case SUBMIT_TYPE.MULTI_COOPERATE:
|
|
243
|
+
return (eventData) => {
|
|
244
|
+
const actionType = eventData?.bpmInfo?.actionType
|
|
245
|
+
const { toSave, getDetail } = this.nativeMethods
|
|
246
|
+
return new Promise((resolve) => {
|
|
247
|
+
if (!actionType) {
|
|
248
|
+
toSave((ret) => {
|
|
249
|
+
if (ret?.data?.success) {
|
|
250
|
+
getDetail()
|
|
251
|
+
resolve(true)
|
|
252
|
+
} else {
|
|
253
|
+
resolve(false)
|
|
254
|
+
}
|
|
255
|
+
}, eventData)
|
|
256
|
+
} else {
|
|
257
|
+
resolve(true)
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
178
264
|
// 暂时没用到=======start======
|
|
179
265
|
on(key, fn) {
|
|
180
266
|
let fns = this.actions[key] || (this.actions[key] = [])
|
|
@@ -2,38 +2,9 @@ import { isArray, isHasVal, isNull, isUndefined } from "../../utils/is"
|
|
|
2
2
|
import { DATA_VALID_RULE_EXECUTE } from "../../api/builtIn"
|
|
3
3
|
import { getRelateConfigKeys } from "../../rules/ruleUtils"
|
|
4
4
|
import { RESULT_CODE, resultToast } from "../../utils/respone"
|
|
5
|
-
import { isPromise, modelValueDeepMerge, parseExtendAttr, unionWith } from "../../utils/index"
|
|
5
|
+
import { assignmentPathVal, getPathVal, isPromise, modelValueDeepMerge, parseExtendAttr, unionWith } from "../../utils/index"
|
|
6
6
|
import { buildInRequest } from "../../utils/request"
|
|
7
|
-
|
|
8
|
-
function getPathVal(obj = {}, path) {
|
|
9
|
-
let paths = path
|
|
10
|
-
if (typeof path === 'string') {
|
|
11
|
-
paths = path.split('.')
|
|
12
|
-
}
|
|
13
|
-
return paths.reduce((ret, key) => {
|
|
14
|
-
if (ret) {
|
|
15
|
-
return ret[key]
|
|
16
|
-
}
|
|
17
|
-
return null
|
|
18
|
-
}, obj) ?? ''
|
|
19
|
-
}
|
|
20
|
-
function assignmentPathVal(obj = {}, path, val) {
|
|
21
|
-
let paths = path
|
|
22
|
-
if (typeof path === 'string') {
|
|
23
|
-
paths = path.split('.')
|
|
24
|
-
}
|
|
25
|
-
let currentObj = obj
|
|
26
|
-
paths.forEach((item, idx) => {
|
|
27
|
-
if (idx + 1 === paths.length) {
|
|
28
|
-
currentObj[item] = val ?? ''
|
|
29
|
-
} else {
|
|
30
|
-
if (!currentObj[item]) {
|
|
31
|
-
currentObj[item] = {}
|
|
32
|
-
}
|
|
33
|
-
currentObj = currentObj[item]
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
7
|
+
import { bpmInstance } from "../../bpm/bpmInstance"
|
|
37
8
|
|
|
38
9
|
export async function dispatchClickEvents ({serviceList = [], requestTraceId, axiosInstance, dialogReq, dynamicMapComp, rootValue, dynamicHireRelat, messageCb, compConfig, messageInstance, lang, beforeRequestService, afterRequestService}) {
|
|
39
10
|
const dynamicMapCompKeys = Object.keys(dynamicMapComp)
|
|
@@ -164,7 +135,16 @@ export async function dispatchClickEvent(service, {
|
|
|
164
135
|
}
|
|
165
136
|
|
|
166
137
|
const noSuccessIip = httpMethod.toLocaleLowerCase() === 'get' || service.transactionType == '1' || serviceCustomProps?.noSuccessIip
|
|
167
|
-
|
|
138
|
+
const toastParmas = {
|
|
139
|
+
messageCb,
|
|
140
|
+
service,
|
|
141
|
+
compConfig,
|
|
142
|
+
noSuccessIip
|
|
143
|
+
}
|
|
144
|
+
if (serviceCustomProps.resultCodeKey) {
|
|
145
|
+
toastParmas.resultCodeKey = serviceCustomProps.resultCodeKey
|
|
146
|
+
}
|
|
147
|
+
if (!resultToast(ret?.data, messageInstance, toastParmas)) {
|
|
168
148
|
await Promise.reject()
|
|
169
149
|
return
|
|
170
150
|
}
|
|
@@ -426,6 +406,7 @@ export function openDailg({
|
|
|
426
406
|
const paramsBeforeOpenDialog = beforeOpenDialog
|
|
427
407
|
if (configBeforeOpenDialog || paramsBeforeOpenDialog) {
|
|
428
408
|
beforeOpenDialog = async (...arg) => {
|
|
409
|
+
bpmInstance?.changeSlide?.(false)
|
|
429
410
|
let beforeOpenDialogRet = true
|
|
430
411
|
if (paramsBeforeOpenDialog) {
|
|
431
412
|
beforeOpenDialogRet = paramsBeforeOpenDialog?.(...arg)
|
|
@@ -475,13 +456,14 @@ export function openDailg({
|
|
|
475
456
|
const paramsAfterOpenDialog = afterOpenDialog
|
|
476
457
|
if (configAfterOpenDialog || paramsAfterOpenDialog) {
|
|
477
458
|
afterOpenDialog = async (...arg) => {
|
|
459
|
+
bpmInstance?.changeSlide?.(true)
|
|
478
460
|
paramsAfterOpenDialog?.(...arg)
|
|
479
461
|
configAfterOpenDialog?.(...arg)
|
|
480
462
|
}
|
|
481
463
|
}
|
|
482
464
|
afterOpenDialog && afterOpenDialog({
|
|
483
465
|
dynamicMapComp,
|
|
484
|
-
rootValue,
|
|
466
|
+
rootValue,
|
|
485
467
|
dynamicHireRelat,
|
|
486
468
|
compConfig,
|
|
487
469
|
pagePopupMap,
|
|
@@ -291,6 +291,12 @@ function normalTableRowValue(row) {
|
|
|
291
291
|
...row
|
|
292
292
|
}
|
|
293
293
|
pmPageMetaList.value.forEach(config => {
|
|
294
|
+
if (config?.defaultValue) {
|
|
295
|
+
if (ret[config.metaCode] === "" || ret[config.metaCode] === undefined || ret[config.metaCode] === null) {
|
|
296
|
+
ret[config.metaCode] = config.defaultValue
|
|
297
|
+
row[config.metaCode] = config.defaultValue
|
|
298
|
+
}
|
|
299
|
+
}
|
|
294
300
|
normalResult(ret, config)
|
|
295
301
|
})
|
|
296
302
|
return ret
|
package/src/index.jsx
CHANGED
|
@@ -167,6 +167,10 @@ export default {
|
|
|
167
167
|
bpmActions: {
|
|
168
168
|
type: [Object],
|
|
169
169
|
default: {}
|
|
170
|
+
},
|
|
171
|
+
bpmConfigs: {
|
|
172
|
+
type: Object,
|
|
173
|
+
default: {}
|
|
170
174
|
}
|
|
171
175
|
},
|
|
172
176
|
emits: ['update:modelValue', 'rootStoreChange'],
|
|
@@ -201,7 +205,11 @@ export default {
|
|
|
201
205
|
return props.dataLoad || nativeDataLoad.value
|
|
202
206
|
})
|
|
203
207
|
const { initPageConfig, pageConfigRef, mapCompRef, hireRelatMapRulesRef } = usePageConfig()
|
|
204
|
-
function toExecuteLoadServices(
|
|
208
|
+
function toExecuteLoadServices(
|
|
209
|
+
clearFlag,
|
|
210
|
+
alongLoad,
|
|
211
|
+
configs
|
|
212
|
+
) {
|
|
205
213
|
// 触发加载事件执行
|
|
206
214
|
const oldNativeDataload = nativeDataLoad.value
|
|
207
215
|
nativeDataLoad.value = false
|
|
@@ -213,7 +221,7 @@ export default {
|
|
|
213
221
|
messageInstance: toRef(props, 'messageInstance'),
|
|
214
222
|
businessIdentityReqData: props.businessIdentityReqData,
|
|
215
223
|
axiosInstance,
|
|
216
|
-
reqData: {...props.loadEvnetsReq, ...props.dialogReq},
|
|
224
|
+
reqData: {...props.loadEvnetsReq, ...props.dialogReq, ...(configs?.params || {})},
|
|
217
225
|
notLoadCb: () => {
|
|
218
226
|
nativeDataLoad.value = true
|
|
219
227
|
},
|
|
@@ -363,56 +371,11 @@ export default {
|
|
|
363
371
|
})
|
|
364
372
|
onMounted(() => {
|
|
365
373
|
if (props.openBpm) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
saveButton?.vm?.click({
|
|
372
|
-
// 保存成功的回调
|
|
373
|
-
afterRequestService(ret) {
|
|
374
|
-
if (ret?.data?.success) {
|
|
375
|
-
toExecuteLoadServices(true, true)
|
|
376
|
-
resolve(true)
|
|
377
|
-
} else {
|
|
378
|
-
resolve(false)
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
})
|
|
382
|
-
}
|
|
383
|
-
})
|
|
384
|
-
}
|
|
385
|
-
function toSubmit() {
|
|
386
|
-
return new Promise((resolve) => {
|
|
387
|
-
validate((valid) => {
|
|
388
|
-
if (valid) {
|
|
389
|
-
resolve(toSave())
|
|
390
|
-
} else {
|
|
391
|
-
resolve(false)
|
|
392
|
-
}
|
|
393
|
-
})
|
|
394
|
-
})
|
|
395
|
-
}
|
|
396
|
-
const commonSaveObj = {
|
|
397
|
-
getForm({ eventData }) {
|
|
398
|
-
return toSave()
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const commonSubmitObj = {
|
|
402
|
-
getForm({ eventData }) {
|
|
403
|
-
const actionType = eventData?.bpmInfo?.actionType
|
|
404
|
-
if (!actionType) {
|
|
405
|
-
return toSubmit()
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
const bpmInstance = initBpm(bpmMessage, props.bpmActions)
|
|
410
|
-
bpmInstance.setDefaultactions({
|
|
411
|
-
[SUBMIT_TYPE.SEND]: commonSubmitObj,
|
|
412
|
-
[SUBMIT_TYPE.SUBMIT]: commonSubmitObj,
|
|
413
|
-
[SUBMIT_TYPE.GIVE]: commonSaveObj,
|
|
414
|
-
[SUBMIT_TYPE.AGREE]: commonSaveObj,
|
|
415
|
-
[SUBMIT_TYPE.DRAFT_HANDLE]: commonSaveObj,
|
|
374
|
+
initBpm(props.bpmMessage, props.bpmActions, props.bpmConfigs, {
|
|
375
|
+
validate,
|
|
376
|
+
dynamicMapComp,
|
|
377
|
+
toExecuteLoadServices,
|
|
378
|
+
bpmSubmitBtn: props.bpmSubmitBtn
|
|
416
379
|
})
|
|
417
380
|
}
|
|
418
381
|
})
|
package/src/utils/common.js
CHANGED
|
@@ -565,4 +565,35 @@ function normalizeNumberString(numStr) {
|
|
|
565
565
|
if (result.startsWith("-.")) result = "-0" + result.slice(1);
|
|
566
566
|
|
|
567
567
|
return result;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
export function getPathVal(obj = {}, path) {
|
|
572
|
+
let paths = path
|
|
573
|
+
if (typeof path === 'string') {
|
|
574
|
+
paths = path.split('.')
|
|
575
|
+
}
|
|
576
|
+
return paths.reduce((ret, key) => {
|
|
577
|
+
if (ret) {
|
|
578
|
+
return ret[key]
|
|
579
|
+
}
|
|
580
|
+
return null
|
|
581
|
+
}, obj) ?? ''
|
|
582
|
+
}
|
|
583
|
+
export function assignmentPathVal(obj = {}, path, val) {
|
|
584
|
+
let paths = path
|
|
585
|
+
if (typeof path === 'string') {
|
|
586
|
+
paths = path.split('.')
|
|
587
|
+
}
|
|
588
|
+
let currentObj = obj
|
|
589
|
+
paths.forEach((item, idx) => {
|
|
590
|
+
if (idx + 1 === paths.length) {
|
|
591
|
+
currentObj[item] = val ?? ''
|
|
592
|
+
} else {
|
|
593
|
+
if (!currentObj[item]) {
|
|
594
|
+
currentObj[item] = {}
|
|
595
|
+
}
|
|
596
|
+
currentObj = currentObj[item]
|
|
597
|
+
}
|
|
598
|
+
})
|
|
568
599
|
}
|
package/src/utils/respone.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPromise } from "./common"
|
|
1
|
+
import { getPathVal, isPromise } from "./common"
|
|
2
2
|
|
|
3
3
|
export const RESULT_CODE = {
|
|
4
4
|
SUCCESS: '000000',
|
|
@@ -7,11 +7,12 @@ export const RESULT_CODE = {
|
|
|
7
7
|
ERROR: '000000',
|
|
8
8
|
OTHER: '020002'
|
|
9
9
|
}
|
|
10
|
-
export function resultToast(result = {}, messageInstance, {messageCb, service, compConfig, noSuccessIip = false} = {}) {
|
|
10
|
+
export function resultToast(result = {}, messageInstance, {messageCb, service, compConfig, noSuccessIip = false, resultCodeKey = 'resultCode'} = {}) {
|
|
11
11
|
let ret = false
|
|
12
12
|
let cbKey = ''
|
|
13
13
|
const resultMessage = result?.resultMessage || ''
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
const resultCode = getPathVal(result, resultCodeKey)
|
|
15
16
|
switch (resultCode) {
|
|
16
17
|
case RESULT_CODE.SUCCESS:
|
|
17
18
|
if (!noSuccessIip) {
|