From e19dd0ca434459d3ba7937e5214a8cbea1bd2f08 Mon Sep 17 00:00:00 2001 From: robinwu Date: Thu, 21 Dec 2023 15:12:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(datepicker):=20"hour-minute"=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8B=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=86=E9=92=9F=E5=88=97=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/datepicker/index.taro.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/packages/__VUE/datepicker/index.taro.vue b/src/packages/__VUE/datepicker/index.taro.vue index d047f97ad4..00191b7767 100644 --- a/src/packages/__VUE/datepicker/index.taro.vue +++ b/src/packages/__VUE/datepicker/index.taro.vue @@ -221,11 +221,11 @@ export default create({ selectedValue: (string | number)[]; selectedOptions: PickerOption[]; }) => { + let formatDate: (number | string)[] = []; + selectedValue.forEach((item) => { + formatDate.push(item); + }); if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) { - let formatDate: (number | string)[] = []; - selectedValue.forEach((item) => { - formatDate.push(item); - }); if (props.type == 'month-day' && formatDate.length < 3) { formatDate.unshift(new Date(state.currentDate || props.minDate || props.maxDate).getFullYear()); } @@ -245,6 +245,13 @@ export default create({ date = new Date(year, month, day, Number(formatDate[3])); } state.currentDate = formatValue(date as Date); + } else if (['hour-minute'].includes(props.type)) { + let date = new Date(state.currentDate); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); + date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); + state.currentDate = formatValue(date as Date); } emit('change', { columnIndex, selectedValue, selectedOptions }); }; From 7f431fc30c6751c67e29cd065972316c0709af32 Mon Sep 17 00:00:00 2001 From: robinwu Date: Thu, 21 Dec 2023 16:14:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(datepicker):=20"hour-minute"=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8B=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=86=E9=92=9F=E5=88=97=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/datepicker/index.taro.vue | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/packages/__VUE/datepicker/index.taro.vue b/src/packages/__VUE/datepicker/index.taro.vue index 00191b7767..167edac13c 100644 --- a/src/packages/__VUE/datepicker/index.taro.vue +++ b/src/packages/__VUE/datepicker/index.taro.vue @@ -221,11 +221,11 @@ export default create({ selectedValue: (string | number)[]; selectedOptions: PickerOption[]; }) => { - let formatDate: (number | string)[] = []; - selectedValue.forEach((item) => { - formatDate.push(item); - }); - if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) { + if (['date', 'datetime', 'datehour', 'month-day', 'year-month', 'hour-minute'].includes(props.type)) { + let formatDate: (number | string)[] = []; + selectedValue.forEach((item) => { + formatDate.push(item); + }); if (props.type == 'month-day' && formatDate.length < 3) { formatDate.unshift(new Date(state.currentDate || props.minDate || props.maxDate).getFullYear()); } @@ -243,15 +243,14 @@ export default create({ date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4])); } else if (props.type === 'datehour') { date = new Date(year, month, day, Number(formatDate[3])); + } else if (props.type === 'hour-minute') { + date = new Date(state.currentDate); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); + date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); } state.currentDate = formatValue(date as Date); - } else if (['hour-minute'].includes(props.type)) { - let date = new Date(state.currentDate); - const year = date.getFullYear(); - const month = date.getMonth(); - const day = date.getDate(); - date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); - state.currentDate = formatValue(date as Date); } emit('change', { columnIndex, selectedValue, selectedOptions }); }; From deda109bb68ec88fefba86cd304f73d857e5a9ad Mon Sep 17 00:00:00 2001 From: robinwu Date: Thu, 21 Dec 2023 18:27:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(datepicker):=20"hour-minute"=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8B=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=86=E9=92=9F=E5=88=97=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/datepicker/index.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/packages/__VUE/datepicker/index.vue b/src/packages/__VUE/datepicker/index.vue index 4a09376101..0a6f3d69a4 100644 --- a/src/packages/__VUE/datepicker/index.vue +++ b/src/packages/__VUE/datepicker/index.vue @@ -221,7 +221,7 @@ export default create({ selectedValue: (string | number)[]; selectedOptions: PickerOption[]; }) => { - if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) { + if (['date', 'datetime', 'datehour', 'month-day', 'year-month', 'hour-minute'].includes(props.type)) { let formatDate: (number | string)[] = []; selectedValue.forEach((item) => { formatDate.push(item); @@ -243,6 +243,12 @@ export default create({ date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4])); } else if (props.type === 'datehour') { date = new Date(year, month, day, Number(formatDate[3])); + } else if (props.type === 'hour-minute') { + date = new Date(state.currentDate); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); + date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); } state.currentDate = formatValue(date as Date); }