resolver-egretimp-plus 0.1.124 → 0.1.126
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/web/index.js +2 -2
- package/package.json +1 -1
- package/src/analysisComponent.jsx +0 -1
- package/src/components/lazyLoadComponent/index.js +1 -0
- package/src/components/lazyLoadComponent/src/LazyLoadComponent.jsx +137 -0
- package/src/components/lazyLoadComponent/src/LazyLoadComponent.scss +36 -0
- package/src/components/packages-web/CustomComponentPlain.vue +3 -2
- package/src/components/packages-web/CustomComponentTabs.vue +1 -5
- package/src/components/packages-web/ElDatePicker.vue +24 -8
- package/src/hooks/pageConfig.js +11 -1
- package/src/index.jsx +29 -3
- package/src/resolver-web.vue +3 -1
- package/src/utils/common.js +1 -0
- package/src/utils/lazyLoad.js +69 -0
- package/src/utils/render.jsx +173 -32
- package/src/utils/validateByData.js +177 -0
package/src/utils/render.jsx
CHANGED
|
@@ -26,14 +26,15 @@ import {
|
|
|
26
26
|
MODE,
|
|
27
27
|
|
|
28
28
|
isHidden,
|
|
29
|
-
CYCLE_COMPONETS
|
|
29
|
+
CYCLE_COMPONETS,
|
|
30
|
+
EXECTE_CLICK_EVENT_COMPONENTS
|
|
30
31
|
} from './const.js'
|
|
31
32
|
import { preserveCheck } from './preserveFunc.js'
|
|
32
33
|
import { isArray, isFunction, isString } from './is.js'
|
|
33
34
|
import CustomComponentPlain from '../components/packages-web/CustomComponentPlain.vue'
|
|
34
35
|
// import QuestionFilled from '../components/icons/question-filled.vue'
|
|
35
36
|
import infoIcon from '../components/icons/info.vue'
|
|
36
|
-
import { dispatchClickEvent, dispatchClickEvents, getTableConfig } from '../components/helper/eventOrchestration.js'
|
|
37
|
+
import { dispatchClickEvent, dispatchClickEvents, executeEventOrchestration, getTableConfig } from '../components/helper/eventOrchestration.js'
|
|
37
38
|
import CmiFormItem from '../components/cmiFormItem'
|
|
38
39
|
import loadModule from './loadModule.js'
|
|
39
40
|
import dayjs from 'dayjs'
|
|
@@ -119,6 +120,11 @@ export function generateFormConfig(lang = 'zh', isH5) {
|
|
|
119
120
|
* @param {*} config 通过接口获取的配置对象
|
|
120
121
|
*/
|
|
121
122
|
export function parsePageConfig({
|
|
123
|
+
components,
|
|
124
|
+
confirmInstance,
|
|
125
|
+
openChildDialogInstance,
|
|
126
|
+
buttonActions,
|
|
127
|
+
builtPolyfillReq,
|
|
122
128
|
requestTraceId,
|
|
123
129
|
dialogReq,
|
|
124
130
|
mode,
|
|
@@ -140,6 +146,11 @@ export function parsePageConfig({
|
|
|
140
146
|
const cbs = []
|
|
141
147
|
window?.performance?.mark('noraml_config_start')
|
|
142
148
|
let { pageConfig, mapComp } = normalConfig({
|
|
149
|
+
components,
|
|
150
|
+
confirmInstance,
|
|
151
|
+
openChildDialogInstance,
|
|
152
|
+
buttonActions,
|
|
153
|
+
builtPolyfillReq,
|
|
143
154
|
requestTraceId,
|
|
144
155
|
dialogReq,
|
|
145
156
|
lang,
|
|
@@ -204,6 +215,20 @@ function correctConfigDynamicMapHandler({config, dynamicMapComp, changedDynamicH
|
|
|
204
215
|
}
|
|
205
216
|
}
|
|
206
217
|
}
|
|
218
|
+
|
|
219
|
+
function canReuse(
|
|
220
|
+
dynamicMapComp,
|
|
221
|
+
dynamicHireRelat,
|
|
222
|
+
currentIdx
|
|
223
|
+
) {
|
|
224
|
+
// 如果组件上的rowIndex等于当前的idx,说明这个config已经没有被用到了,我们可以直接拿过来复用
|
|
225
|
+
const currentCg = dynamicMapComp[dynamicHireRelat]
|
|
226
|
+
if (currentCg?.rowIndex === currentIdx) {
|
|
227
|
+
return true
|
|
228
|
+
}
|
|
229
|
+
return false
|
|
230
|
+
}
|
|
231
|
+
|
|
207
232
|
/**
|
|
208
233
|
* {
|
|
209
234
|
* children: [], // 子元素
|
|
@@ -212,6 +237,11 @@ function correctConfigDynamicMapHandler({config, dynamicMapComp, changedDynamicH
|
|
|
212
237
|
* @param {*} config
|
|
213
238
|
*/
|
|
214
239
|
export function normalConfig({
|
|
240
|
+
components,
|
|
241
|
+
confirmInstance,
|
|
242
|
+
openChildDialogInstance,
|
|
243
|
+
buttonActions,
|
|
244
|
+
builtPolyfillReq,
|
|
215
245
|
requestTraceId,
|
|
216
246
|
dialogReq,
|
|
217
247
|
lang,
|
|
@@ -229,6 +259,7 @@ export function normalConfig({
|
|
|
229
259
|
noParsePageMetaList,
|
|
230
260
|
changeConfig,
|
|
231
261
|
notParseConfig,
|
|
262
|
+
parentConfig,
|
|
232
263
|
}, config, hireRelat = '', mapComp = {}, needformItem = false, dynamicHireRelat = '', unWatchsList = []) {
|
|
233
264
|
|
|
234
265
|
const metaCode = config.metaCode || ''
|
|
@@ -250,10 +281,10 @@ export function normalConfig({
|
|
|
250
281
|
vm: null, // 具体渲染的组件
|
|
251
282
|
wrapVm: null, // 当前组件的实例(也就是analysisComponent)
|
|
252
283
|
hireRelat,
|
|
253
|
-
parent: null, // 这个是执行过程中,动态获取的
|
|
254
284
|
}
|
|
255
285
|
if (!OPEN_DATA_RULES) {
|
|
256
286
|
extendNativeObj.dynamicHireRelat = ''
|
|
287
|
+
extendNativeObj.parent = null
|
|
257
288
|
} else {
|
|
258
289
|
if (changeConfig) {
|
|
259
290
|
// 设置multiPmPageMetaList的时候,如果数组变了,如果数组中的值变换了位置,需要对dynamicMapComp设置正确的映射
|
|
@@ -263,6 +294,7 @@ export function normalConfig({
|
|
|
263
294
|
dynamicMapComp[dynamicHireRelat] = config
|
|
264
295
|
definePrivatelyProp(config, '_rootValue', rootValue)
|
|
265
296
|
definePrivatelyProp(config, 'refValue', useVmodels(config).modelValue)
|
|
297
|
+
definePrivatelyProp(config, 'parent', parentConfig) // 这边手动设置一下,防止组件复用的时候不会刷新,造成parent的丢失
|
|
266
298
|
}
|
|
267
299
|
|
|
268
300
|
if (!notParseConfig) {
|
|
@@ -351,6 +383,23 @@ export function normalConfig({
|
|
|
351
383
|
})?.sort((a, b) => a.seqNo - b.seqNo)
|
|
352
384
|
}
|
|
353
385
|
} else {
|
|
386
|
+
compatibilityConfig({
|
|
387
|
+
config,
|
|
388
|
+
builtPolyfillReq,
|
|
389
|
+
components,
|
|
390
|
+
requestTraceId,
|
|
391
|
+
rootValue,
|
|
392
|
+
axiosInstance,
|
|
393
|
+
polyfillConfigs,
|
|
394
|
+
confirmInstance,
|
|
395
|
+
dynamicMapComp,
|
|
396
|
+
openChildDialogInstance,
|
|
397
|
+
messageInstance,
|
|
398
|
+
messageCb,
|
|
399
|
+
buttonActions,
|
|
400
|
+
lang,
|
|
401
|
+
dialogReq,
|
|
402
|
+
})
|
|
354
403
|
// 如果有子项,需要进行递归遍历
|
|
355
404
|
if (pageConfig.pmPageMetaList && pageConfig.pmPageMetaList.length && !noParsePageMetaList) {
|
|
356
405
|
normalPmPageMetaList(pageConfig)
|
|
@@ -379,59 +428,72 @@ export function normalConfig({
|
|
|
379
428
|
|
|
380
429
|
|
|
381
430
|
config._unPageMetaListWatch = watch(() => getPathVal(unref(rootValue), config.dynamicHireRelat, '->'), (val) => {
|
|
431
|
+
let noParseConfigs = []
|
|
382
432
|
const list = getPathVal(unref(rootValue), config.dynamicHireRelat, '->')
|
|
383
433
|
if (list && list.length) {
|
|
384
434
|
const cbFns = []
|
|
385
|
-
const pageMetaList = list.
|
|
435
|
+
const pageMetaList = new Array(list.length)
|
|
436
|
+
for (let idx = 0; idx < list.length; idx++) {
|
|
437
|
+
const row = list[idx];
|
|
386
438
|
const columnsCgs = config._rowColumnConfgsMap.get(row)
|
|
387
439
|
if (columnsCgs) {
|
|
388
440
|
columnsCgs.forEach(config => {
|
|
389
441
|
config.rowIndex = idx
|
|
390
442
|
config.rowScope.$index =idx
|
|
391
443
|
})
|
|
392
|
-
|
|
444
|
+
pageMetaList.splice(idx, 1, columnsCgs)
|
|
393
445
|
} else {
|
|
394
|
-
let retColumnConfigs = config.pmPageMetaList.map((itemConfig, relIdx) => {
|
|
395
|
-
const ret = cloneDeep(itemConfig)
|
|
396
|
-
if (findComponent(['CustomComponentTable'], config.renderby) !== -1 || findComponent(['CustomComponentTable'], config.metaType) !== -1) {
|
|
397
|
-
ret.labelHidden = '1'
|
|
398
|
-
if (ret.width && !ret.columnWidth) {
|
|
399
|
-
ret.columnWidth = ret.width
|
|
400
|
-
delete ret.width
|
|
401
|
-
}
|
|
402
|
-
ret.isColumn = true
|
|
403
|
-
}
|
|
404
|
-
ret.rowScope = {$index: idx, row}
|
|
405
|
-
ret.columnId = generateUniqueId()
|
|
406
|
-
ret.rowIndex = idx
|
|
407
|
-
definePrivatelyProp(ret, 'refConfig', config.pmPageMetaList?.[relIdx])
|
|
408
|
-
definePrivatelyProp(ret, 'parent', config) // 这边手动设置一下,防止组件复用的时候不会刷新,造成parent的丢失
|
|
409
|
-
return ret
|
|
410
|
-
})
|
|
411
|
-
retColumnConfigs = reactive(retColumnConfigs)
|
|
412
446
|
cbFns.push(() => {
|
|
447
|
+
let retColumnConfigs = config.pmPageMetaList.map((itemConfig, relIdx) => {
|
|
448
|
+
const compareDynamicHireRelat = `${config.dynamicHireRelat}[${idx}]->${itemConfig.metaCode}`
|
|
449
|
+
let ret = null
|
|
450
|
+
if (canReuse(dynamicMapComp, compareDynamicHireRelat, idx)) {
|
|
451
|
+
ret = dynamicMapComp[compareDynamicHireRelat]
|
|
452
|
+
noParseConfigs.push(ret)
|
|
453
|
+
} else {
|
|
454
|
+
ret = cloneDeep(itemConfig)
|
|
455
|
+
if (findComponent(['CustomComponentTable'], config.renderby) !== -1 || findComponent(['CustomComponentTable'], config.metaType) !== -1) {
|
|
456
|
+
ret.labelHidden = '1'
|
|
457
|
+
if (ret.width && !ret.columnWidth) {
|
|
458
|
+
ret.columnWidth = ret.width
|
|
459
|
+
delete ret.width
|
|
460
|
+
}
|
|
461
|
+
ret.isColumn = true
|
|
462
|
+
}
|
|
463
|
+
ret.rowScope = {$index: idx, row}
|
|
464
|
+
ret.rowIndex = idx
|
|
465
|
+
ret.columnId = generateUniqueId()
|
|
466
|
+
}
|
|
467
|
+
definePrivatelyProp(ret, 'parent', parentConfig) // 这边手动设置一下,防止组件复用的时候不会刷新,造成parent的丢失
|
|
468
|
+
definePrivatelyProp(ret, 'refConfig', config.pmPageMetaList?.[relIdx])
|
|
469
|
+
return ret
|
|
470
|
+
})
|
|
471
|
+
retColumnConfigs = reactive(retColumnConfigs)
|
|
413
472
|
simpleNormalPmPageMetaList({
|
|
414
|
-
pmPageMetaList: retColumnConfigs,
|
|
473
|
+
pmPageMetaList: retColumnConfigs.filter(cg => !noParseConfigs.some(cg1 => cg === cg1)),
|
|
415
474
|
dynamicHireRelat: `${config.dynamicHireRelat}[${idx}]`,
|
|
416
475
|
unWatchsList: currentUnWatchsList,
|
|
417
476
|
noParsePageMetaList: false,
|
|
418
477
|
changeConfig: true,
|
|
419
478
|
notParseConfig: true,
|
|
420
479
|
})
|
|
480
|
+
config._rowColumnConfgsMap.set(row, retColumnConfigs)
|
|
481
|
+
|
|
482
|
+
pageMetaList.splice(idx, 1, retColumnConfigs)
|
|
421
483
|
})
|
|
422
|
-
config._rowColumnConfgsMap.set(row, retColumnConfigs)
|
|
423
|
-
return retColumnConfigs
|
|
424
484
|
}
|
|
425
|
-
}
|
|
426
|
-
config.multiPmPageMetaList = pageMetaList
|
|
485
|
+
}
|
|
427
486
|
cbFns.forEach(cb => cb())
|
|
487
|
+
config.multiPmPageMetaList = pageMetaList
|
|
428
488
|
|
|
429
489
|
const mapKeys = config._rowColumnConfgsMap.keys()
|
|
430
490
|
Array.from(mapKeys).forEach(row => {
|
|
431
491
|
// 如果已经没有对应的数据循环config了,删除子级的PmPageMetaList监听
|
|
432
492
|
if (!list.some(row2 => row2 === row)) {
|
|
433
493
|
config._rowColumnConfgsMap.get(row)?.forEach(unWatchConfig => {
|
|
434
|
-
|
|
494
|
+
if (!noParseConfigs.some(cg1 => cg1 === unWatchConfig)) {
|
|
495
|
+
unWatchConfig?._unWatchs?.forEach(un => un?.())
|
|
496
|
+
}
|
|
435
497
|
})
|
|
436
498
|
config._rowColumnConfgsMap.delete(row)
|
|
437
499
|
}
|
|
@@ -440,10 +502,9 @@ export function normalConfig({
|
|
|
440
502
|
}, {
|
|
441
503
|
immediate: true,
|
|
442
504
|
deep: true,
|
|
443
|
-
// flush: 'sync'
|
|
444
505
|
})
|
|
445
506
|
|
|
446
|
-
|
|
507
|
+
currentUnWatchsList?.forEach(list => {
|
|
447
508
|
list?.push(config._unPageMetaListWatch)
|
|
448
509
|
})
|
|
449
510
|
}
|
|
@@ -451,6 +512,11 @@ export function normalConfig({
|
|
|
451
512
|
function simpleNormalPmPageMetaList({pmPageMetaList, dynamicHireRelat, unWatchsList, noParsePageMetaList, changeConfig, notParseConfig}) {
|
|
452
513
|
return pmPageMetaList.map(metaItem => {
|
|
453
514
|
const { pageConfig } = normalConfig({
|
|
515
|
+
components,
|
|
516
|
+
confirmInstance,
|
|
517
|
+
openChildDialogInstance,
|
|
518
|
+
buttonActions,
|
|
519
|
+
builtPolyfillReq,
|
|
454
520
|
requestTraceId,
|
|
455
521
|
dialogReq,
|
|
456
522
|
lang,
|
|
@@ -468,6 +534,7 @@ export function normalConfig({
|
|
|
468
534
|
noParsePageMetaList,
|
|
469
535
|
changeConfig,
|
|
470
536
|
notParseConfig,
|
|
537
|
+
parentConfig: config
|
|
471
538
|
}, metaItem, hireRelat, mapComp, needformItem || [FORM_META_TYPE, FORM_META_TYPE_H5].includes(metaType), dynamicHireRelat, unWatchsList)
|
|
472
539
|
return pageConfig
|
|
473
540
|
})?.sort((a, b) => a.seqNo - b.seqNo)
|
|
@@ -475,13 +542,83 @@ export function normalConfig({
|
|
|
475
542
|
}
|
|
476
543
|
}
|
|
477
544
|
|
|
478
|
-
|
|
479
545
|
return {
|
|
480
546
|
mapComp,
|
|
481
547
|
pageConfig
|
|
482
548
|
}
|
|
483
549
|
}
|
|
484
550
|
|
|
551
|
+
// 目前做数据进行驱动规则、循环组件的config渲染,需要兼容一些现有业务逻辑
|
|
552
|
+
function compatibilityConfig({
|
|
553
|
+
config,
|
|
554
|
+
builtPolyfillReq,
|
|
555
|
+
components,
|
|
556
|
+
requestTraceId,
|
|
557
|
+
rootValue,
|
|
558
|
+
axiosInstance,
|
|
559
|
+
polyfillConfigs,
|
|
560
|
+
confirmInstance,
|
|
561
|
+
dynamicMapComp,
|
|
562
|
+
openChildDialogInstance,
|
|
563
|
+
messageInstance,
|
|
564
|
+
messageCb,
|
|
565
|
+
buttonActions,
|
|
566
|
+
lang,
|
|
567
|
+
dialogReq,
|
|
568
|
+
}) {
|
|
569
|
+
// 给button组件的vm中添加click事件,因为这边业务都用到了,需要进行兼容
|
|
570
|
+
const needClick = findComponent(EXECTE_CLICK_EVENT_COMPONENTS, config.renderby) !== -1 || findComponent(EXECTE_CLICK_EVENT_COMPONENTS, config.metaType) !== -1
|
|
571
|
+
if (needClick) {
|
|
572
|
+
config.vm = markRaw({
|
|
573
|
+
click(params) {
|
|
574
|
+
executeEventOrchestration({
|
|
575
|
+
...params,
|
|
576
|
+
builtPolyfillReq,
|
|
577
|
+
components,
|
|
578
|
+
props: {config},
|
|
579
|
+
requestTraceId,
|
|
580
|
+
axiosInstance: axiosInstance,
|
|
581
|
+
polyfillConfigs,
|
|
582
|
+
rootValue: rootValue?.value,
|
|
583
|
+
confirmInstance,
|
|
584
|
+
dynamicMapComp,
|
|
585
|
+
openChildDialog: openChildDialogInstance,
|
|
586
|
+
messageInstance,
|
|
587
|
+
messageCb,
|
|
588
|
+
buttonActions,
|
|
589
|
+
lang,
|
|
590
|
+
dialogReq,
|
|
591
|
+
appContext: null
|
|
592
|
+
})
|
|
593
|
+
}
|
|
594
|
+
})
|
|
595
|
+
}
|
|
596
|
+
// tab需要兼容setActiveTab方法,业务侧有没加载就使用
|
|
597
|
+
const needSetActive = findComponent(['CustomComponentTabs'], config.renderby) !== -1 || findComponent(['CustomComponentTabs'], config.metaType) !== -1
|
|
598
|
+
if (needSetActive) {
|
|
599
|
+
config.vm = markRaw({
|
|
600
|
+
setActiveTab(val) {
|
|
601
|
+
const tabpanes = config.pmPageMetaList || []
|
|
602
|
+
tabpanes.forEach(tab => {
|
|
603
|
+
if (assertMetaType(tab, 'CustomComponentCycleTabPane') || tab?.isCycle == '1') {
|
|
604
|
+
if (/^cycleTabpane-(\d+)$/.test(val)) {
|
|
605
|
+
tab.currentCode = val
|
|
606
|
+
} else {
|
|
607
|
+
tab.currentCode = ''
|
|
608
|
+
}
|
|
609
|
+
} else if (tab.metaType === 'CustomComponentTabPane') {
|
|
610
|
+
if (tab.metaCode === val) {
|
|
611
|
+
tab.defaultShowFlag = '1'
|
|
612
|
+
} else {
|
|
613
|
+
tab.defaultShowFlag = '0'
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
})
|
|
617
|
+
}
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
485
622
|
// 从按钮的服务编排中,获取到按钮中配置的表格中的config,并且绑定表格的分页
|
|
486
623
|
function getTableServices(lcpPageServiceMapVOList = [], { dynamicMapComp, dynamicMapCompKeys, dynamicHireRelat }) {
|
|
487
624
|
const mixinServiceConfig = lcpPageServiceMapVOList.find(service => service.serviceType == '1')
|
|
@@ -1311,3 +1448,7 @@ function labelMouseEnenter(e, config, lang) {
|
|
|
1311
1448
|
config._triggerRef = e.target
|
|
1312
1449
|
}
|
|
1313
1450
|
}
|
|
1451
|
+
|
|
1452
|
+
export function assertMetaType(config, metaType) {
|
|
1453
|
+
return config.renderby === metaType || config.metaType === metaType
|
|
1454
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { toRaw } from "vue"
|
|
2
|
+
import { calcDisable } from "./const"
|
|
3
|
+
import { getFormItemRule, isCycleConfig } from "./render"
|
|
4
|
+
import AsyncValidator from 'async-validator'
|
|
5
|
+
|
|
6
|
+
export async function toValidate({
|
|
7
|
+
rootConfig, rootValue, mode, lang, messageInstance,
|
|
8
|
+
formRef, cb, dynamicMapComp
|
|
9
|
+
}) {
|
|
10
|
+
const flag = await validateConfig({
|
|
11
|
+
validConfig: rootConfig,
|
|
12
|
+
mode,
|
|
13
|
+
lang,
|
|
14
|
+
rootValue,
|
|
15
|
+
dynamicMapComp,
|
|
16
|
+
messageInstance
|
|
17
|
+
})
|
|
18
|
+
if (!flag) {
|
|
19
|
+
if (!cb) {
|
|
20
|
+
return formRef.value && formRef.value.validate().catch(err => {
|
|
21
|
+
validFailAction(err, dynamicMapComp)
|
|
22
|
+
return Promise.reject(err)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
return formRef.value && formRef.value.validate((valid, errInfo) => {
|
|
26
|
+
errInfo && validFailAction(errInfo, dynamicMapComp)
|
|
27
|
+
cb && cb(valid, errInfo)
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
if (!cb) {
|
|
31
|
+
return Promise.resolve(true)
|
|
32
|
+
}
|
|
33
|
+
return cb?.(true)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 校验的一些附加动作, 例如校验失败,tab需要聚焦到失败tab页面,组件失败,需要展开
|
|
38
|
+
function validFailAction(errInfo, dynamicMapComp) {
|
|
39
|
+
const errKyes = Object.keys(errInfo)
|
|
40
|
+
if (errKyes.length) {
|
|
41
|
+
let oneKey = errKyes[0]
|
|
42
|
+
const referComps = []
|
|
43
|
+
while (oneKey.indexOf('->') > -1) {
|
|
44
|
+
let idx = -1
|
|
45
|
+
let code = ''
|
|
46
|
+
const matchs = oneKey?.match(/^(.+)\[(\d+)\]$/)
|
|
47
|
+
if (matchs) {
|
|
48
|
+
idx = parseInt(matchs[2])
|
|
49
|
+
code = matchs[1]
|
|
50
|
+
} else {
|
|
51
|
+
code = oneKey
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const compInfo = dynamicMapComp[code]
|
|
55
|
+
compInfo && referComps.unshift({
|
|
56
|
+
compInfo,
|
|
57
|
+
cycleIdx: idx
|
|
58
|
+
})
|
|
59
|
+
oneKey = oneKey?.split('->')?.slice(0, -1)?.join('->') || ''
|
|
60
|
+
}
|
|
61
|
+
const compInfo = dynamicMapComp[oneKey]
|
|
62
|
+
compInfo && referComps.unshift({
|
|
63
|
+
compInfo,
|
|
64
|
+
cycleIdx: -1
|
|
65
|
+
})
|
|
66
|
+
referComps.forEach(({compInfo, cycleIdx}) => {
|
|
67
|
+
validFail(compInfo, cycleIdx)
|
|
68
|
+
})
|
|
69
|
+
// 组件对应的页面展示更新后才能获取到校验住的元素
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
const {compInfo: config} = referComps.pop()
|
|
72
|
+
const veiwEl = config?.wrapVm?.vnode?.el
|
|
73
|
+
veiwEl && veiwEl.scrollIntoView({ behavior: 'smooth' })
|
|
74
|
+
|
|
75
|
+
// const fouceErrEle = document.querySelector('.el-form-item__error')
|
|
76
|
+
// const fouceEle = fouceErrEle.parentElement
|
|
77
|
+
// fouceEle && fouceEle.scrollIntoView({ behavior: 'smooth' })
|
|
78
|
+
}, 200)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 校验不通过的时候,需要进行一下组件配置的调整,
|
|
82
|
+
// 标签组件,需要进行聚焦当前页面
|
|
83
|
+
// component组件,需要打开折叠
|
|
84
|
+
function validFail(config, cycleIdx) {
|
|
85
|
+
const type = config.renderby || config.metaType
|
|
86
|
+
switch (type) {
|
|
87
|
+
case 'CustomComponentTabPane':
|
|
88
|
+
case 'CustomComponentCycleTabPane':
|
|
89
|
+
config.parent && config.parent.pmPageMetaList && config.parent.pmPageMetaList.forEach(tab => {
|
|
90
|
+
if (tab.metaType === 'CustomComponentTabPane') {
|
|
91
|
+
tab.defaultShowFlag = '0'
|
|
92
|
+
}
|
|
93
|
+
if (tab.metaType === 'CustomComponentCycleTabPane' || tab?.isCycle == '1') {
|
|
94
|
+
tab.currentCode = ''
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
if (type === 'CustomComponentTabPane' && config?.isCycle != '1') {
|
|
98
|
+
config.defaultShowFlag = '1'
|
|
99
|
+
}
|
|
100
|
+
if (type === 'CustomComponentCycleTabPane' || config?.isCycle == '1') {
|
|
101
|
+
config.currentCode = `${config.metaCode}-${cycleIdx}`
|
|
102
|
+
}
|
|
103
|
+
break
|
|
104
|
+
case 'CustomComponentCollapse':
|
|
105
|
+
config.defaultOpenFlag = '1'
|
|
106
|
+
break
|
|
107
|
+
case 'CustomComponentDialog':
|
|
108
|
+
config.dialogVisible = true
|
|
109
|
+
break
|
|
110
|
+
default:
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function validateConfig({
|
|
115
|
+
validConfig,
|
|
116
|
+
mode,
|
|
117
|
+
lang,
|
|
118
|
+
rootValue,
|
|
119
|
+
dynamicMapComp,
|
|
120
|
+
messageInstance
|
|
121
|
+
}) {
|
|
122
|
+
return travelConfig(validConfig, (config) => {
|
|
123
|
+
const compProps = {
|
|
124
|
+
disabled: calcDisable(config, mode)
|
|
125
|
+
}
|
|
126
|
+
const params = {
|
|
127
|
+
lang,
|
|
128
|
+
rootValue,
|
|
129
|
+
dynamicMapComp,
|
|
130
|
+
props: {
|
|
131
|
+
config: config,
|
|
132
|
+
modelValue: toRaw(config?.refValue),
|
|
133
|
+
rowScope: config.rowScope,
|
|
134
|
+
mode: mode
|
|
135
|
+
},
|
|
136
|
+
messageInstance
|
|
137
|
+
}
|
|
138
|
+
const rules = getFormItemRule(config, lang, params, compProps, true)
|
|
139
|
+
if (rules && rules.length) {
|
|
140
|
+
const validator = new AsyncValidator({
|
|
141
|
+
[config.dynamicHireRelat]: rules
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
async function toValidate() {
|
|
145
|
+
try {
|
|
146
|
+
await validator.validate({[config.dynamicHireRelat]: toRaw(config?.refValue)})
|
|
147
|
+
} catch (error) {
|
|
148
|
+
validFailAction({[config.dynamicHireRelat]: true}, dynamicMapComp)
|
|
149
|
+
return Promise.reject()
|
|
150
|
+
}
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
return toValidate()
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function travelConfig(configs, cb) {
|
|
159
|
+
let travseConfigs = Array.isArray(configs) ? configs : [configs]
|
|
160
|
+
let currentConfig = null
|
|
161
|
+
while(travseConfigs.length) {
|
|
162
|
+
currentConfig = travseConfigs.shift()
|
|
163
|
+
try {
|
|
164
|
+
await cb?.(currentConfig)
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
if (isCycleConfig(currentConfig)) {
|
|
169
|
+
(currentConfig.multiPmPageMetaList || []).forEach(pmPageMetaList => {
|
|
170
|
+
[].push.apply(travseConfigs, pmPageMetaList)
|
|
171
|
+
})
|
|
172
|
+
} else if (currentConfig?.pmPageMetaList?.length) {
|
|
173
|
+
[].push.apply(travseConfigs, currentConfig.pmPageMetaList)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return true
|
|
177
|
+
}
|