resolver-egretimp-plus 0.1.110 → 0.1.111
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 +2 -2
- package/package.json +1 -1
- package/src/components/helper/FormPolyfill.jsx +25 -0
- package/src/components/helper/table.jsx +54 -28
- package/src/components/packages-web/CustomComponentFormLayout.vue +6 -4
- package/src/components/packages-web/CustomComponentTable.jsx +8 -10
- package/src/utils/render.jsx +9 -2
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { formContextKey } from "element-plus"
|
|
2
|
+
import { inject } from "vue"
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
name: 'FormPolyfill',
|
|
6
|
+
props: {
|
|
7
|
+
form: Object
|
|
8
|
+
},
|
|
9
|
+
setup(props, { slots }) {
|
|
10
|
+
const formContext = inject(formContextKey, undefined)
|
|
11
|
+
formContext.removeField = (field) => {
|
|
12
|
+
const fields = props.form?.fields
|
|
13
|
+
if (field.prop && fields) {
|
|
14
|
+
const idx = fields.indexOf(field)
|
|
15
|
+
if (idx !== -1) {
|
|
16
|
+
fields.splice(idx, 1)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
return slots?.default?.() || null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -27,44 +27,70 @@ export async function tableValidate({
|
|
|
27
27
|
lang,
|
|
28
28
|
rootValue,
|
|
29
29
|
dynamicMapComp,
|
|
30
|
-
messageInstance
|
|
30
|
+
messageInstance,
|
|
31
|
+
isFrontPage,
|
|
32
|
+
page
|
|
31
33
|
}) {
|
|
34
|
+
// 如果没有开启前端分页功能,不需进行表格校验处理
|
|
35
|
+
if (!isFrontPage) {
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
32
38
|
const multiPmPageMetaList = props.config.multiPmPageMetaList || []
|
|
33
39
|
const list = (data || [])
|
|
40
|
+
const currentStart = (page.pageNum - 1) * page.pageSize
|
|
41
|
+
const currentEnd = page.pageNum * page.pageSize
|
|
34
42
|
for (let index = 0; index < list.length; index++) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
if (index < currentStart || index >= currentEnd) {
|
|
44
|
+
const row = list[index];
|
|
45
|
+
const configColumns = multiPmPageMetaList[index] || multiPmPageMetaList[index % page.pageSize]
|
|
46
|
+
const rowScope = {row, $index: index}
|
|
47
|
+
for (let j = 0; j < configColumns.length; j++) {
|
|
48
|
+
const columnConfig = configColumns[j];
|
|
49
|
+
const renderProps = getItemRenderProps(columnConfig, props, rowScope)
|
|
50
|
+
const params = {
|
|
51
|
+
lang,
|
|
52
|
+
rootValue,
|
|
53
|
+
dynamicMapComp,
|
|
54
|
+
props: renderProps,
|
|
55
|
+
messageInstance
|
|
56
|
+
}
|
|
57
|
+
const compProps = {
|
|
58
|
+
disabled: calcDisable(columnConfig, props.mode)
|
|
59
|
+
}
|
|
60
|
+
const rules = getFormItemRule(columnConfig, lang, params, compProps, true)
|
|
61
|
+
const validator = new AsyncValidator({
|
|
62
|
+
[columnConfig.dynamicHireRelat]: rules
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
async function toValidate() {
|
|
66
|
+
try {
|
|
67
|
+
await validator.validate({[columnConfig.dynamicHireRelat]: row[columnConfig.metaCode]})
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return new Promise((resolve, inject) => {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
let failPageNum = 0
|
|
72
|
+
if (index) {
|
|
73
|
+
failPageNum = parseInt((index + 1) / page.pageSize)
|
|
74
|
+
if ((index + 1) % page.pageSize) {
|
|
75
|
+
failPageNum ++
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
page.pageNum = failPageNum
|
|
79
|
+
inject({})
|
|
80
|
+
});
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
await toValidate()
|
|
50
86
|
}
|
|
51
|
-
const rules = getFormItemRule(columnConfig, lang, params, compProps)
|
|
52
|
-
const validator = new AsyncValidator({
|
|
53
|
-
[props.config.metaCode]: rules
|
|
54
|
-
// validator: (rule, value, callback) => {
|
|
55
|
-
// callback(new Error('test error'))
|
|
56
|
-
// return
|
|
57
|
-
// }
|
|
58
|
-
})
|
|
59
|
-
const a = await validator.validate({[columnConfig.metaCode]: row[columnConfig.metaCode]})
|
|
60
|
-
debugger
|
|
61
87
|
}
|
|
62
88
|
}
|
|
63
|
-
|
|
89
|
+
return true
|
|
64
90
|
}
|
|
65
91
|
|
|
66
92
|
function getItemRenderProps(itemConfig, tableProps, rowScope) {
|
|
67
|
-
const {row } = rowScope
|
|
93
|
+
const { row } = rowScope
|
|
68
94
|
return {
|
|
69
95
|
config: itemConfig,
|
|
70
96
|
modelValue: row[itemConfig.metaCode],
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ElForm v-bind="formProps" :ref="refFn" :model="props.modelValue">
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<FormPolyfill :form="rootForm">
|
|
4
|
+
<ElRow v-bind="rowProps">
|
|
5
|
+
<Renderer :config="pmPageMetaList" v-model="val"></Renderer>
|
|
6
|
+
</ElRow>
|
|
7
|
+
</FormPolyfill>
|
|
6
8
|
</ElForm>
|
|
7
9
|
</template>
|
|
8
10
|
<script setup>
|
|
9
11
|
import Renderer from '../../renderer.jsx'
|
|
10
12
|
import { computed, inject } from "vue"
|
|
11
13
|
import { ElForm, ElRow } from 'element-plus'
|
|
12
|
-
|
|
14
|
+
import FormPolyfill from '../helper/FormPolyfill.jsx'
|
|
13
15
|
|
|
14
16
|
const emits = defineEmits(['update:modelValue'])
|
|
15
17
|
const props = defineProps({
|
|
@@ -36,9 +36,9 @@ export default {
|
|
|
36
36
|
const isFrontPage = computed(() => {
|
|
37
37
|
return props.config?.frontPageFlag == '1'
|
|
38
38
|
})
|
|
39
|
-
//
|
|
39
|
+
// 是否开启分页功能 ====== start======
|
|
40
40
|
const pageable = computed(() => {
|
|
41
|
-
return props.config?.pageable == '1'
|
|
41
|
+
return isFrontPage.value || props.config?.pageable == '1'
|
|
42
42
|
})
|
|
43
43
|
// 分页器布局模式
|
|
44
44
|
const pageAlign = computed(() => {
|
|
@@ -554,22 +554,20 @@ export default {
|
|
|
554
554
|
}, {})
|
|
555
555
|
|
|
556
556
|
function validate() {
|
|
557
|
-
// lang,
|
|
558
|
-
// rootValue,
|
|
559
|
-
// dynamicMapComp,
|
|
560
|
-
// props,
|
|
561
|
-
// messageInstance: messageInstance?.value
|
|
562
557
|
return tableValidate({
|
|
563
558
|
props,
|
|
564
559
|
data: unref(modelValue),
|
|
565
|
-
lang,
|
|
560
|
+
lang: unref(lang),
|
|
566
561
|
rootValue,
|
|
567
562
|
dynamicMapComp,
|
|
568
|
-
messageInstance: messageInstance?.value
|
|
563
|
+
messageInstance: messageInstance?.value,
|
|
564
|
+
isFrontPage: unref(isFrontPage),
|
|
565
|
+
page,
|
|
569
566
|
})
|
|
570
567
|
}
|
|
571
568
|
|
|
572
569
|
const context = reactive({
|
|
570
|
+
prop: props.config.dynamicHireRelat,
|
|
573
571
|
// ...toRefs(props),
|
|
574
572
|
// $el: formItemRef,
|
|
575
573
|
// size: _size,
|
|
@@ -586,7 +584,7 @@ export default {
|
|
|
586
584
|
validate,
|
|
587
585
|
})
|
|
588
586
|
onMounted(() => {
|
|
589
|
-
|
|
587
|
+
formContext?.addField(context)
|
|
590
588
|
})
|
|
591
589
|
|
|
592
590
|
// 是否配置分页功能 ====== end======
|
package/src/utils/render.jsx
CHANGED
|
@@ -417,6 +417,7 @@ export function getComponentForConfig({messageInstance, config, disabled, getNat
|
|
|
417
417
|
if (config.isCustom) {
|
|
418
418
|
return () => loadModule(generateVuePath(config.fileId), loadModuleCache, messageInstance)
|
|
419
419
|
}
|
|
420
|
+
|
|
420
421
|
// 表格中中的列,是否需要转换为普通形式
|
|
421
422
|
if (isPlainColumn(config, disabled)) {
|
|
422
423
|
return CustomComponentPlain
|
|
@@ -809,7 +810,7 @@ function getFormItemExtendProps(config, lang, params, compProps) {
|
|
|
809
810
|
}
|
|
810
811
|
}
|
|
811
812
|
|
|
812
|
-
export function getFormItemRule(config, lang, params, compProps) {
|
|
813
|
+
export function getFormItemRule(config, lang, params, compProps, fromCustValid) {
|
|
813
814
|
const required = config.requiredFlag == '1'
|
|
814
815
|
const onlyRequiredFlag = config.onlyRequiredFlag
|
|
815
816
|
let trigger = ['blur', 'change']
|
|
@@ -828,7 +829,10 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
828
829
|
callback()
|
|
829
830
|
return
|
|
830
831
|
}
|
|
831
|
-
|
|
832
|
+
let val = config?.refValue
|
|
833
|
+
if (fromCustValid) {
|
|
834
|
+
val = value
|
|
835
|
+
}
|
|
832
836
|
const message = lang.indexOf('zh') > -1 ? `${config.metaNameZh || ''}不能为空` : `${config.metaNameEn || ''} can not be empty`
|
|
833
837
|
if (!onlyRequiredFlag && required) {
|
|
834
838
|
if (val === '' || val === null || val === undefined || (Array.isArray(val) && !val.length)) {
|
|
@@ -879,6 +883,9 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
879
883
|
return
|
|
880
884
|
}
|
|
881
885
|
const bingdValue = config?.refValue
|
|
886
|
+
if (fromCustValid) {
|
|
887
|
+
val = value
|
|
888
|
+
}
|
|
882
889
|
const val = (bingdValue === null || bingdValue === undefined) ? '' : bingdValue
|
|
883
890
|
if (!val) callback() // 为空不进行正则校验
|
|
884
891
|
for (let i = 0; i < regexPattern.length; i++) {
|