resolver-egretimp-plus 0.1.15 → 0.1.16
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 +1 -1
- package/dist/web/index.js +1 -1
- package/package.json +1 -1
- package/src/bpm/bpmInstance.js +74 -59
package/package.json
CHANGED
package/src/bpm/bpmInstance.js
CHANGED
|
@@ -61,10 +61,16 @@ export class Bpm {
|
|
|
61
61
|
window.addEventListener("message", this.messageListener.bind(this))
|
|
62
62
|
}
|
|
63
63
|
setNativeMethods() {
|
|
64
|
-
const { validate, dynamicMapComp, bpmSubmitBtn, toExecuteLoadServices } = this.params
|
|
64
|
+
const { validate: nativeValidate, dynamicMapComp, bpmSubmitBtn, toExecuteLoadServices } = this.params
|
|
65
|
+
const { getDetailReq, customValidate } = this.bpmConfigs
|
|
66
|
+
|
|
65
67
|
const toSave = (cb, eventData) => {
|
|
66
68
|
const saveButton = dynamicMapComp[bpmSubmitBtn]
|
|
67
69
|
if (saveButton) {
|
|
70
|
+
if (!eventData && typeof cb !== 'function') {
|
|
71
|
+
eventData = cb
|
|
72
|
+
cb = null
|
|
73
|
+
}
|
|
68
74
|
const createAfterRequestService = (fn) => {
|
|
69
75
|
return async (ret) => {
|
|
70
76
|
const { saveAfter } = this.bpmConfigs
|
|
@@ -96,12 +102,25 @@ export class Bpm {
|
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
const getDetail = () => {
|
|
99
|
-
const { getDetailReq } = this.bpmConfigs
|
|
100
105
|
const params = getDetailReq?.(this.saveResponse)
|
|
101
106
|
toExecuteLoadServices(true, true, { params })
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
const validate = async (eventData) => {
|
|
110
|
+
let valid = await new Promise((resolve) => {
|
|
111
|
+
nativeValidate((val) => {
|
|
112
|
+
resolve(val)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
if (!valid) return false
|
|
116
|
+
if (customValidate && typeof customValidate === 'function') {
|
|
117
|
+
return customValidate(eventData)
|
|
118
|
+
}
|
|
119
|
+
return true
|
|
120
|
+
}
|
|
104
121
|
this.nativeMethods = {
|
|
122
|
+
nativeValidate,
|
|
123
|
+
customValidate,
|
|
105
124
|
validate,
|
|
106
125
|
toSave,
|
|
107
126
|
getDetail
|
|
@@ -119,25 +138,16 @@ export class Bpm {
|
|
|
119
138
|
this.handleMessage && this.handleMessage(event, options)
|
|
120
139
|
}
|
|
121
140
|
async handleMessage(event, options) {
|
|
122
|
-
let
|
|
123
|
-
const { messageType, submitType } =
|
|
124
|
-
const actionType =
|
|
141
|
+
let eventData = this.eventData || {}
|
|
142
|
+
const { messageType, submitType } = eventData
|
|
143
|
+
const actionType = eventData?.bpmInfo?.actionType
|
|
125
144
|
console.log('messageType==:', messageType)
|
|
126
145
|
console.log('submitType==:', submitType)
|
|
127
146
|
console.log('actionType==:', actionType)
|
|
128
147
|
if (MESSAGE_TYPE.GET_FORM_DATA === messageType) {
|
|
129
|
-
let postMessageData = this.actions?.[submitType]?.postMessageData
|
|
130
|
-
if (!postMessageData) {
|
|
131
|
-
postMessageData = this.postMessageData
|
|
132
|
-
}
|
|
133
|
-
if (typeof postMessageData === 'function') {
|
|
134
|
-
postMessageData = await postMessageData({
|
|
135
|
-
eventData: this.eventData,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
148
|
let action = this.actions?.[submitType]?.formAction
|
|
139
149
|
if (!action) {
|
|
140
|
-
action = this.getDefaultAction(
|
|
150
|
+
action = this.getDefaultAction(eventData)
|
|
141
151
|
}
|
|
142
152
|
if (action) {
|
|
143
153
|
let valid = await action?.({
|
|
@@ -148,6 +158,15 @@ export class Bpm {
|
|
|
148
158
|
return
|
|
149
159
|
}
|
|
150
160
|
}
|
|
161
|
+
let postMessageData = this.actions?.[submitType]?.postMessageData
|
|
162
|
+
if (!postMessageData) {
|
|
163
|
+
postMessageData = this.postMessageData
|
|
164
|
+
}
|
|
165
|
+
if (typeof postMessageData === 'function') {
|
|
166
|
+
postMessageData = await postMessageData({
|
|
167
|
+
eventData: this.eventData,
|
|
168
|
+
})
|
|
169
|
+
}
|
|
151
170
|
this.postMessage(postMessageData)
|
|
152
171
|
} else if (MESSAGE_TYPE.PROCESS_ACTION_SUCCESS === messageType) {
|
|
153
172
|
let closeFlag = true
|
|
@@ -155,7 +174,7 @@ export class Bpm {
|
|
|
155
174
|
|
|
156
175
|
let action = this.actions?.[submitType]?.successAction
|
|
157
176
|
if (!action) {
|
|
158
|
-
action = this.getDefaultAction(
|
|
177
|
+
action = this.getDefaultAction(eventData)
|
|
159
178
|
}
|
|
160
179
|
if (action) {
|
|
161
180
|
closeFlag = await action?.({
|
|
@@ -175,7 +194,7 @@ export class Bpm {
|
|
|
175
194
|
}
|
|
176
195
|
}
|
|
177
196
|
async postMessage(formData = {}, options) {
|
|
178
|
-
console.log('postmessage===:', formData, options)
|
|
197
|
+
console.log('postmessage formData ===:', formData, options)
|
|
179
198
|
this.postOptions = options
|
|
180
199
|
const closeFlag = options?.closeFlag
|
|
181
200
|
if (closeFlag) {
|
|
@@ -192,19 +211,22 @@ export class Bpm {
|
|
|
192
211
|
let preventCloseFlag = ['BACK'].includes(this.eventData?.submitType) ? false : true
|
|
193
212
|
console.log('eventData==:', this.eventData)
|
|
194
213
|
if (window.parent !== window) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
preventClose: preventCloseFlag, // true 不关闭页面
|
|
202
|
-
},
|
|
203
|
-
//表单数据放这里
|
|
204
|
-
formData: {
|
|
205
|
-
...formData
|
|
206
|
-
},
|
|
214
|
+
const postData = {
|
|
215
|
+
success: true, //表单数据验证成功或不需要验证时传true,否则传false
|
|
216
|
+
submitType: this.eventData?.submitType, //将此字段值回传
|
|
217
|
+
messageType: this.eventData?.messageType, //获取表单数据消息
|
|
218
|
+
actionInfo: {
|
|
219
|
+
preventClose: preventCloseFlag, // true 不关闭页面
|
|
207
220
|
},
|
|
221
|
+
//表单数据放这里
|
|
222
|
+
formData: {
|
|
223
|
+
...formData
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
console.log('url==:', this.eventData.url)
|
|
227
|
+
console.log('postData==:', postData)
|
|
228
|
+
window.parent.postMessage(
|
|
229
|
+
postData,
|
|
208
230
|
this.eventData?.url
|
|
209
231
|
)
|
|
210
232
|
}
|
|
@@ -217,46 +239,39 @@ export class Bpm {
|
|
|
217
239
|
case SUBMIT_TYPE.SEND:
|
|
218
240
|
case SUBMIT_TYPE.SUBMIT:
|
|
219
241
|
case SUBMIT_TYPE.AGREE:
|
|
220
|
-
return (eventData) => {
|
|
242
|
+
return async (eventData) => {
|
|
221
243
|
const { validate, toSave, getDetail } = this.nativeMethods
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
resolve(false)
|
|
235
|
-
}
|
|
236
|
-
})
|
|
237
|
-
})
|
|
244
|
+
const valid = await validate(eventData)
|
|
245
|
+
if (valid) {
|
|
246
|
+
const ret = await toSave(eventData)
|
|
247
|
+
if (ret?.data?.success) {
|
|
248
|
+
getDetail()
|
|
249
|
+
return true
|
|
250
|
+
} else {
|
|
251
|
+
return false
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
238
256
|
}
|
|
239
257
|
case SUBMIT_TYPE.NOTICE:
|
|
240
258
|
case SUBMIT_TYPE.GIVE:
|
|
241
259
|
case SUBMIT_TYPE.DRAFT_HANDLE:
|
|
242
260
|
case SUBMIT_TYPE.MULTI_COOPERATE:
|
|
243
|
-
return (eventData) => {
|
|
261
|
+
return async (eventData) => {
|
|
244
262
|
const actionType = eventData?.bpmInfo?.actionType
|
|
245
263
|
const { toSave, getDetail } = this.nativeMethods
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
resolve(true)
|
|
252
|
-
} else {
|
|
253
|
-
resolve(false)
|
|
254
|
-
}
|
|
255
|
-
}, eventData)
|
|
264
|
+
if (!actionType) {
|
|
265
|
+
const ret = await toSave(eventData)
|
|
266
|
+
if (ret?.data?.success) {
|
|
267
|
+
getDetail()
|
|
268
|
+
return true
|
|
256
269
|
} else {
|
|
257
|
-
|
|
270
|
+
return false
|
|
258
271
|
}
|
|
259
|
-
}
|
|
272
|
+
} else {
|
|
273
|
+
return true
|
|
274
|
+
}
|
|
260
275
|
}
|
|
261
276
|
}
|
|
262
277
|
}
|