resolver-egretimp-plus 0.0.156 → 0.0.157

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.156",
3
+ "version": "0.0.157",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, defineProps, inject, useAttrs } from 'vue'
3
- import { commonPropsType, formatDate, hasOwn } from '../../utils/index.js'
3
+ import { commonPropsType, formatDate, formatAmount, hasOwn } from '../../utils/index.js'
4
4
 
5
5
  const lang = inject('lang')
6
6
  const modelValue = defineModel()
@@ -24,6 +24,10 @@ const dateFormat = computed(() => {
24
24
  return props.config?.dateFormat
25
25
  })
26
26
 
27
+ const amountFormat = computed(() => {
28
+ return props.config?.amountFormat
29
+ })
30
+
27
31
  const calcProps = computed(() => {
28
32
  let desc = normalVal.value || props.config?.desc
29
33
  try {
@@ -33,8 +37,11 @@ const calcProps = computed(() => {
33
37
  if (dateFormat.value) {
34
38
  desc = formatDate(desc, dateFormat.value)
35
39
  }
40
+ if (amountFormat.value) {
41
+ desc = formatAmount(desc, amountFormat.value)
42
+ }
36
43
  if (props.formatter && typeof props.formatter === "function") {
37
- desc = props.formatter(desc)
44
+ desc = props.formatter(desc, props.config)
38
45
  }
39
46
  } catch (error) {
40
47
  console.log('CmiCell, error==:', error)
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { commonPropsType, formatDate, getConfigOptions, hasOwn } from '../../utils/index.js'
2
+ import { commonPropsType, formatDate, formatAmount, getConfigOptions, hasOwn } from '../../utils/index.js'
3
3
  import { computed, inject, onMounted, reactive, ref, useAttrs, watch } from 'vue'
4
4
 
5
5
  const attrs = useAttrs()
@@ -198,6 +198,12 @@ function normalTableRowValue(row) {
198
198
  if (config?.dateFormat) {
199
199
  ret[config.metaCode] = formatDate(ret[config.metaCode], config.dateFormat)
200
200
  }
201
+ if (config?.amountFormat) {
202
+ ret[config.metaCode] = formatAmount(ret[config.metaCode], config.amountFormat)
203
+ }
204
+ if (typeof config?.formatter === "function") {
205
+ ret[config.metaCode] = config.formatter(ret[config.metaCode], config)
206
+ }
201
207
  })
202
208
  return ret
203
209
  }
@@ -27,7 +27,9 @@ const datePickerProps = computed(() => {
27
27
  if (!ret['value-format'] && !ret.valueFormat) {
28
28
  ret.valueFormat = 'YYYY-MM-DD'
29
29
  }
30
-
30
+ if (props?.config?.displayType) {
31
+ ret.type = props?.config?.displayType
32
+ }
31
33
  return ret
32
34
  })
33
35
  const attrs = useAttrs()
@@ -27,7 +27,9 @@
27
27
  --prmary-marign-second: 12px;
28
28
  --prmary-marign: 16px
29
29
  }
30
-
30
+ .poppper-class {
31
+ max-width: calc(100vw - 20px)
32
+ }
31
33
  @import './card.scss';
32
34
  @import './collapse.scss';
33
35
  @import './date.scss';
@@ -143,6 +143,28 @@ export function formatDate(date, fmt) {
143
143
  return fmt
144
144
  }
145
145
 
146
+ export const formatAmount = (val, data) => {
147
+ if (!data) {
148
+ return val
149
+ }
150
+ if (typeof val !== "string" && typeof val !== "number") {
151
+ return val
152
+ }
153
+ let params = isPlainObject(data) ? data : { decimals: 2, isThousandth: true }
154
+ let str = String(val).replace(/[^\d\.\-]/g, "")
155
+ if (params?.decimals || params?.decimals == 0) {
156
+ str = parseFloat(str).toFixed(params.decimals).toString()
157
+ }
158
+ let reg = /(\d)(?=(?:\d{3})+$)/g
159
+ let arr = str.split(".")
160
+ if (params?.isThousandth) {
161
+ if (arr[0]) {
162
+ arr[0] = arr[0].replace(reg, "$1,")
163
+ }
164
+ }
165
+ return arr.join(".")
166
+ }
167
+
146
168
  function padLeftZero(str) {
147
169
  return (`00${str}`).substr(str.length)
148
170
  }
@@ -834,7 +834,7 @@ function createFormLable(config, lang = 'zh') {
834
834
  </span>
835
835
  {
836
836
  config.hintFlag == '1' ? (
837
- <ElTooltip effect="dark" content={lang.indexOf('zh') > -1 ? config.hintContentZh : config.hintContentEn} placement="top">
837
+ <ElTooltip popper-class="poppper-class" effect="dark" content={lang.indexOf('zh') > -1 ? config.hintContentZh : config.hintContentEn} placement="top">
838
838
  <span class="label-tip"><elIcon><QuestionFilled /></elIcon></span>
839
839
  </ElTooltip>
840
840
  ) : null