resolver-egretimp-plus 0.0.156 → 0.0.158

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.158",
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()
@@ -9,6 +9,10 @@ const props = defineProps({
9
9
  formatter: {
10
10
  type: Function,
11
11
  default: null
12
+ },
13
+ titleFormatter: {
14
+ type: Function,
15
+ default: null
12
16
  }
13
17
  })
14
18
 
@@ -24,8 +28,13 @@ const dateFormat = computed(() => {
24
28
  return props.config?.dateFormat
25
29
  })
26
30
 
31
+ const amountFormat = computed(() => {
32
+ return props.config?.amountFormat
33
+ })
34
+
27
35
  const calcProps = computed(() => {
28
36
  let desc = normalVal.value || props.config?.desc
37
+ let title = lang?.value?.indexOf('zh') > -1 ? props.config?.metaNameZh : props.config?.metaNameEn
29
38
  try {
30
39
  if (desc?.toString) {
31
40
  desc = desc.toString()
@@ -33,14 +42,20 @@ const calcProps = computed(() => {
33
42
  if (dateFormat.value) {
34
43
  desc = formatDate(desc, dateFormat.value)
35
44
  }
45
+ if (amountFormat.value) {
46
+ desc = formatAmount(desc, amountFormat.value)
47
+ }
36
48
  if (props.formatter && typeof props.formatter === "function") {
37
- desc = props.formatter(desc)
49
+ desc = props.formatter(desc, props.config, props)
50
+ }
51
+ if (props.titleFormatter && typeof props.titleFormatter === "function") {
52
+ title = props.titleFormatter(title, props.config, props)
38
53
  }
39
54
  } catch (error) {
40
55
  console.log('CmiCell, error==:', error)
41
56
  }
42
57
  return {
43
- title: lang?.value?.indexOf('zh') > -1 ? props.config?.metaNameZh : props.config?.metaNameEn,
58
+ title,
44
59
  desc,
45
60
  content: props.config?.content,
46
61
  to: props.config?.toHref,
@@ -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()
@@ -129,8 +129,12 @@ const pmPageMetaList = computed(() => {
129
129
  })
130
130
 
131
131
  const getTableColumnProps = (config) => {
132
+ let label = lang?.value?.indexOf('zh') > -1 ? config.metaNameZh : config.metaNameEn
133
+ if (typeof config.titleFormatter === "function") {
134
+ label = config.titleFormatter(label, config, props)
135
+ }
132
136
  return {
133
- label: lang?.value?.indexOf('zh') > -1 ? config.metaNameZh : config.metaNameEn,
137
+ label,
134
138
  prop: config.metaCode,
135
139
  width: config.columnWidth,
136
140
  ellipsis: config.ellipsis === '1',
@@ -198,6 +202,12 @@ function normalTableRowValue(row) {
198
202
  if (config?.dateFormat) {
199
203
  ret[config.metaCode] = formatDate(ret[config.metaCode], config.dateFormat)
200
204
  }
205
+ if (config?.amountFormat) {
206
+ ret[config.metaCode] = formatAmount(ret[config.metaCode], config.amountFormat)
207
+ }
208
+ if (typeof config?.formatter === "function") {
209
+ ret[config.metaCode] = config.formatter(ret[config.metaCode], config, props)
210
+ }
201
211
  })
202
212
  return ret
203
213
  }
@@ -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