resolver-egretimp-plus 0.1.14 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resolver-egretimp-plus",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -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 data = this.eventData || {}
123
- const { messageType, submitType } = data
124
- const actionType = data?.bpmInfo?.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(data)
150
+ action = this.getDefaultAction(eventData)
141
151
  }
142
152
  if (action) {
143
153
  let valid = await action?.({
@@ -148,14 +158,23 @@ 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
- let closeFlag = false
154
- closeFlag = [SUBMIT_TYPE.PROCESS_SHOW, SUBMIT_TYPE.BACK, SUBMIT_TYPE.DRAFT_HANDLE].includes(submitType)
172
+ let closeFlag = true
173
+ closeFlag = ![SUBMIT_TYPE.PROCESS_SHOW, SUBMIT_TYPE.BACK, SUBMIT_TYPE.DRAFT_HANDLE].includes(submitType)
155
174
 
156
175
  let action = this.actions?.[submitType]?.successAction
157
176
  if (!action) {
158
- action = this.getDefaultAction(data)
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
- window.parent.postMessage(
196
- {
197
- success: true, //表单数据验证成功或不需要验证时传true,否则传false
198
- submitType: this.eventData?.submitType, //将此字段值回传
199
- messageType: this.eventData?.messageType, //获取表单数据消息
200
- actionInfo: {
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 不关闭页面
220
+ },
221
+ //表单数据放这里
222
+ formData: {
223
+ ...formData
207
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
  }
@@ -212,50 +234,46 @@ export class Bpm {
212
234
  }
213
235
  getDefaultAction(eventData) {
214
236
  const { messageType, submitType } = eventData
215
- switch (submitType) {
216
- case SUBMIT_TYPE.SEND:
217
- case SUBMIT_TYPE.SUBMIT:
218
- return (eventData) => {
219
- const { validate, toSave, getDetail } = this.nativeMethods
220
- return new Promise((resolve) => {
221
- validate((valid) => {
222
- if (valid) {
223
- toSave((ret) => {
224
- if (ret?.data?.success) {
225
- getDetail()
226
- resolve(true)
227
- } else {
228
- resolve(false)
229
- }
230
- }, eventData)
237
+ if (MESSAGE_TYPE.GET_FORM_DATA === messageType) {
238
+ switch (submitType) {
239
+ case SUBMIT_TYPE.SEND:
240
+ case SUBMIT_TYPE.SUBMIT:
241
+ case SUBMIT_TYPE.AGREE:
242
+ return async (eventData) => {
243
+ const { validate, toSave, getDetail } = this.nativeMethods
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
231
250
  } else {
232
- resolve(false)
251
+ return false
233
252
  }
234
- })
235
- })
236
- }
237
- case SUBMIT_TYPE.NOTICE:
238
- case SUBMIT_TYPE.GIVE:
239
- case SUBMIT_TYPE.DELETE_DRAFT:
240
- case SUBMIT_TYPE.MULTI_COOPERATE:
241
- return (eventData) => {
242
- const actionType = eventData?.bpmInfo?.actionType
243
- const { toSave, getDetail } = this.nativeMethods
244
- return new Promise((resolve) => {
253
+ } else {
254
+ return false
255
+ }
256
+ }
257
+ case SUBMIT_TYPE.NOTICE:
258
+ case SUBMIT_TYPE.GIVE:
259
+ case SUBMIT_TYPE.DRAFT_HANDLE:
260
+ case SUBMIT_TYPE.MULTI_COOPERATE:
261
+ return async (eventData) => {
262
+ const actionType = eventData?.bpmInfo?.actionType
263
+ const { toSave, getDetail } = this.nativeMethods
245
264
  if (!actionType) {
246
- toSave((ret) => {
247
- if (ret?.data?.success) {
248
- getDetail()
249
- resolve(true)
250
- } else {
251
- resolve(false)
252
- }
253
- }, eventData)
265
+ const ret = await toSave(eventData)
266
+ if (ret?.data?.success) {
267
+ getDetail()
268
+ return true
269
+ } else {
270
+ return false
271
+ }
254
272
  } else {
255
- resolve(true)
273
+ return true
256
274
  }
257
- })
258
- }
275
+ }
276
+ }
259
277
  }
260
278
  }
261
279
  // 暂时没用到=======start======
@@ -4,6 +4,7 @@ import { getRelateConfigKeys } from "../../rules/ruleUtils"
4
4
  import { RESULT_CODE, resultToast } from "../../utils/respone"
5
5
  import { assignmentPathVal, getPathVal, isPromise, modelValueDeepMerge, parseExtendAttr, unionWith } from "../../utils/index"
6
6
  import { buildInRequest } from "../../utils/request"
7
+ import { bpmInstance } from "../../bpm/bpmInstance"
7
8
 
8
9
  export async function dispatchClickEvents ({serviceList = [], requestTraceId, axiosInstance, dialogReq, dynamicMapComp, rootValue, dynamicHireRelat, messageCb, compConfig, messageInstance, lang, beforeRequestService, afterRequestService}) {
9
10
  const dynamicMapCompKeys = Object.keys(dynamicMapComp)
@@ -405,6 +406,7 @@ export function openDailg({
405
406
  const paramsBeforeOpenDialog = beforeOpenDialog
406
407
  if (configBeforeOpenDialog || paramsBeforeOpenDialog) {
407
408
  beforeOpenDialog = async (...arg) => {
409
+ bpmInstance?.changeSlide?.(false)
408
410
  let beforeOpenDialogRet = true
409
411
  if (paramsBeforeOpenDialog) {
410
412
  beforeOpenDialogRet = paramsBeforeOpenDialog?.(...arg)
@@ -454,13 +456,14 @@ export function openDailg({
454
456
  const paramsAfterOpenDialog = afterOpenDialog
455
457
  if (configAfterOpenDialog || paramsAfterOpenDialog) {
456
458
  afterOpenDialog = async (...arg) => {
459
+ bpmInstance?.changeSlide?.(true)
457
460
  paramsAfterOpenDialog?.(...arg)
458
461
  configAfterOpenDialog?.(...arg)
459
462
  }
460
463
  }
461
464
  afterOpenDialog && afterOpenDialog({
462
465
  dynamicMapComp,
463
- rootValue,
466
+ rootValue,
464
467
  dynamicHireRelat,
465
468
  compConfig,
466
469
  pagePopupMap,