imeik-bizui 2.7.2 → 2.7.3

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.
@@ -242,10 +242,10 @@ export default {
242
242
  type: Boolean,
243
243
  default: false
244
244
  },
245
- /** 价格/金额小数位,默认两位 */
245
+ /** 价格/金额小数位;默认 null 不强制,跟随接口原值 */
246
246
  numberDigits: {
247
247
  type: Number,
248
- default: 2
248
+ default: null
249
249
  },
250
250
  maxColumns: {
251
251
  type: Number,
@@ -309,7 +309,7 @@ export default {
309
309
  },
310
310
  applyTotalFeeText() {
311
311
  if (this.applyTotalFee == null || this.applyTotalFee === '') return ''
312
- return `${formatNumber(this.applyTotalFee, { digits: this.numberDigits })} 元`
312
+ return `${formatNumber(this.applyTotalFee)} 元`
313
313
  },
314
314
  yearText() {
315
315
  if (this.year == null || this.year === '') return ''
@@ -397,9 +397,9 @@ export default {
397
397
  },
398
398
  formatCell(value, col = {}) {
399
399
  if (col.type === 'number' || col.type === 'highlight' || col.digits != null) {
400
- // 价格/金额统一两位小数;数量列勿标 type:number,或显式 digits:null
400
+ // 金额按接口原样展示(不千分位、不截断小数)
401
401
  return formatNumber(value, {
402
- digits: col.digits != null ? col.digits : 2,
402
+ digits: col.digits != null ? col.digits : null,
403
403
  fallback: '-'
404
404
  })
405
405
  }
@@ -408,7 +408,7 @@ export default {
408
408
  },
409
409
  formatGapCell(value, col = {}) {
410
410
  return formatSignedNumber(value, {
411
- digits: col.digits != null ? col.digits : 2,
411
+ digits: col.digits != null ? col.digits : null,
412
412
  fallback: '-'
413
413
  })
414
414
  },
@@ -149,7 +149,7 @@ function buildSections(data = {}) {
149
149
  footer: {
150
150
  label: '合计(含本次)',
151
151
  theme: 'purple',
152
- values: [`金额 ${formatNumber(sumBy(saleRows, 'amount'), { digits: 2 })}`]
152
+ values: [`金额 ${formatNumber(sumBy(saleRows, 'amount'))}`]
153
153
  }
154
154
  })
155
155
  }
@@ -171,7 +171,7 @@ function buildSections(data = {}) {
171
171
  theme: 'danger',
172
172
  values: [
173
173
  `数量 ${formatNumber(sumBy(nonSaleRows, 'qty'))}`,
174
- `折算费用 ${formatNumber(sumBy(nonSaleRows, 'amount'), { digits: 2 })}`
174
+ `折算费用 ${formatNumber(sumBy(nonSaleRows, 'amount'))}`
175
175
  ]
176
176
  }
177
177
  })
@@ -191,7 +191,7 @@ function buildSections(data = {}) {
191
191
  footer: {
192
192
  label: '合计(含本次)',
193
193
  theme: 'danger',
194
- values: [formatNumber(sumBy(expenseRows, 'costAmount'), { digits: 2 })]
194
+ values: [formatNumber(sumBy(expenseRows, 'costAmount'))]
195
195
  }
196
196
  })
197
197
  }
@@ -2,40 +2,55 @@
2
2
  * 底价看板 / 明细弹窗 · 纯展示工具(格式化、默认文案、前端差距推导)
3
3
  */
4
4
 
5
- /** 千分位金额/数量;无效值返回 fallback */
5
+ /**
6
+ * 数值展示:默认按接口原样(不千分位、不截断小数位)。
7
+ * 仅当显式传入 digits 时才按固定小数位输出。
8
+ * 注意:toLocaleString 默认最多 3 位小数,会导致四位金额被截断,故原样路径不用它。
9
+ */
6
10
  export function formatNumber(value, { digits = null, fallback = '-' } = {}) {
7
11
  if (value === undefined || value === null || value === '') return fallback
8
- const n = Number(value)
9
- if (Number.isNaN(n)) return String(value)
12
+
10
13
  if (digits === null || digits === undefined) {
11
- return n.toLocaleString('zh-CN')
14
+ if (typeof value === 'string') {
15
+ const s = value.trim()
16
+ if (s === '') return fallback
17
+ if (Number.isNaN(Number(s))) return fallback
18
+ return s
19
+ }
20
+ const n = Number(value)
21
+ if (Number.isNaN(n)) return String(value)
22
+ return String(n)
12
23
  }
13
- return n.toLocaleString('zh-CN', {
14
- minimumFractionDigits: digits,
15
- maximumFractionDigits: digits
16
- })
24
+
25
+ const n = Number(value)
26
+ if (Number.isNaN(n)) return String(value)
27
+ return n.toFixed(digits)
17
28
  }
18
29
 
19
- /** 金额带 ¥,如 ¥ 800.00;价格/金额默认保留两位小数 */
20
- export function formatMoney(value, { digits = 2, fallback = '-' } = {}) {
30
+ /** 金额带 ¥;默认跟随接口原值,如 ¥ 2401.4385 */
31
+ export function formatMoney(value, { digits = null, fallback = '-' } = {}) {
21
32
  const body = formatNumber(value, { digits, fallback: null })
22
33
  if (body == null) return fallback
23
34
  return `¥ ${body}`
24
35
  }
25
36
 
26
- /** 带正负号的差距展示,如 -23.68 / +3.10;金额默认两位小数 */
27
- export function formatSignedNumber(value, { digits = 2, fallback = '-' } = {}) {
37
+ /** 绝对值的原样展示(去掉正负号) */
38
+ function rawAbsBody(value, n) {
39
+ if (typeof value === 'string') {
40
+ return value.trim().replace(/^[+-]/, '')
41
+ }
42
+ return String(Math.abs(n))
43
+ }
44
+
45
+ /** 带正负号的差距展示;默认跟随原精度,如 +23.6800 / -3.1 */
46
+ export function formatSignedNumber(value, { digits = null, fallback = '-' } = {}) {
28
47
  if (value === undefined || value === null || value === '') return fallback
29
48
  const n = Number(value)
30
49
  if (Number.isNaN(n)) return String(value)
31
- const abs = Math.abs(n)
32
50
  const body =
33
51
  digits === null || digits === undefined
34
- ? abs.toLocaleString('zh-CN')
35
- : abs.toLocaleString('zh-CN', {
36
- minimumFractionDigits: digits,
37
- maximumFractionDigits: digits
38
- })
52
+ ? rawAbsBody(value, n)
53
+ : Math.abs(n).toFixed(digits)
39
54
  if (n > 0) return `+${body}`
40
55
  if (n < 0) return `-${body}`
41
56
  return body
@@ -46,9 +61,9 @@ export function formatSignedNumber(value, { digits = 2, fallback = '-' } = {}) {
46
61
  * - gap < 0 → 低于底价 / 禁止;文案「低 N 元/支」
47
62
  * - gap > 0 → 通过;文案「高 N 元/支」
48
63
  * - gap = 0 → 持平
49
- * digits 默认 2,与看板/明细金额展示一致
64
+ * 展示不截断小数位(不用 toLocaleString)
50
65
  */
51
- export function computePriceGap(afterPrice, standard, { digits = 2 } = {}) {
66
+ export function computePriceGap(afterPrice, standard, { digits = null } = {}) {
52
67
  const after = Number(afterPrice)
53
68
  const std = Number(standard)
54
69
  if (
@@ -68,11 +83,8 @@ export function computePriceGap(afterPrice, standard, { digits = 2 } = {}) {
68
83
  const abs = Math.abs(gap)
69
84
  const body =
70
85
  digits === null || digits === undefined
71
- ? abs.toLocaleString('zh-CN')
72
- : abs.toLocaleString('zh-CN', {
73
- minimumFractionDigits: digits,
74
- maximumFractionDigits: digits
75
- })
86
+ ? String(abs)
87
+ : abs.toFixed(digits)
76
88
  let gapLabel = '持平'
77
89
  if (gap < 0) gapLabel = `低 ${body} 元/支`
78
90
  else if (gap > 0) gapLabel = `高 ${body} 元/支`