sadais-piui 1.2.7-beta178 → 1.2.7-beta179
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.
|
@@ -249,13 +249,16 @@ export default {
|
|
|
249
249
|
}
|
|
250
250
|
return {
|
|
251
251
|
date,
|
|
252
|
-
|
|
252
|
+
scrollingCount: 0 // picker滚动中的列数,用计数器替代boolean,支持多列并发滚动
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
255
|
computed: {
|
|
256
256
|
getPopupSelect() {
|
|
257
257
|
return this.$pi.lang.mergeDeep(datePicker.popupSelect, this.popupSelect)
|
|
258
258
|
},
|
|
259
|
+
scrolling() {
|
|
260
|
+
return this.scrollingCount > 0
|
|
261
|
+
},
|
|
259
262
|
getConfirmBtn() {
|
|
260
263
|
const datePickerConfirmBtn = this.$pi.lang.mergeDeep(
|
|
261
264
|
datePicker.confirmBtn,
|
|
@@ -522,7 +525,8 @@ export default {
|
|
|
522
525
|
} else {
|
|
523
526
|
const intValue = parseInt(value, 10)
|
|
524
527
|
const val = col.items.findIndex(m => m === intValue)
|
|
525
|
-
|
|
528
|
+
// findIndex 返回 -1 说明当前值不在选项中(如月份变更后日期越界),回退到最后一个有效值
|
|
529
|
+
pickerValue.push(val === -1 ? col.items.length - 1 : val)
|
|
526
530
|
}
|
|
527
531
|
}
|
|
528
532
|
})
|
|
@@ -556,11 +560,11 @@ export default {
|
|
|
556
560
|
})
|
|
557
561
|
},
|
|
558
562
|
handlePickstart() {
|
|
559
|
-
this.
|
|
563
|
+
this.scrollingCount++
|
|
560
564
|
},
|
|
561
565
|
// 标识滑动结束
|
|
562
566
|
handlePickend() {
|
|
563
|
-
this.
|
|
567
|
+
this.scrollingCount = Math.max(0, this.scrollingCount - 1)
|
|
564
568
|
},
|
|
565
569
|
handlePopupClose() {
|
|
566
570
|
this.val = false
|
|
@@ -570,7 +574,8 @@ export default {
|
|
|
570
574
|
},
|
|
571
575
|
handleDateChange(e) {
|
|
572
576
|
const values = e.detail.value // values 返回的数组固定是picker的数量,只返回有变化的索引值
|
|
573
|
-
|
|
577
|
+
// 克隆 Date 对象,避免直接修改原引用导致 parsedMaxDate/parsedMinDate 被污染
|
|
578
|
+
const time = new Date(this.date.time.getTime())
|
|
574
579
|
|
|
575
580
|
// 仅当年/月变化时才需要防溢出处理:预扫描收集意图年月
|
|
576
581
|
let intendedYear = time.getFullYear()
|
|
@@ -597,7 +602,10 @@ export default {
|
|
|
597
602
|
if (value !== null && value !== -1) {
|
|
598
603
|
// value为picker列的索引值
|
|
599
604
|
const col = this.columns[index]
|
|
600
|
-
|
|
605
|
+
if (!col || !col.items || col.items.length === 0) return
|
|
606
|
+
// 并发滚动时,月份变更会导致日期列选项重渲染,事件中的 index 可能越界
|
|
607
|
+
const safeIndex = Math.max(0, Math.min(value, col.items.length - 1))
|
|
608
|
+
let val = col.items[safeIndex] // 取出对应picker值
|
|
601
609
|
if (col.field === 'month') val--
|
|
602
610
|
if (col.field === 'halfday') val = value === 0 ? 0 : 12
|
|
603
611
|
if (col.field === 'day' && yearMonthChanged) val = Math.min(val, daysInIntendedMonth)
|
|
@@ -619,12 +627,12 @@ export default {
|
|
|
619
627
|
let needUpdate = false
|
|
620
628
|
// 校正最小日期
|
|
621
629
|
if (this.parsedMinDate && time < this.parsedMinDate.time) {
|
|
622
|
-
this.date = this.$pi.date.parseDate(this.parsedMinDate.time)
|
|
630
|
+
this.date = this.$pi.date.parseDate(new Date(this.parsedMinDate.time.getTime()))
|
|
623
631
|
needUpdate = true
|
|
624
632
|
}
|
|
625
633
|
// 校正最大日期
|
|
626
634
|
if (this.parsedMaxDate && time > this.parsedMaxDate.time) {
|
|
627
|
-
this.date = this.$pi.date.parseDate(this.parsedMaxDate.time)
|
|
635
|
+
this.date = this.$pi.date.parseDate(new Date(this.parsedMaxDate.time.getTime()))
|
|
628
636
|
needUpdate = true
|
|
629
637
|
}
|
|
630
638
|
return needUpdate
|