vxe-pc-ui 4.14.37 → 4.14.39

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.
Files changed (36) hide show
  1. package/dist/all.esm.js +45 -18
  2. package/es/input/src/input.js +2 -2
  3. package/es/number-input/src/number-input.js +25 -10
  4. package/es/number-input/src/util.js +16 -4
  5. package/es/ui/index.js +1 -1
  6. package/es/ui/src/log.js +1 -1
  7. package/lib/index.umd.js +45 -17
  8. package/lib/index.umd.min.js +1 -1
  9. package/lib/input/src/input.js +2 -2
  10. package/lib/input/src/input.min.js +1 -1
  11. package/lib/number-input/src/number-input.js +24 -7
  12. package/lib/number-input/src/number-input.min.js +1 -1
  13. package/lib/number-input/src/util.js +15 -4
  14. package/lib/number-input/src/util.min.js +1 -1
  15. package/lib/ui/index.js +1 -1
  16. package/lib/ui/index.min.js +1 -1
  17. package/lib/ui/src/log.js +1 -1
  18. package/lib/ui/src/log.min.js +1 -1
  19. package/package.json +2 -2
  20. package/packages/input/src/input.ts +2 -2
  21. package/packages/number-input/src/number-input.ts +24 -11
  22. package/packages/number-input/src/util.ts +17 -4
  23. package/types/components/number-input.d.ts +12 -1
  24. package/types/components/table.d.ts +33 -124
  25. /package/es/icon/{iconfont.1781322556500.ttf → iconfont.1781503194392.ttf} +0 -0
  26. /package/es/icon/{iconfont.1781322556500.woff → iconfont.1781503194392.woff} +0 -0
  27. /package/es/icon/{iconfont.1781322556500.woff2 → iconfont.1781503194392.woff2} +0 -0
  28. /package/es/{iconfont.1781322556500.ttf → iconfont.1781503194392.ttf} +0 -0
  29. /package/es/{iconfont.1781322556500.woff → iconfont.1781503194392.woff} +0 -0
  30. /package/es/{iconfont.1781322556500.woff2 → iconfont.1781503194392.woff2} +0 -0
  31. /package/lib/icon/style/{iconfont.1781322556500.ttf → iconfont.1781503194392.ttf} +0 -0
  32. /package/lib/icon/style/{iconfont.1781322556500.woff → iconfont.1781503194392.woff} +0 -0
  33. /package/lib/icon/style/{iconfont.1781322556500.woff2 → iconfont.1781503194392.woff2} +0 -0
  34. /package/lib/{iconfont.1781322556500.ttf → iconfont.1781503194392.ttf} +0 -0
  35. /package/lib/{iconfont.1781322556500.woff → iconfont.1781503194392.woff} +0 -0
  36. /package/lib/{iconfont.1781322556500.woff2 → iconfont.1781503194392.woff2} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { h, ref, Ref, computed, reactive, inject, nextTick, watch, onMounted, onBeforeUnmount, PropType } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
- import XEUtils from 'xe-utils'
3
+ import XEUtils, { CommafyOptions } from 'xe-utils'
4
4
  import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize, renderEmptyElement } from '../../ui'
5
5
  import { getFuncText, eqEmptyValue, isEnableConf } from '../../ui/src/utils'
6
6
  import { hasClass, getEventTargetNode, hasControlKey } from '../../ui/src/dom'
@@ -75,6 +75,11 @@ export default defineVxeComponent({
75
75
  },
76
76
  controlConfig: Object as PropType<VxeNumberInputPropTypes.ControlConfig>,
77
77
 
78
+ // float
79
+ roundingMode: {
80
+ type: String as PropType<VxeNumberInputPropTypes.RoundingMode>,
81
+ default: null
82
+ },
78
83
  // float
79
84
  digits: {
80
85
  type: [String, Number] as PropType<VxeNumberInputPropTypes.Digits>,
@@ -268,12 +273,20 @@ export default defineVxeComponent({
268
273
  })
269
274
 
270
275
  const computeNumLabel = computed(() => {
271
- const { type, showCurrency, currencySymbol, autoFill } = props
276
+ const { type, roundingMode, showCurrency, currencySymbol, autoFill } = props
272
277
  const { inputValue } = reactData
273
278
  const digitsValue = computeDigitsValue.value
274
279
  if (type === 'amount') {
275
280
  const num = XEUtils.toNumber(inputValue)
276
- let amountLabel = XEUtils.commafy(num, { digits: digitsValue })
281
+ const cfyOpts: CommafyOptions = { digits: digitsValue }
282
+ if (roundingMode === 'floor') {
283
+ cfyOpts.floor = true
284
+ } else if (roundingMode === 'ceil') {
285
+ cfyOpts.ceil = true
286
+ } else {
287
+ cfyOpts.round = true
288
+ }
289
+ let amountLabel = XEUtils.commafy(num, cfyOpts)
277
290
  if (!autoFill) {
278
291
  const [iStr, dStr] = amountLabel.split('.')
279
292
  if (dStr) {
@@ -340,13 +353,13 @@ export default defineVxeComponent({
340
353
  }
341
354
 
342
355
  const getNumberValue = (val: any) => {
343
- const { exponential, autoFill } = props
356
+ const { exponential, roundingMode, autoFill } = props
344
357
  const inpMaxLength = computeInpMaxLength.value
345
358
  const digitsValue = computeDigitsValue.value
346
359
  const decimalsType = computeDecimalsType.value
347
360
  let restVal = ''
348
361
  if (decimalsType) {
349
- restVal = toFloatValueFixed(val, digitsValue)
362
+ restVal = toFloatValueFixed(val, digitsValue, roundingMode)
350
363
  if (!autoFill) {
351
364
  restVal = handleNumberString(XEUtils.toNumber(restVal))
352
365
  }
@@ -446,18 +459,18 @@ export default defineVxeComponent({
446
459
  }
447
460
 
448
461
  const updateModel = (val: any) => {
449
- const { autoFill } = props
462
+ const { roundingMode, autoFill } = props
450
463
  const { inputValue } = reactData
451
464
  const digitsValue = computeDigitsValue.value
452
465
  const decimalsType = computeDecimalsType.value
453
466
  if (eqEmptyValue(val)) {
454
467
  reactData.inputValue = ''
455
468
  } else {
456
- let textValue = `${val}`
469
+ let textValue = '' + val
457
470
  if (decimalsType) {
458
- textValue = toFloatValueFixed(val, digitsValue)
471
+ textValue = toFloatValueFixed(val, digitsValue, roundingMode)
459
472
  if (!autoFill) {
460
- textValue = `${XEUtils.toNumber(textValue)}`
473
+ textValue = '' + XEUtils.toNumber(textValue)
461
474
  }
462
475
  }
463
476
  if (textValue !== inputValue) {
@@ -470,7 +483,7 @@ export default defineVxeComponent({
470
483
  * 检查初始值
471
484
  */
472
485
  const initValue = () => {
473
- const { autoFill } = props
486
+ const { roundingMode, autoFill } = props
474
487
  const { inputValue } = reactData
475
488
  const digitsValue = computeDigitsValue.value
476
489
  const decimalsType = computeDecimalsType.value
@@ -479,7 +492,7 @@ export default defineVxeComponent({
479
492
  let textValue = ''
480
493
  let validValue: number | null = null
481
494
  if (inputValue) {
482
- textValue = toFloatValueFixed(inputValue, digitsValue)
495
+ textValue = toFloatValueFixed(inputValue, digitsValue, roundingMode)
483
496
  validValue = XEUtils.toNumber(textValue)
484
497
  if (!autoFill) {
485
498
  textValue = `${validValue}`
@@ -1,12 +1,25 @@
1
1
  import XEUtils from 'xe-utils'
2
2
 
3
+ import type { VxeNumberInputPropTypes } from '../../../types'
4
+
3
5
  export function handleNumber (val: string | number | null | undefined) {
4
6
  return XEUtils.isString(val) ? val.replace(/[^0-9e.-]/g, '') : val
5
7
  }
6
8
 
7
- export function toFloatValueFixed (inputValue: string | number, digitsValue: number) {
8
- if (/^-/.test('' + inputValue)) {
9
- return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
9
+ export function toFloatValueFixed (inputValue: string | number, digitsValue: number, roundingMode: VxeNumberInputPropTypes.RoundingMode) {
10
+ if (!roundingMode || roundingMode === 'default') {
11
+ // 默认截取忽略
12
+ if (/^-/.test('' + inputValue)) {
13
+ return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
14
+ }
15
+ return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
16
+ } else {
17
+ if (roundingMode === 'ceil') {
18
+ return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
19
+ }
20
+ if (roundingMode === 'floor') {
21
+ return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
22
+ }
23
+ return XEUtils.toFixed(XEUtils.round(inputValue, digitsValue), digitsValue)
10
24
  }
11
- return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
12
25
  }
@@ -68,6 +68,13 @@ export namespace VxeNumberInputPropTypes {
68
68
  */
69
69
  layout?: 'left' | 'right' | 'default' | ''
70
70
  }
71
+ /**
72
+ * 小数位数处理时的舍入方式
73
+ */
74
+ export type RoundingMode = 'round' | 'ceil' | 'floor' | 'default' | '' | null
75
+ /**
76
+ * 保留小数位数
77
+ */
71
78
  export type Digits = string | number | null
72
79
  export type AutoFill = boolean
73
80
  export type Editable = boolean
@@ -146,7 +153,11 @@ export interface VxeNumberInputProps {
146
153
  controlConfig?: VxeNumberInputPropTypes.ControlConfig
147
154
 
148
155
  /**
149
- * 小数位数
156
+ * 小数位数处理时的舍入方式
157
+ */
158
+ roundingMode?: VxeNumberInputPropTypes.RoundingMode
159
+ /**
160
+ * 保留小数位数
150
161
  */
151
162
  digits?: VxeNumberInputPropTypes.Digits
152
163
  /**
@@ -2968,13 +2968,7 @@ export namespace VxeTablePropTypes {
2968
2968
  field?: string
2969
2969
  }
2970
2970
 
2971
- /**
2972
- * 导出参数
2973
- */
2974
- export interface ExportConfig {
2975
- // 内置属性
2976
- _typeMaps?: Record<string, number>
2977
-
2971
+ interface ExportAndPrintConfig {
2978
2972
  /**
2979
2973
  * 文件名
2980
2974
  */
@@ -2993,14 +2987,6 @@ export namespace VxeTablePropTypes {
2993
2987
  $gantt: VxeGanttConstructor | null | undefined
2994
2988
  options: ExportOpts
2995
2989
  }) => string)
2996
- /**
2997
- * 文件类型
2998
- */
2999
- type?: string
3000
- /**
3001
- * 可选文件类型列表
3002
- */
3003
- types?: string[]
3004
2990
  /**
3005
2991
  * 导出数据的方式
3006
2992
  */
@@ -3092,6 +3078,37 @@ export namespace VxeTablePropTypes {
3092
3078
  items: any[]
3093
3079
  $rowIndex: number
3094
3080
  }): boolean
3081
+ /**
3082
+ * 自定义参数
3083
+ */
3084
+ params?: Record<string, any>
3085
+
3086
+ /**
3087
+ * 自定义高级导出窗口的插槽模板
3088
+ */
3089
+ slots?: {
3090
+ top?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3091
+ bottom?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3092
+ default?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3093
+ footer?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3094
+ parameter?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3095
+ }
3096
+ }
3097
+
3098
+ /**
3099
+ * 导出参数
3100
+ */
3101
+ export interface ExportConfig extends ExportAndPrintConfig {
3102
+ // 内置属性
3103
+ _typeMaps?: Record<string, number>
3104
+ /**
3105
+ * 文件类型
3106
+ */
3107
+ type?: string
3108
+ /**
3109
+ * 可选文件类型列表
3110
+ */
3111
+ types?: string[]
3095
3112
  /**
3096
3113
  * 是否服务端导出
3097
3114
  */
@@ -3101,10 +3118,6 @@ export namespace VxeTablePropTypes {
3101
3118
  */
3102
3119
  useStyle?: boolean
3103
3120
  sheetMethod?(params: VxeTableDefines.ExtortSheetMethodParams): void
3104
- /**
3105
- * 自定义参数
3106
- */
3107
- params?: Record<string, any>
3108
3121
  /**
3109
3122
  * 只对 remote=true 有效,用于自定义导出逻辑
3110
3123
  */
@@ -3127,17 +3140,6 @@ export namespace VxeTablePropTypes {
3127
3140
  status: boolean
3128
3141
  options: ExportHandleOptions
3129
3142
  }): void
3130
-
3131
- /**
3132
- * 自定义高级导出窗口的插槽模板
3133
- */
3134
- slots?: {
3135
- top?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3136
- bottom?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3137
- default?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3138
- footer?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3139
- parameter?: string | ((params: VxeTableDefines.ExtortSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3140
- }
3141
3143
  }
3142
3144
  export interface ExportOpts extends ExportConfig { }
3143
3145
  export interface ExportHandleOptions extends Exclude<ExportConfig, 'filename' | 'sheetName'> {
@@ -3163,47 +3165,7 @@ export namespace VxeTablePropTypes {
3163
3165
  /**
3164
3166
  * 打印参数
3165
3167
  */
3166
- export interface PrintConfig {
3167
- /**
3168
- * 表名
3169
- */
3170
- sheetName?: string | ((params: {
3171
- $table: VxeTableConstructor
3172
- $grid: VxeGridConstructor | null | undefined
3173
- $gantt: VxeGanttConstructor | null | undefined
3174
- options: ExportOpts
3175
- }) => string)
3176
- /**
3177
- * 导出数据的方式
3178
- */
3179
- mode?: string
3180
- /**
3181
- * 导出数据的方式列表
3182
- */
3183
- modes?: (string | {
3184
- label?: string | number
3185
- value: string | number
3186
- })[]
3187
- /**
3188
- * 是否为源数据
3189
- */
3190
- original?: boolean
3191
- /**
3192
- * 是否需要表头
3193
- */
3194
- isHeader?: boolean
3195
- /**
3196
- * 是否需要表尾
3197
- */
3198
- isFooter?: boolean
3199
- /**
3200
- * 自定义数据
3201
- */
3202
- data?: any[]
3203
- /**
3204
- * 自定义列
3205
- */
3206
- columns?: VxeTableDefines.ColumnInfo[] | ExportOrPrintColumnOption[]
3168
+ export interface PrintConfig extends ExportAndPrintConfig {
3207
3169
  /**
3208
3170
  * 打印样式
3209
3171
  */
@@ -3212,48 +3174,6 @@ export namespace VxeTablePropTypes {
3212
3174
  * 自定义打印内容
3213
3175
  */
3214
3176
  html?: string
3215
- /**
3216
- * 自定义参数
3217
- */
3218
- params?: Record<string, any>
3219
- /**
3220
- * 指定列
3221
- */
3222
- includeFields?: string[]
3223
- /**
3224
- * 排除列
3225
- */
3226
- excludeFields?: string[]
3227
- /**
3228
- * 列过滤方法
3229
- */
3230
- columnFilterMethod?(params: {
3231
- $table: VxeTableConstructor
3232
- $grid: VxeGridConstructor | null | undefined
3233
- $gantt: VxeGanttConstructor | null | undefined
3234
- column: VxeTableDefines.ColumnInfo
3235
- $columnIndex: number
3236
- }): boolean
3237
- /**
3238
- * 数据过滤方法
3239
- */
3240
- dataFilterMethod?(params: {
3241
- $table: VxeTableConstructor
3242
- $grid: VxeGridConstructor | null | undefined
3243
- $gantt: VxeGanttConstructor | null | undefined
3244
- row: any
3245
- $rowIndex: number
3246
- }): boolean
3247
- /**
3248
- * 表尾过滤方法
3249
- */
3250
- footerFilterMethod?(params: {
3251
- $table: VxeTableConstructor
3252
- $grid: VxeGridConstructor | null | undefined
3253
- $gantt: VxeGanttConstructor | null | undefined
3254
- items: any[]
3255
- $rowIndex: number
3256
- }): boolean
3257
3177
  /**
3258
3178
  * 打印之前的方法,可以通过返回自定义打印的内容
3259
3179
  */
@@ -3271,17 +3191,6 @@ export namespace VxeTablePropTypes {
3271
3191
  content: string
3272
3192
  }): string
3273
3193
 
3274
- /**
3275
- * 自定义高级导出窗口的插槽模板
3276
- */
3277
- slots?: {
3278
- top?: string | ((params: VxeTableDefines.PrintSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3279
- bottom?: string | ((params: VxeTableDefines.PrintSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3280
- default?: string | ((params: VxeTableDefines.PrintSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3281
- footer?: string | ((params: VxeTableDefines.PrintSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3282
- parameter?: string | ((params: VxeTableDefines.PrintSlotParams) => VxeComponentSlotType | VxeComponentSlotType[])
3283
- }
3284
-
3285
3194
  /**
3286
3195
  * 已被 html 替换
3287
3196
  * @deprecated