resolver-egretimp-plus 0.1.110 → 0.1.112
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/theme/element/index.css +1 -1
- package/dist/theme/element/src/components/common.scss +7 -1
- package/dist/theme/element/src/components/table.scss +13 -0
- package/dist/web/index.js +13 -13
- 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 +18 -16
- package/src/theme/element/components/common.scss +7 -1
- package/src/theme/element/components/table.scss +13 -0
- package/src/utils/render.jsx +32 -29
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({
|
|
@@ -23,10 +23,14 @@ export default {
|
|
|
23
23
|
triggerRef: null,
|
|
24
24
|
content: ''
|
|
25
25
|
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
|
|
27
|
+
// let pageSize = 10 // 默认每页5条
|
|
28
|
+
// if (props.config?.pageSize) {
|
|
29
|
+
// pageSize = parseInt(props.config.pageSize) || 5
|
|
30
|
+
// }
|
|
31
|
+
const pageSize = computed(() => {
|
|
32
|
+
return parseInt(props.config.pageSize) || 5
|
|
33
|
+
})
|
|
30
34
|
const page = reactive({
|
|
31
35
|
pageNum: 1,
|
|
32
36
|
pageSize,
|
|
@@ -36,9 +40,9 @@ export default {
|
|
|
36
40
|
const isFrontPage = computed(() => {
|
|
37
41
|
return props.config?.frontPageFlag == '1'
|
|
38
42
|
})
|
|
39
|
-
//
|
|
43
|
+
// 是否开启分页功能 ====== start======
|
|
40
44
|
const pageable = computed(() => {
|
|
41
|
-
return props.config?.pageable == '1'
|
|
45
|
+
return isFrontPage.value || props.config?.pageable == '1'
|
|
42
46
|
})
|
|
43
47
|
// 分页器布局模式
|
|
44
48
|
const pageAlign = computed(() => {
|
|
@@ -252,6 +256,7 @@ export default {
|
|
|
252
256
|
retObj.className = `${retObj.className || ''} clear-index`
|
|
253
257
|
}
|
|
254
258
|
if (!isVirtualized.value) {
|
|
259
|
+
retObj.className = `${retObj.className} cell-col-ellipsis`
|
|
255
260
|
if (!retObj.prop) {
|
|
256
261
|
retObj.prop = config.metaCode
|
|
257
262
|
}
|
|
@@ -554,22 +559,20 @@ export default {
|
|
|
554
559
|
}, {})
|
|
555
560
|
|
|
556
561
|
function validate() {
|
|
557
|
-
// lang,
|
|
558
|
-
// rootValue,
|
|
559
|
-
// dynamicMapComp,
|
|
560
|
-
// props,
|
|
561
|
-
// messageInstance: messageInstance?.value
|
|
562
562
|
return tableValidate({
|
|
563
563
|
props,
|
|
564
564
|
data: unref(modelValue),
|
|
565
|
-
lang,
|
|
565
|
+
lang: unref(lang),
|
|
566
566
|
rootValue,
|
|
567
567
|
dynamicMapComp,
|
|
568
|
-
messageInstance: messageInstance?.value
|
|
568
|
+
messageInstance: messageInstance?.value,
|
|
569
|
+
isFrontPage: unref(isFrontPage),
|
|
570
|
+
page,
|
|
569
571
|
})
|
|
570
572
|
}
|
|
571
573
|
|
|
572
574
|
const context = reactive({
|
|
575
|
+
prop: props.config.dynamicHireRelat,
|
|
573
576
|
// ...toRefs(props),
|
|
574
577
|
// $el: formItemRef,
|
|
575
578
|
// size: _size,
|
|
@@ -586,7 +589,7 @@ export default {
|
|
|
586
589
|
validate,
|
|
587
590
|
})
|
|
588
591
|
onMounted(() => {
|
|
589
|
-
|
|
592
|
+
formContext?.addField(context)
|
|
590
593
|
})
|
|
591
594
|
|
|
592
595
|
// 是否配置分页功能 ====== end======
|
|
@@ -602,7 +605,6 @@ export default {
|
|
|
602
605
|
const dataList = computed(() => {
|
|
603
606
|
return totalRow.value?.length ? [...tableData.value, ...totalRow.value] : tableData.value
|
|
604
607
|
})
|
|
605
|
-
// console.log('dynamicMapComp===:', inject('dynamicMapComp'))
|
|
606
608
|
|
|
607
609
|
function cellMouseEnenter(e) {
|
|
608
610
|
const {overflow, content} = eleIsOverflow(e)
|
|
@@ -678,7 +680,7 @@ export default {
|
|
|
678
680
|
}
|
|
679
681
|
if (isVirtualized.value) {
|
|
680
682
|
retVnode = (
|
|
681
|
-
<div className="table-v2-cell" onMouseenter={(e) => cellMouseEnenter(e)}
|
|
683
|
+
<div className="table-v2-cell" onMouseenter={(e) => cellMouseEnenter(e)} onMouseleave={(e) => cellMouseout(e)}>
|
|
682
684
|
{retVnode}
|
|
683
685
|
</div>
|
|
684
686
|
)
|
|
@@ -154,6 +154,14 @@
|
|
|
154
154
|
.pagination-wrap {
|
|
155
155
|
display: flex;
|
|
156
156
|
}
|
|
157
|
+
.cell-col-ellipsis {
|
|
158
|
+
& > .cell > .el-col {
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
text-overflow: ellipsis;
|
|
161
|
+
white-space: nowrap;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
157
165
|
// table-v2
|
|
158
166
|
.table-border {
|
|
159
167
|
--el-table-header-bg-color: #f5f6f7;
|
|
@@ -181,6 +189,11 @@
|
|
|
181
189
|
.table-v2-cell {
|
|
182
190
|
padding: 0 16px;
|
|
183
191
|
width: 100%;
|
|
192
|
+
& > .el-col {
|
|
193
|
+
overflow: hidden;
|
|
194
|
+
text-overflow: ellipsis;
|
|
195
|
+
white-space: nowrap;
|
|
196
|
+
}
|
|
184
197
|
}
|
|
185
198
|
.table-v2-common-row {
|
|
186
199
|
border-bottom: none;
|
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
|
|
@@ -720,6 +721,12 @@ function generateFormItemPc (config, lang, compProps, params,) {
|
|
|
720
721
|
return node
|
|
721
722
|
}
|
|
722
723
|
}
|
|
724
|
+
|
|
725
|
+
// 表格中的列,不需要form-item的时候,就尽可能不要,可以提升性能
|
|
726
|
+
|
|
727
|
+
if (!props?.rules?.length && props?.class?.['hidden-label'] && config.isColumn) {
|
|
728
|
+
return node
|
|
729
|
+
}
|
|
723
730
|
|
|
724
731
|
const slots = {
|
|
725
732
|
error: (info) => createFormLabelErrorTip(info, config, lang)
|
|
@@ -786,6 +793,10 @@ export function generateFormItemPolyfill(config, lang, compProps, _isH5, params)
|
|
|
786
793
|
}
|
|
787
794
|
}
|
|
788
795
|
|
|
796
|
+
function isHiddenLable(config) {
|
|
797
|
+
return (config.labelWidth == 0 || config.labelWidth === '0px' || config.labelHidden == '1') && config.showLabel != '1'
|
|
798
|
+
}
|
|
799
|
+
|
|
789
800
|
function getFormItemExtendProps(config, lang, params, compProps) {
|
|
790
801
|
const prop = config.dynamicHireRelat || ''
|
|
791
802
|
// const propAttr = config.dynamicHireRelat ? config.dynamicHireRelat?.split('->') : []
|
|
@@ -802,14 +813,14 @@ function getFormItemExtendProps(config, lang, params, compProps) {
|
|
|
802
813
|
class: {
|
|
803
814
|
[`vertical-${config['label-vertical'] || config['labelVertical'] || 'center'}`]: true,
|
|
804
815
|
'content-right': config.contentRight,
|
|
805
|
-
'hidden-label': (config
|
|
816
|
+
'hidden-label': isHiddenLable(config),
|
|
806
817
|
[`label-position-${config['label-position'] || config['labelPosition'] || 'right'}`]: true // label-position 支持三个值,right、left、top
|
|
807
818
|
},
|
|
808
819
|
style,
|
|
809
820
|
}
|
|
810
821
|
}
|
|
811
822
|
|
|
812
|
-
export function getFormItemRule(config, lang, params, compProps) {
|
|
823
|
+
export function getFormItemRule(config, lang, params, compProps, fromCustValid) {
|
|
813
824
|
const required = config.requiredFlag == '1'
|
|
814
825
|
const onlyRequiredFlag = config.onlyRequiredFlag
|
|
815
826
|
let trigger = ['blur', 'change']
|
|
@@ -817,18 +828,22 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
817
828
|
if (config.showMoney && config.metaType == 'ElInput') {
|
|
818
829
|
trigger = 'blur'
|
|
819
830
|
}
|
|
820
|
-
const rules = [
|
|
831
|
+
const rules = []
|
|
832
|
+
// 是否需要去进行校验
|
|
833
|
+
const needToValid = !(
|
|
834
|
+
(compProps?.disabled || isPlainColumn(config, compProps?.disabled)) && config.alongValidate != '1' ||
|
|
835
|
+
isChainHidden({ config })
|
|
836
|
+
)
|
|
837
|
+
if (!needToValid) {
|
|
838
|
+
return rules
|
|
839
|
+
}
|
|
840
|
+
rules.push({
|
|
821
841
|
// required,
|
|
822
842
|
validator: (rule, value, callback) => {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
843
|
+
let val = config?.refValue
|
|
844
|
+
if (fromCustValid) {
|
|
845
|
+
val = value
|
|
826
846
|
}
|
|
827
|
-
if (isChainHidden({ config })) {
|
|
828
|
-
callback()
|
|
829
|
-
return
|
|
830
|
-
}
|
|
831
|
-
const val = config?.refValue
|
|
832
847
|
const message = lang.indexOf('zh') > -1 ? `${config.metaNameZh || ''}不能为空` : `${config.metaNameEn || ''} can not be empty`
|
|
833
848
|
if (!onlyRequiredFlag && required) {
|
|
834
849
|
if (val === '' || val === null || val === undefined || (Array.isArray(val) && !val.length)) {
|
|
@@ -846,7 +861,8 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
846
861
|
}
|
|
847
862
|
},
|
|
848
863
|
trigger,
|
|
849
|
-
}
|
|
864
|
+
})
|
|
865
|
+
|
|
850
866
|
let regexPattern = []
|
|
851
867
|
if (config.regexPattern) {
|
|
852
868
|
try {
|
|
@@ -870,15 +886,10 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
870
886
|
if (regexPattern?.length) {
|
|
871
887
|
rules.push({
|
|
872
888
|
validator: (rule, value, callback) => {
|
|
873
|
-
if ((compProps?.disabled || isPlainColumn(config, compProps?.disabled)) && config.alongValidate != '1') {
|
|
874
|
-
callback()
|
|
875
|
-
return
|
|
876
|
-
}
|
|
877
|
-
if (isChainHidden({ config })) {
|
|
878
|
-
callback()
|
|
879
|
-
return
|
|
880
|
-
}
|
|
881
889
|
const bingdValue = config?.refValue
|
|
890
|
+
if (fromCustValid) {
|
|
891
|
+
val = value
|
|
892
|
+
}
|
|
882
893
|
const val = (bingdValue === null || bingdValue === undefined) ? '' : bingdValue
|
|
883
894
|
if (!val) callback() // 为空不进行正则校验
|
|
884
895
|
for (let i = 0; i < regexPattern.length; i++) {
|
|
@@ -908,14 +919,6 @@ export function getFormItemRule(config, lang, params, compProps) {
|
|
|
908
919
|
if (isFunction(validator)) {
|
|
909
920
|
rules.push({
|
|
910
921
|
validator: (rule, value, callback) => {
|
|
911
|
-
if ((compProps?.disabled || isPlainColumn(config, compProps?.disabled)) && config.alongValidate != '1') {
|
|
912
|
-
callback()
|
|
913
|
-
return
|
|
914
|
-
}
|
|
915
|
-
if (isChainHidden({ config })) {
|
|
916
|
-
callback()
|
|
917
|
-
return
|
|
918
|
-
}
|
|
919
922
|
return validator(rule, config.refValue, callback, config)
|
|
920
923
|
},
|
|
921
924
|
trigger,
|
|
@@ -988,7 +991,7 @@ function createFormLable(config, lang = 'zh') {
|
|
|
988
991
|
<div title={lang.indexOf('zh') > -1 ? (config.labelZh || config.metaNameZh) : (config.labelEn || config.metaNameEn)} class="custom-label">
|
|
989
992
|
<span
|
|
990
993
|
onMouseenter={(e) => labelMouseEnenter(e, config, lang)}
|
|
991
|
-
|
|
994
|
+
onMouseleave={() => config._labelShowTip = false}
|
|
992
995
|
class={`custom-label-content ${required ? 'custom-label-require' : ''}`} style={config.labelStyle}
|
|
993
996
|
onClick={() => config.onLabelClick && config.onLabelClick?.(config)}
|
|
994
997
|
>
|