Skip to content

Commit a1e9530

Browse files
author
xuqingkai
committed
fix: 🐛 修复DateTimePicker区域选择极值计算错误的问题
1 parent ed5d7ac commit a1e9530

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

src/uni_modules/wot-design-uni/components/wd-datetime-picker-view/wd-datetime-picker-view.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626

2727
<script lang="ts" setup>
2828
import { getCurrentInstance, onBeforeMount, ref, watch } from 'vue'
29-
import { debounce, getType, isDef, padZero, range } from '../common/util'
29+
import { debounce, isFunction, isDef, padZero, range } from '../common/util'
3030
import {
3131
getPickerValue,
3232
datetimePickerViewProps,
@@ -78,6 +78,15 @@ const created = ref<boolean>(false)
7878
7979
const { proxy } = getCurrentInstance() as any
8080
81+
defineExpose<DatetimePickerViewExpose>({
82+
updateColumns,
83+
setColumns,
84+
getSelects,
85+
correctValue,
86+
getPickerValue,
87+
getOriginColumns,
88+
...props
89+
})
8190
/**
8291
* @description updateValue 防抖函数的占位符
8392
*/
@@ -120,7 +129,7 @@ watch(
120129
watch(
121130
() => props.filter,
122131
(fn) => {
123-
if (fn && getType(fn) !== 'function') {
132+
if (fn && !isFunction(fn)) {
124133
console.error('The type of filter must be Function')
125134
}
126135
updateValue()
@@ -131,7 +140,7 @@ watch(
131140
watch(
132141
() => props.formatter,
133142
(fn) => {
134-
if (fn && getType(fn) !== 'function') {
143+
if (fn && !isFunction(fn)) {
135144
console.error('The type of formatter must be Function')
136145
}
137146
updateValue()
@@ -142,7 +151,7 @@ watch(
142151
watch(
143152
() => props.columnFormatter,
144153
(fn) => {
145-
if (fn && getType(fn) !== 'function') {
154+
if (fn && !isFunction(fn)) {
146155
console.error('The type of columnFormatter must be Function')
147156
}
148157
updateValue()
@@ -488,15 +497,6 @@ function onPickEnd() {
488497
function getSelects() {
489498
return datePickerview.value && datePickerview.value.getSelects ? datePickerview.value.getSelects() : undefined
490499
}
491-
492-
defineExpose<DatetimePickerViewExpose>({
493-
updateColumns,
494-
setColumns,
495-
getSelects,
496-
correctValue,
497-
getPickerValue,
498-
getOriginColumns
499-
})
500500
</script>
501501

502502
<style lang="scss" scoped>

src/uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
:label-key="labelKey"
9494
:formatter="formatter"
9595
:filter="filter"
96-
:column-formatter="getType(modelValue) === 'array' ? customColumnFormatter : undefined"
96+
:column-formatter="isArray(modelValue) ? customColumnFormatter : undefined"
9797
:max-hour="maxHour"
9898
:min-hour="minHour"
9999
:max-date="maxDate"
@@ -119,7 +119,7 @@
119119
:label-key="labelKey"
120120
:formatter="formatter"
121121
:filter="filter"
122-
:column-formatter="getType(modelValue) === 'array' ? customColumnFormatter : undefined"
122+
:column-formatter="isArray(modelValue) ? customColumnFormatter : undefined"
123123
:max-hour="maxHour"
124124
:min-hour="minHour"
125125
:max-date="maxDate"
@@ -150,7 +150,7 @@ export default {
150150

151151
<script lang="ts" setup>
152152
import { computed, getCurrentInstance, nextTick, onBeforeMount, onMounted, ref, watch } from 'vue'
153-
import { deepClone, getType, isArray, isDef, isEqual, padZero } from '../common/util'
153+
import { deepClone, isArray, isDef, isEqual, isFunction, padZero } from '../common/util'
154154
import { useCell } from '../composables/useCell'
155155
import {
156156
getPickerValue,
@@ -191,7 +191,7 @@ watch(
191191
(val, oldVal) => {
192192
if (isEqual(val, oldVal)) return
193193
194-
if (getType(val) === 'array') {
194+
if (isArray(val)) {
195195
region.value = true
196196
innerValue.value = deepClone(getDefaultInnerValue(true))
197197
endInnerValue.value = deepClone(getDefaultInnerValue(true, true))
@@ -212,7 +212,7 @@ watch(
212212
watch(
213213
() => props.displayFormat,
214214
(fn) => {
215-
if (fn && getType(fn) !== 'function') {
215+
if (fn && !isFunction(fn)) {
216216
console.error('The type of displayFormat must be Function')
217217
}
218218
},
@@ -224,7 +224,7 @@ watch(
224224
watch(
225225
() => props.filter,
226226
(fn) => {
227-
if (fn && getType(fn) !== 'function') {
227+
if (fn && !isFunction(fn)) {
228228
console.error('The type of filter must be Function')
229229
}
230230
},
@@ -236,7 +236,7 @@ watch(
236236
watch(
237237
() => props.formatter,
238238
(fn) => {
239-
if (fn && getType(fn) !== 'function') {
239+
if (fn && !isFunction(fn)) {
240240
console.error('The type of formatter must be Function')
241241
}
242242
},
@@ -248,7 +248,7 @@ watch(
248248
watch(
249249
() => props.beforeConfirm,
250250
(fn) => {
251-
if (fn && getType(fn) !== 'function') {
251+
if (fn && !isFunction(fn)) {
252252
console.error('The type of beforeConfirm must be Function')
253253
}
254254
},
@@ -260,7 +260,7 @@ watch(
260260
watch(
261261
() => props.displayFormatTabLabel,
262262
(fn) => {
263-
if (fn && getType(fn) !== 'function') {
263+
if (fn && !isFunction(fn)) {
264264
console.error('The type of displayFormatTabLabel must be Function')
265265
}
266266
},
@@ -273,7 +273,7 @@ watch(
273273
watch(
274274
() => props.defaultValue,
275275
(val) => {
276-
if (getType(val) === 'array' || region.value) {
276+
if (isArray(val) || region.value) {
277277
innerValue.value = deepClone(getDefaultInnerValue(true))
278278
endInnerValue.value = deepClone(getDefaultInnerValue(true, true))
279279
} else {
@@ -327,6 +327,7 @@ const customColumnFormatter: DatetimePickerViewColumnFormatter = (picker) => {
327327
// 校准上下方picker的value值,与内部innerValue对应
328328
const start = picker.correctValue(innerValue.value)
329329
const end = picker.correctValue(endInnerValue.value)
330+
330331
/**
331332
* 如果是上方picekr 那么将下方picker的值作为下边界
332333
* 如果是下方picekr 那么将上方picker的值作为上边界
@@ -351,7 +352,7 @@ const customColumnFormatter: DatetimePickerViewColumnFormatter = (picker) => {
351352
352353
onBeforeMount(() => {
353354
const { modelValue: value } = props
354-
if (getType(value) === 'array') {
355+
if (isArray(value)) {
355356
region.value = true
356357
innerValue.value = deepClone(getDefaultInnerValue(true))
357358
endInnerValue.value = deepClone(getDefaultInnerValue(true, true))
@@ -453,7 +454,6 @@ function onChangeStart({ value }: { value: number | string }) {
453454
datetimePickerView.value && datetimePickerView.value.setColumns(datetimePickerView.value.updateColumns())
454455
datetimePickerView1.value && datetimePickerView1.value.setColumns(datetimePickerView1.value.updateColumns())
455456
} else {
456-
// emit('update:modelValue', innerValue.value)
457457
emit('change', {
458458
value: innerValue.value
459459
})
@@ -465,9 +465,7 @@ function onChangeStart({ value }: { value: number | string }) {
465465
*/
466466
function onChangeEnd({ value }: { value: number | string }) {
467467
endInnerValue.value = deepClone(value)
468-
469468
showTabLabel.value = [deepClone(showTabLabel.value[0]), setTabLabel(1)]
470-
// emit('update:modelValue', [innerValue.value, value])
471469
emit('change', {
472470
value: [innerValue.value, value]
473471
})

src/uni_modules/wot-design-uni/components/wd-select-picker/wd-select-picker.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default {
117117
<script lang="ts" setup>
118118
import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed } from 'vue'
119119
import { useCell } from '../composables/useCell'
120-
import { getRect, getType, isArray, isDef, requestAnimationFrame } from '../common/util'
120+
import { getRect, isArray, isDef, isFunction, requestAnimationFrame } from '../common/util'
121121
import { useParent } from '../composables/useParent'
122122
import { FORM_KEY, type FormItemRule } from '../wd-form/types'
123123
import { useTranslate } from '../composables/useTranslate'
@@ -194,7 +194,7 @@ watch(
194194
watch(
195195
() => props.displayFormat,
196196
(fn) => {
197-
if (fn && getType(fn) !== 'function') {
197+
if (fn && !isFunction(fn)) {
198198
console.error('The type of displayFormat must be Function')
199199
}
200200
},
@@ -207,7 +207,7 @@ watch(
207207
watch(
208208
() => props.beforeConfirm,
209209
(fn) => {
210-
if (fn && getType(fn) !== 'function') {
210+
if (fn && !isFunction(fn)) {
211211
console.error('The type of beforeConfirm must be Function')
212212
}
213213
},

0 commit comments

Comments
 (0)