Skip to content

Commit

Permalink
releases 4.3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 6, 2024
1 parent 4e6a516 commit 0bc8083
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-pc-ui",
"version": "4.3.16",
"version": "4.3.18",
"description": "A vue based PC component library",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -63,7 +63,7 @@
"vue": "3.5.5",
"vue-i18n": "^9.13.1",
"vue-router": "^4.3.2",
"vxe-table": "^4.9.13"
"vxe-table": "^4.9.16"
},
"vetur": {
"tags": "helper/vetur/tags.json",
Expand Down
21 changes: 14 additions & 7 deletions packages/input/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { toStringTimeDate, getDateQuarter } from '../../date-picker/src/util'
import { handleNumber, toFloatValueFixed } from '../../number-input/src/util'
import { getSlotVNs } from '../..//ui/src/vn'

import type { VxeInputConstructor, VxeInputEmits, InputReactData, InputMethods, ValueOf, InputInternalData, VxeInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeDrawerConstructor, VxeDrawerMethods, VxeModalConstructor, VxeModalMethods, VxeDatePickerDefines } from '../../../types'
import type { VxeInputConstructor, VxeInputEmits, InputReactData, InputMethods, ValueOf, InputInternalData, VxeInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeDrawerConstructor, VxeDrawerMethods, VxeModalConstructor, VxeModalMethods, VxeDatePickerDefines, VxeSelectConstructor, VxeSelectMethods, VxeTreeSelectConstructor, VxeTreeSelectMethods } from '../../../types'

export default defineComponent({
name: 'VxeInput',
Expand Down Expand Up @@ -155,6 +155,9 @@ export default defineComponent({
setup (props, context) {
const { slots, emit } = context

const $xeSelect = inject<(VxeSelectConstructor & VxeSelectMethods) | null>('$xeSelect', null)
const $xeTreeSelect = inject<(VxeTreeSelectConstructor & VxeTreeSelectMethods) | null>('$xeTreeSelect', null)

const $xeModal = inject<(VxeModalConstructor & VxeModalMethods) | null>('$xeModal', null)
const $xeDrawer = inject<(VxeDrawerConstructor & VxeDrawerMethods) | null>('$xeDrawer', null)
const $xeTable = inject<(VxeTableConstructor & VxeTablePrivateMethods) | null>('$xeTable', null)
Expand Down Expand Up @@ -788,9 +791,11 @@ export default defineComponent({
inputMethods.dispatchEvent('input', { value }, evnt as any)
if (XEUtils.toValueString(props.modelValue) !== value) {
inputMethods.dispatchEvent('change', { value }, evnt as any)
// 自动更新校验状态
if ($xeForm && formItemInfo) {
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
if (!$xeSelect && !$xeTreeSelect) {
// 自动更新校验状态
if ($xeForm && formItemInfo) {
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
}
}
}
}
Expand Down Expand Up @@ -833,9 +838,11 @@ export default defineComponent({
reactData.isActivated = false
}
inputMethods.dispatchEvent('blur', { value }, evnt)
// 自动更新校验状态
if ($xeForm && formItemInfo) {
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
if (!$xeSelect && !$xeTreeSelect) {
// 自动更新校验状态
if ($xeForm && formItemInfo) {
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
}
}
}

Expand Down
31 changes: 26 additions & 5 deletions packages/number-input/src/number-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,19 @@ export default defineComponent({
return false
})

const handleNumberString = (val: any) => {
if (XEUtils.eqNull(val)) {
return ''
}
return `${val}`
}

const getNumberValue = (val: any) => {
const { type, exponential } = props
const inpMaxLength = computeInpMaxLength.value
const digitsValue = computeDigitsValue.value
const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val))
if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : handleNumberString(val))
if (exponential && (val === restVal || handleNumberString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
return val
}
return restVal.slice(0, inpMaxLength)
Expand All @@ -262,9 +269,13 @@ export default defineComponent({
const value = (val as any) === '' || XEUtils.eqNull(val) ? null : Number(val)
const isChange = Number(value) !== props.modelValue
if (isChange) {
reactData.inputValue = inputValue || ''
emit('update:modelValue', value)
}
if (reactData.inputValue !== inputValue) {
nextTick(() => {
reactData.inputValue = inputValue || ''
})
}
numberInputMethods.dispatchEvent('input', { value }, evnt as Event)
if (isChange) {
numberInputMethods.dispatchEvent('change', { value }, evnt as Event)
Expand Down Expand Up @@ -361,6 +372,16 @@ export default defineComponent({
const { inputValue } = reactData
const inputReadonly = computeInputReadonly.value
if (!inputReadonly) {
if (inputValue === '') {
let inpNumVal = null
let inpValue = inputValue
if (min || min === 0) {
inpNumVal = XEUtils.toNumber(min)
inpValue = `${inpNumVal}`
}
handleChange(inpNumVal, inpValue, { type: 'check' })
return
}
if (inputValue || (min || max)) {
let inpNumVal: number | string = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
if (!validMinNum(inpNumVal)) {
Expand All @@ -369,7 +390,7 @@ export default defineComponent({
inpNumVal = max
}
if (exponential) {
const inpStringVal = XEUtils.toValueString(inputValue).toLowerCase()
const inpStringVal = handleNumberString(inputValue).toLowerCase()
if (inpStringVal === XEUtils.toNumber(inpNumVal).toExponential()) {
inpNumVal = inpStringVal
}
Expand All @@ -385,7 +406,7 @@ export default defineComponent({
const inpImmediate = computeInpImmediate.value
const value = inputValue ? Number(inputValue) : null
if (!inpImmediate) {
handleChange(value, `${inputValue || ''}`, evnt)
handleChange(value, handleNumberString(inputValue), evnt)
}
afterCheckValue()
reactData.isActivated = false
Expand Down
8 changes: 6 additions & 2 deletions types/components/table.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ export namespace VxeTablePropTypes {
* 自定义列配置项
*/
export interface CustomConfig<D = VxeTablePropTypes.Row> {
/**
* 是否启用,支持局部/全局启用
*/
enabled?: boolean
/**
* 是否启用 localStorage 本地保存,会将列操作状态保留在本地(需要有 id)
*/
Expand Down Expand Up @@ -1674,7 +1678,7 @@ export namespace VxeTablePropTypes {
*/
oSize?: number
/**
* 是否启用
* 是否启用,支持局部/全局启用
*/
enabled?: boolean
/**
Expand Down Expand Up @@ -1711,7 +1715,7 @@ export namespace VxeTablePropTypes {
*/
oSize?: number
/**
* 是否启用纵向虚拟滚动
* 是否启用,支持局部/全局启用
*/
enabled?: boolean
/**
Expand Down

0 comments on commit 0bc8083

Please sign in to comment.