resolver-egretimp-plus 0.1.109 → 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/resolver.js +22 -1
- 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/resolver-common.vue +40 -32
- package/src/utils/render.jsx +10 -3
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
|
+
}
|
|
@@ -87,16 +87,37 @@ export async function executeLoadServices(services = [], {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export function normalPageConfigs(pageConfig) {
|
|
90
|
+
export function normalPageConfigs(pageConfig, target) {
|
|
91
91
|
const rootOptionComp = pageConfig?.pmPageMetaList?.find(item => item.metaType === 'PC-root-panel' || item.metaType === 'H5-root-panel')
|
|
92
92
|
if (rootOptionComp) {
|
|
93
93
|
pageConfig.pmPageMetaList = rootOptionComp.pmPageMetaList
|
|
94
94
|
delete rootOptionComp.pmPageMetaList
|
|
95
95
|
pageConfig.rootOptionComp = rootOptionComp
|
|
96
96
|
}
|
|
97
|
+
if (target) {
|
|
98
|
+
const targetComp = getTargetComp(pageConfig, target)
|
|
99
|
+
if (targetComp) {
|
|
100
|
+
pageConfig.pmPageMetaList = [targetComp]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
97
103
|
return pageConfig
|
|
98
104
|
}
|
|
99
105
|
|
|
106
|
+
// 获取配置的时候,设置了只需要展示指定的部分
|
|
107
|
+
function getTargetComp(config, target = '') {
|
|
108
|
+
let ret = config
|
|
109
|
+
if (target) {
|
|
110
|
+
metaCodes = target.split('->')
|
|
111
|
+
ret = metaCodes.reduce((ret, metaCode) => {
|
|
112
|
+
if (ret && ret.pmPageMetaList && Array.isArray(ret.pmPageMetaList)) {
|
|
113
|
+
return ret.pmPageMetaList.find(item => item.metaCode === metaCode)
|
|
114
|
+
}
|
|
115
|
+
return ret
|
|
116
|
+
}, config)
|
|
117
|
+
}
|
|
118
|
+
return ret
|
|
119
|
+
}
|
|
120
|
+
|
|
100
121
|
export function resetConfigEventInit(dynamicMapComp) {
|
|
101
122
|
Object.keys(dynamicMapComp).forEach(key => {
|
|
102
123
|
if (hasOwn(dynamicMapComp[key], 'eventInit')) {
|
|
@@ -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
|
-
const compProps = {
|
|
49
|
-
disabled: calcDisable(columnConfig, props.mode)
|
|
50
|
-
}
|
|
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
|
|
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
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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()
|
|
86
|
+
}
|
|
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/resolver-common.vue
CHANGED
|
@@ -8,7 +8,7 @@ const props = defineProps({
|
|
|
8
8
|
busiIdentityId: String,
|
|
9
9
|
selects: {
|
|
10
10
|
type: Object,
|
|
11
|
-
default: () => ({})
|
|
11
|
+
default: () => ({_default: true})
|
|
12
12
|
},
|
|
13
13
|
getNativeComps: {
|
|
14
14
|
type: Function,
|
|
@@ -38,43 +38,51 @@ const props = defineProps({
|
|
|
38
38
|
type: Object,
|
|
39
39
|
default: () => ({})
|
|
40
40
|
},
|
|
41
|
+
// 外部传入的config
|
|
42
|
+
nativeConfig: [Object, Array]
|
|
41
43
|
})
|
|
44
|
+
const selectsLoad = ref(true)
|
|
42
45
|
defineOptions({
|
|
43
46
|
inheritAttrs: false
|
|
44
47
|
})
|
|
45
|
-
const loadSelects = ref({})
|
|
46
48
|
const attrs = useAttrs()
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
...loadSelects.value,
|
|
50
|
-
...(props.selects || {})
|
|
51
|
-
}
|
|
52
|
-
})
|
|
49
|
+
|
|
53
50
|
initInterceptors(props.messageInstance)
|
|
54
51
|
const { getPageConfig, pageConfig, selects } = useBuildInData({messageInstance: props.messageInstance, loadingInstance: props.loadingInstance, requestTraceId: props.requestTraceId})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
...(props.builtPolyfillReq || {}),
|
|
60
|
-
...(props.loadConfigReq || {})
|
|
61
|
-
}, {
|
|
62
|
-
configCb: (pageConfig) => {
|
|
63
|
-
// 配置数据加载完成事件 'loadedConfigCompeted'
|
|
64
|
-
attrs?.onLoadedConfigCompeted?.(pageConfig)
|
|
65
|
-
},
|
|
66
|
-
selectsCb: (selects) => {
|
|
67
|
-
// 配置数据加载完成事件 'loadedConfigCompeted'
|
|
68
|
-
// Object.keys(selects || {}).forEach(key => {
|
|
69
|
-
// props.selects[key] = selects[key]
|
|
70
|
-
// })
|
|
71
|
-
loadSelects.value = selects
|
|
72
|
-
attrs?.onLoadedSelectsCompeted?.(allSelects.value)
|
|
73
|
-
},
|
|
74
|
-
selectPolyReq: {
|
|
75
|
-
...(props.builtPolyfillReq || {}),
|
|
52
|
+
if (!props.nativeConfig) {
|
|
53
|
+
if (props.selects?._default) {
|
|
54
|
+
// 没有传selects对象的时候,在selectsCb中设置props.selects属性,是不会响应式的,所以这边需要进行逻辑控制
|
|
55
|
+
selectsLoad.value = false
|
|
76
56
|
}
|
|
77
|
-
|
|
57
|
+
getPageConfig({
|
|
58
|
+
busiIdentityId: props.busiIdentityId,
|
|
59
|
+
queryPageMeta: '1',
|
|
60
|
+
queryPageService: '1',
|
|
61
|
+
...(props.builtPolyfillReq || {}),
|
|
62
|
+
...(props.loadConfigReq || {})
|
|
63
|
+
}, {
|
|
64
|
+
configCb: (pageConfig) => {
|
|
65
|
+
// 配置数据加载完成事件 'loadedConfigCompeted'
|
|
66
|
+
attrs?.onLoadedConfigCompeted?.(pageConfig)
|
|
67
|
+
},
|
|
68
|
+
selectsCb: (selects) => {
|
|
69
|
+
// 配置数据加载完成事件 'loadedConfigCompeted'
|
|
70
|
+
Object.keys(selects || {}).forEach(key => {
|
|
71
|
+
props.selects[key] = selects[key]
|
|
72
|
+
})
|
|
73
|
+
attrs?.onLoadedSelectsCompeted?.(props.selects)
|
|
74
|
+
if (props.selects?._default) {
|
|
75
|
+
// 没有传selects对象的时候,在selectsCb中设置props.selects属性,是不会响应式的,所以这边需要进行逻辑控制
|
|
76
|
+
selectsLoad.value = true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
selectPolyReq: {
|
|
80
|
+
...(props.builtPolyfillReq || {}),
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
} else {
|
|
84
|
+
pageConfig.value = props.nativeConfig
|
|
85
|
+
}
|
|
78
86
|
|
|
79
87
|
const resolverRef = ref(null)
|
|
80
88
|
defineExpose({
|
|
@@ -106,7 +114,7 @@ defineExpose({
|
|
|
106
114
|
</script>
|
|
107
115
|
<template>
|
|
108
116
|
<Resolver
|
|
109
|
-
v-if="pageConfig"
|
|
117
|
+
v-if="pageConfig && selectsLoad"
|
|
110
118
|
ref="resolverRef"
|
|
111
119
|
v-bind="attrs"
|
|
112
120
|
:loadingInstance="props.loadingInstance"
|
|
@@ -114,7 +122,7 @@ defineExpose({
|
|
|
114
122
|
:getNativeComps="props.getNativeComps"
|
|
115
123
|
:copyModal="props.copyModal"
|
|
116
124
|
:config="pageConfig || null"
|
|
117
|
-
:selects="
|
|
125
|
+
:selects="props.selects"
|
|
118
126
|
:builtPolyfillReq="props.builtPolyfillReq"
|
|
119
127
|
:requestTraceId="props.requestTraceId"
|
|
120
128
|
></Resolver>
|
package/src/utils/render.jsx
CHANGED
|
@@ -199,7 +199,6 @@ export function normalConfig({
|
|
|
199
199
|
parent: null, // 这个是执行过程中,动态获取的
|
|
200
200
|
dynamicHireRelat: '', // 这个也是执行过程中,动态获取的层级
|
|
201
201
|
}
|
|
202
|
-
|
|
203
202
|
let extendAttrObj = parseExtendAttr(config)
|
|
204
203
|
let extendObj = {
|
|
205
204
|
removeCol: findComponent(NOT_NEED_COL_ITEM_META_TYPE, extendAttrObj.renderby) !== -1 || findComponent(NOT_NEED_COL_ITEM_META_TYPE, metaType) !== -1,
|
|
@@ -418,6 +417,7 @@ export function getComponentForConfig({messageInstance, config, disabled, getNat
|
|
|
418
417
|
if (config.isCustom) {
|
|
419
418
|
return () => loadModule(generateVuePath(config.fileId), loadModuleCache, messageInstance)
|
|
420
419
|
}
|
|
420
|
+
|
|
421
421
|
// 表格中中的列,是否需要转换为普通形式
|
|
422
422
|
if (isPlainColumn(config, disabled)) {
|
|
423
423
|
return CustomComponentPlain
|
|
@@ -449,6 +449,7 @@ export function getComponentForConfig({messageInstance, config, disabled, getNat
|
|
|
449
449
|
renderbyComp = <div>not component</div>
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
+
|
|
452
453
|
component = renderbyComp || component
|
|
453
454
|
}
|
|
454
455
|
return component
|
|
@@ -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++) {
|