resolver-egretimp-plus 0.0.220 → 0.0.222

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resolver-egretimp-plus",
3
- "version": "0.0.220",
3
+ "version": "0.0.222",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -35,7 +35,7 @@ const amountFormat = computed(() => {
35
35
  })
36
36
 
37
37
  const calcProps = computed(() => {
38
- let desc = normalVal.value || props.config?.desc
38
+ let desc = normalVal.value ?? props.config?.desc
39
39
  let title = lang?.value?.indexOf('zh') > -1 ? props.config?.metaNameZh : props.config?.metaNameEn
40
40
  try {
41
41
  if (desc?.toString) {
@@ -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,32 @@ export default {
16
16
  textAreaCnt: {
17
17
  type: [Number, String],
18
18
  default: 2,
19
- }
19
+ },
20
+ showMoney: {
21
+ type: String,
22
+ default: ''
23
+ },
24
+ // 小数位数
25
+ decimal: {
26
+ type: Number,
27
+ default: 2
28
+ },
29
+ // 是否显示货币符号
30
+ showSymbol: {
31
+ type: String,
32
+ default: ''
33
+ },
34
+ // 货币符号
35
+ symbol: {
36
+ type: String,
37
+ default: '¥'
38
+ },
39
+ // 符号位置:before/after
40
+ symbolPosition: {
41
+ type: String,
42
+ default: 'before',
43
+ validator: value => ['before', 'after'].includes(value)
44
+ },
20
45
  },
21
46
  emits: ['update:modelValue'],
22
47
  setup(props, { emit, attrs, expose }) {
@@ -43,6 +68,7 @@ export default {
43
68
  const ret = {
44
69
  ...inputProps.value
45
70
  }
71
+ delete ret.modelValue
46
72
  delete ret.suffixIcon
47
73
  delete ret.prefixIcon
48
74
  return ret
@@ -50,6 +76,7 @@ export default {
50
76
  const showTooltip = computed(() => {
51
77
  return props?.config?.showTooltip == '1' && props.disabled
52
78
  })
79
+ // 这个是真实的值
53
80
  const modelValue = computed({
54
81
  get() {
55
82
  return props.modelValue
@@ -58,6 +85,19 @@ export default {
58
85
  emit('update:modelValue', val)
59
86
  }
60
87
  })
88
+ // 如果开启了金额显示的话,需要有currentVal进行中间值展示
89
+ const currentVal = ref('')
90
+ watch(modelValue, (val) => {
91
+ const value = formatValue(val)
92
+ if (currentVal.value != value) {
93
+ currentVal.value = value
94
+ }
95
+ }, {
96
+ immediate: true
97
+ })
98
+ const displayValue = computed(() => {
99
+ return props.showMoney == '1' ? currentVal.value : modelValue.value
100
+ })
61
101
  const isPagePopup = computed(() => {
62
102
  return props.config?.lcpPagePopupMapVO
63
103
  })
@@ -71,11 +111,24 @@ export default {
71
111
  })
72
112
  const vmodelProps = computed(() => {
73
113
  const ret = {
74
- modelValue: modelValue.value
114
+ modelValue: displayValue.value
75
115
  }
76
116
  if (!(isPagePopup.value && !isPagePopupAlwayEdit.value)) {
77
117
  ret['onUpdate:modelValue'] = (val) => {
78
- modelValue.value = val
118
+ if (props.showMoney == '1') {
119
+ currentVal.value = val
120
+ } else {
121
+ modelValue.value = val
122
+ }
123
+ }
124
+ if (props.showMoney == '1') {
125
+ ret['onFocus'] = () => {
126
+ currentVal.value = parseValue(currentVal.value)
127
+ }
128
+ ret['onBlur'] = () => {
129
+ currentVal.value = formatValue(currentVal.value)
130
+ modelValue.value = parseValue(currentVal.value)
131
+ }
79
132
  }
80
133
  } else {
81
134
  ret['onClear'] = () => {
@@ -187,6 +240,37 @@ export default {
187
240
  }
188
241
  return ret
189
242
  }
243
+
244
+ // 格式化显示
245
+ function formatValue(value) {
246
+ if (value === null || isNaN(value)) return ''
247
+ let val = parseFloat(value)
248
+ if (isNaN(val)) {
249
+ return ''
250
+ }
251
+ // 处理千分位
252
+ const parts = val.toFixed(props.decimal).split('.')
253
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
254
+
255
+ // 添加货币符号
256
+ const formatted = parts.join('.')
257
+ return props.showSymbol == '1'
258
+ ? props.symbolPosition === 'before'
259
+ ? `${props.symbol} ${formatted}`
260
+ : `${formatted} ${props.symbol}`
261
+ : formatted
262
+ }
263
+
264
+ // 解析输入值
265
+ function parseValue(value) {
266
+ if (value === undefined || value === null || value === '') {
267
+ return ''
268
+ }
269
+ // 移除所有非数字字符(保留负号和小数点)
270
+ const parsed = Number(value.replace(/[^\d.-]/g, ''))
271
+ return isNaN(parsed) ? '' : parsed
272
+ }
273
+
190
274
  expose({
191
275
  click: (params) => {
192
276
  attrs?.onClick?.(null, params)
@@ -195,7 +279,7 @@ export default {
195
279
  return () => {
196
280
  return (
197
281
  <div class="input-contrainer" {...inputWrapAttrs.value}>
198
- <span ref={(e) => calcSpanRef.value = e} class="calc-span">{ modelValue.value }</span>
282
+ <span ref={(e) => calcSpanRef.value = e} class="calc-span">{ displayValue.value }</span>
199
283
  {
200
284
  polyfillInputWrap(
201
285
  <div class="input-wrap" ref={(e) => inputWrapRef.value = e}>
@@ -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.bindValue
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: ['blur', 'change']
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 val = (config.bindValue === null || config.bindValue === undefined) ? '' : config.bindValue
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: ['blur', 'change']
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: ['blur', 'change']
867
+ trigger,
862
868
  })
863
869
  }
864
870
  })