resolver-egretimp-plus 0.0.225 → 0.0.227

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.225",
3
+ "version": "0.0.227",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <span class="custom-component-plain" :class="classObj" @click="clickAction">{{ props.formatter?.(value) || value }}</span>
2
+ <span class="custom-component-plain" :class="classObj" @click="clickAction">{{ props.formatter?.(value) ?? value }}</span>
3
3
  </template>
4
4
  <script setup>
5
5
  import { findComponent } from '../../utils/common';
@@ -20,7 +20,45 @@ const props = defineProps({
20
20
  },
21
21
  isPointer: {
22
22
  type: [String]
23
- }
23
+ },
24
+ showMoney: {
25
+ type: [String, Number],
26
+ default: ''
27
+ },
28
+ min: {
29
+ type: Number,
30
+ default: -Infinity
31
+ },
32
+ max: {
33
+ type: Number,
34
+ default: Infinity
35
+ },
36
+ // 小数位数
37
+ decimal: {
38
+ type: Number,
39
+ default: 2
40
+ },
41
+ // 在显示金额的时候,可以显示的符号
42
+ canShowFlag: {
43
+ type: Array,
44
+ default: ['na', '-']
45
+ },
46
+ // 是否显示货币符号
47
+ showSymbol: {
48
+ type: String,
49
+ default: ''
50
+ },
51
+ // 货币符号
52
+ symbol: {
53
+ type: String,
54
+ default: '¥'
55
+ },
56
+ // 符号位置:before/after
57
+ symbolPosition: {
58
+ type: String,
59
+ default: 'before',
60
+ validator: value => ['before', 'after'].includes(value)
61
+ },
24
62
  })
25
63
  const lang = inject('lang')
26
64
  function isPatchComponent(components, props) {
@@ -39,6 +77,9 @@ const value = computed(() => {
39
77
  const val = isNaN(Number(modelValue.value)) ? modelValue.value : Number(modelValue.value)
40
78
  return dayjs(val).format(props?.config?.format || 'YYYY-MM-DD')
41
79
  }
80
+ if (props.showMoney == '1') {
81
+ return formatValue(modelValue.value)
82
+ }
42
83
  return modelValue.value
43
84
  }
44
85
  })
@@ -90,6 +131,33 @@ function selectFormat(value) {
90
131
  return `${ret}${ret ? ',' : ''}${str}`
91
132
  }, '')
92
133
  }
134
+
135
+ // 格式化显示
136
+ function formatValue(value) {
137
+ if (props.canShowFlag?.includes(String(value).toLowerCase())) {
138
+ return value
139
+ }
140
+ if (value === null || isNaN(value)) return ''
141
+ let val = parseFloat(value)
142
+ if (isNaN(val)) {
143
+ return ''
144
+ }
145
+
146
+ // 转换数字并限制范围
147
+ val = Math.max(props.min, Math.min(props.max, val))
148
+
149
+ // 处理千分位
150
+ const parts = val.toFixed(props.decimal).split('.')
151
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
152
+
153
+ // 添加货币符号
154
+ const formatted = parts.join('.')
155
+ return props.showSymbol == '1'
156
+ ? props.symbolPosition === 'before'
157
+ ? `${props.symbol} ${formatted}`
158
+ : `${formatted} ${props.symbol}`
159
+ : formatted
160
+ }
93
161
  </script>
94
162
  <style lang="scss" scoped>
95
163
  .custom-component-plain {
@@ -862,7 +862,7 @@ function getFormItemRule(config, lang, params) {
862
862
  callback()
863
863
  return
864
864
  }
865
- return validator(rule, value, callback)
865
+ return validator(rule, value, callback, config)
866
866
  },
867
867
  trigger,
868
868
  })