resolver-egretimp-plus 0.0.221 → 0.0.223
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
|
@@ -38,7 +38,7 @@ const value = computed({
|
|
|
38
38
|
},
|
|
39
39
|
set(val) {
|
|
40
40
|
if (isMutiple.value) {
|
|
41
|
-
modelValue.value = val.join(',')
|
|
41
|
+
modelValue.value = Array.isArray(val) ? val.join(',') : val
|
|
42
42
|
} else {
|
|
43
43
|
modelValue.value = val
|
|
44
44
|
}
|
|
@@ -61,7 +61,7 @@ const clear = () => {
|
|
|
61
61
|
value.value = ''
|
|
62
62
|
}
|
|
63
63
|
const onChange = ({detail}) => {
|
|
64
|
-
value.value = detail.value ||
|
|
64
|
+
value.value = detail.value || ""
|
|
65
65
|
props.config?.onChange(modelValue.value)
|
|
66
66
|
}
|
|
67
67
|
</script>
|
|
@@ -16,7 +16,40 @@ export default {
|
|
|
16
16
|
textAreaCnt: {
|
|
17
17
|
type: [Number, String],
|
|
18
18
|
default: 2,
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
|
+
showMoney: {
|
|
21
|
+
type: [String, Number],
|
|
22
|
+
default: ''
|
|
23
|
+
},
|
|
24
|
+
min: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: -Infinity
|
|
27
|
+
},
|
|
28
|
+
max: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: Infinity
|
|
31
|
+
},
|
|
32
|
+
// 小数位数
|
|
33
|
+
decimal: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 2
|
|
36
|
+
},
|
|
37
|
+
// 是否显示货币符号
|
|
38
|
+
showSymbol: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
// 货币符号
|
|
43
|
+
symbol: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: '¥'
|
|
46
|
+
},
|
|
47
|
+
// 符号位置:before/after
|
|
48
|
+
symbolPosition: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: 'before',
|
|
51
|
+
validator: value => ['before', 'after'].includes(value)
|
|
52
|
+
},
|
|
20
53
|
},
|
|
21
54
|
emits: ['update:modelValue'],
|
|
22
55
|
setup(props, { emit, attrs, expose }) {
|
|
@@ -43,6 +76,7 @@ export default {
|
|
|
43
76
|
const ret = {
|
|
44
77
|
...inputProps.value
|
|
45
78
|
}
|
|
79
|
+
delete ret.modelValue
|
|
46
80
|
delete ret.suffixIcon
|
|
47
81
|
delete ret.prefixIcon
|
|
48
82
|
return ret
|
|
@@ -50,6 +84,7 @@ export default {
|
|
|
50
84
|
const showTooltip = computed(() => {
|
|
51
85
|
return props?.config?.showTooltip == '1' && props.disabled
|
|
52
86
|
})
|
|
87
|
+
// 这个是真实的值
|
|
53
88
|
const modelValue = computed({
|
|
54
89
|
get() {
|
|
55
90
|
return props.modelValue
|
|
@@ -58,6 +93,19 @@ export default {
|
|
|
58
93
|
emit('update:modelValue', val)
|
|
59
94
|
}
|
|
60
95
|
})
|
|
96
|
+
// 如果开启了金额显示的话,需要有currentVal进行中间值展示
|
|
97
|
+
const currentVal = ref('')
|
|
98
|
+
watch(modelValue, (val) => {
|
|
99
|
+
const value = formatValue(val)
|
|
100
|
+
if (currentVal.value != value) {
|
|
101
|
+
currentVal.value = value
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
immediate: true
|
|
105
|
+
})
|
|
106
|
+
const displayValue = computed(() => {
|
|
107
|
+
return props.showMoney == '1' ? currentVal.value : modelValue.value
|
|
108
|
+
})
|
|
61
109
|
const isPagePopup = computed(() => {
|
|
62
110
|
return props.config?.lcpPagePopupMapVO
|
|
63
111
|
})
|
|
@@ -71,11 +119,24 @@ export default {
|
|
|
71
119
|
})
|
|
72
120
|
const vmodelProps = computed(() => {
|
|
73
121
|
const ret = {
|
|
74
|
-
modelValue:
|
|
122
|
+
modelValue: displayValue.value
|
|
75
123
|
}
|
|
76
124
|
if (!(isPagePopup.value && !isPagePopupAlwayEdit.value)) {
|
|
77
125
|
ret['onUpdate:modelValue'] = (val) => {
|
|
78
|
-
|
|
126
|
+
if (props.showMoney == '1') {
|
|
127
|
+
currentVal.value = val
|
|
128
|
+
} else {
|
|
129
|
+
modelValue.value = val
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (props.showMoney == '1') {
|
|
133
|
+
ret['onFocus'] = () => {
|
|
134
|
+
currentVal.value = parseValue(currentVal.value)
|
|
135
|
+
}
|
|
136
|
+
ret['onBlur'] = () => {
|
|
137
|
+
currentVal.value = formatValue(currentVal.value)
|
|
138
|
+
modelValue.value = parseValue(currentVal.value)
|
|
139
|
+
}
|
|
79
140
|
}
|
|
80
141
|
} else {
|
|
81
142
|
ret['onClear'] = () => {
|
|
@@ -187,6 +248,41 @@ export default {
|
|
|
187
248
|
}
|
|
188
249
|
return ret
|
|
189
250
|
}
|
|
251
|
+
|
|
252
|
+
// 格式化显示
|
|
253
|
+
function formatValue(value) {
|
|
254
|
+
if (value === null || isNaN(value)) return ''
|
|
255
|
+
let val = parseFloat(value)
|
|
256
|
+
if (isNaN(val)) {
|
|
257
|
+
return ''
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 转换数字并限制范围
|
|
261
|
+
val = Math.max(props.min, Math.min(props.max, val))
|
|
262
|
+
|
|
263
|
+
// 处理千分位
|
|
264
|
+
const parts = val.toFixed(props.decimal).split('.')
|
|
265
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
266
|
+
|
|
267
|
+
// 添加货币符号
|
|
268
|
+
const formatted = parts.join('.')
|
|
269
|
+
return props.showSymbol == '1'
|
|
270
|
+
? props.symbolPosition === 'before'
|
|
271
|
+
? `${props.symbol} ${formatted}`
|
|
272
|
+
: `${formatted} ${props.symbol}`
|
|
273
|
+
: formatted
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 解析输入值
|
|
277
|
+
function parseValue(value) {
|
|
278
|
+
if (value === undefined || value === null || value === '') {
|
|
279
|
+
return ''
|
|
280
|
+
}
|
|
281
|
+
// 移除所有非数字字符(保留负号和小数点)
|
|
282
|
+
const parsed = Number(value.replace(/[^\d.-]/g, ''))
|
|
283
|
+
return isNaN(parsed) ? '' : parsed
|
|
284
|
+
}
|
|
285
|
+
|
|
190
286
|
expose({
|
|
191
287
|
click: (params) => {
|
|
192
288
|
attrs?.onClick?.(null, params)
|
|
@@ -195,7 +291,7 @@ export default {
|
|
|
195
291
|
return () => {
|
|
196
292
|
return (
|
|
197
293
|
<div class="input-contrainer" {...inputWrapAttrs.value}>
|
|
198
|
-
<span ref={(e) => calcSpanRef.value = e} class="calc-span">{
|
|
294
|
+
<span ref={(e) => calcSpanRef.value = e} class="calc-span">{ displayValue.value }</span>
|
|
199
295
|
{
|
|
200
296
|
polyfillInputWrap(
|
|
201
297
|
<div class="input-wrap" ref={(e) => inputWrapRef.value = e}>
|
package/src/utils/render.jsx
CHANGED
|
@@ -758,6 +758,11 @@ function getFormItemExtendProps(config, lang, params) {
|
|
|
758
758
|
function getFormItemRule(config, lang, params) {
|
|
759
759
|
const required = config.requiredFlag === '1'
|
|
760
760
|
const onlyRequiredFlag = config.onlyRequiredFlag
|
|
761
|
+
let trigger = ['blur', 'change']
|
|
762
|
+
// 如果是input框并且开启了金额显示
|
|
763
|
+
if (config.showMoney && config.metaType == 'ElInput') {
|
|
764
|
+
trigger = 'blur'
|
|
765
|
+
}
|
|
761
766
|
const rules = [{
|
|
762
767
|
// required,
|
|
763
768
|
validator: (rule, value, callback) => {
|
|
@@ -769,7 +774,7 @@ function getFormItemRule(config, lang, params) {
|
|
|
769
774
|
callback()
|
|
770
775
|
return
|
|
771
776
|
}
|
|
772
|
-
const val = config
|
|
777
|
+
const val = config?.refValue
|
|
773
778
|
const message = lang.indexOf('zh') > -1 ? `${config.metaNameZh}不能为空` : `${config.metaNameEn} can not be empty`
|
|
774
779
|
if (!onlyRequiredFlag && required) {
|
|
775
780
|
if (val === '' || val === null || val === undefined) {
|
|
@@ -786,7 +791,7 @@ function getFormItemRule(config, lang, params) {
|
|
|
786
791
|
callback()
|
|
787
792
|
}
|
|
788
793
|
},
|
|
789
|
-
trigger
|
|
794
|
+
trigger,
|
|
790
795
|
}]
|
|
791
796
|
let regexPattern = []
|
|
792
797
|
if (config.regexPattern) {
|
|
@@ -819,7 +824,8 @@ function getFormItemRule(config, lang, params) {
|
|
|
819
824
|
callback()
|
|
820
825
|
return
|
|
821
826
|
}
|
|
822
|
-
const
|
|
827
|
+
const bingdValue = config?.refValue
|
|
828
|
+
const val = (bingdValue === null || bingdValue === undefined) ? '' : bingdValue
|
|
823
829
|
if (!val) callback() // 为空不进行正则校验
|
|
824
830
|
for (let i = 0; i < regexPattern.length; i++) {
|
|
825
831
|
const validInfo = regexPattern[i]
|
|
@@ -838,7 +844,7 @@ function getFormItemRule(config, lang, params) {
|
|
|
838
844
|
}
|
|
839
845
|
callback()
|
|
840
846
|
},
|
|
841
|
-
trigger
|
|
847
|
+
trigger,
|
|
842
848
|
})
|
|
843
849
|
}
|
|
844
850
|
let validators = config.validators
|
|
@@ -858,7 +864,7 @@ function getFormItemRule(config, lang, params) {
|
|
|
858
864
|
}
|
|
859
865
|
return validator(rule, value, callback)
|
|
860
866
|
},
|
|
861
|
-
trigger
|
|
867
|
+
trigger,
|
|
862
868
|
})
|
|
863
869
|
}
|
|
864
870
|
})
|