|
39 | 39 | }, |
40 | 40 | data() { |
41 | 41 | return { |
42 | | - tempIndex: [0, 0, 0] |
| 42 | + tempIndex: [0, 0, 0], |
| 43 | + values: [0, 0, 0] |
43 | 44 | } |
44 | 45 | }, |
| 46 | + mounted() { |
| 47 | + this.values = [this.years[this.selectedIndex[0]], this.month[this.selectedIndex[1]], this.day[this.selectedIndex[2]]] |
| 48 | + this.tempIndex = this.selectedIndex |
| 49 | + }, |
45 | 50 | computed: { |
46 | 51 | years() { |
47 | 52 | return range(this.min[0], this.max[0], false, '年') |
|
67 | 72 |
|
68 | 73 | let minDay = !this.tempIndex[0] && !this.tempIndex[1] ? this.min[2] : 1 |
69 | 74 | let maxDay = this.tempIndex[0] === this.years.length - 1 && this.tempIndex[1] === this.months.length - 1 ? this.max[2] : day |
| 75 | + let days = range(minDay, maxDay, false, '日') |
| 76 | +
|
| 77 | + this.$refs.picker.setData([this.years, this.months, this.days], this.tempIndex) |
70 | 78 |
|
71 | | - return range(minDay, maxDay, false, '日') |
| 79 | + return days |
72 | 80 | }, |
73 | 81 | dateData() { |
74 | 82 | return [this.years, this.months, this.days] |
75 | 83 | } |
76 | 84 | }, |
77 | 85 | watch: { |
78 | | - dateData() { |
| 86 | + days() { |
| 87 | + this.$refs.picker.setData(this.dateData, [this.yearIndex, this.monthIndex, this.dayIndex]) |
79 | 88 | this.$refs.picker.refresh() |
80 | 89 | } |
81 | 90 | }, |
|
89 | 98 | change(i, newIndex) { |
90 | 99 | if (newIndex !== this.tempIndex[i]) { |
91 | 100 | this.tempIndex.splice(i, 1, newIndex) |
92 | | - this.$refs.picker.setData(this.dateData, this.tempIndex) |
| 101 | + } |
| 102 | + if (this.dateData[i][newIndex] !== this.value[i]) { |
| 103 | + this.values.splice(i, 1, this.dateData[i][newIndex]) |
93 | 104 | } |
94 | 105 | }, |
95 | 106 | select(selectedVal, selectedIndex, selectedText) { |
|
0 commit comments