From 7a9d948c12833160822eb3ecaa8031887e49dffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0o=E5=BC=A0=E4=B8=8D=E6=AD=AAo0?= Date: Fri, 22 Jul 2022 09:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(component):=20=E4=BF=AE=E5=A4=8Dda?= =?UTF-8?q?tePicker=E6=9E=84=E5=BB=BA=E4=B9=8B=E5=90=8Etime=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datePicker/components/TimePanel.vue | 19 ++++++++++++++----- .../src/component/datePicker/index.vue | 6 +----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/package/component/src/component/datePicker/components/TimePanel.vue b/package/component/src/component/datePicker/components/TimePanel.vue index 94fa5dbf..4476d605 100644 --- a/package/component/src/component/datePicker/components/TimePanel.vue +++ b/package/component/src/component/datePicker/components/TimePanel.vue @@ -23,7 +23,7 @@ :key="it" :class="[ 'num', - index.toString().padStart(2, '0') == (hms as hmsType)[item.type] + index == hms[item.type] ? 'layui-this' : '', ]" @@ -64,6 +64,7 @@ export interface hmsType { hh: number; mm: number; ss: number; + [key: string]: any; } export interface TimePanelProps { modelValue: hmsType; @@ -77,7 +78,11 @@ const els = [ { count: 60, type: "mm" }, { count: 60, type: "ss" }, ]; -const hms = ref<{ hh: number; mm: number; ss: number }>(props.modelValue); +const hms = ref({ + hh:props.modelValue.hh, + mm: props.modelValue.mm, + ss: props.modelValue.ss, +}); // 点击时间 - hms const chooseTime = (e: any) => { @@ -94,9 +99,13 @@ onMounted(() => { watch( () => props.modelValue, () => { - hms.value = props.modelValue; + hms.value = { + hh:props.modelValue.hh, + mm: props.modelValue.mm, + ss: props.modelValue.ss + }; }, - { deep: true } + { deep: true} ); const scrollTo = () => { nextTick(() => { @@ -125,7 +134,7 @@ const scrollTo = () => { //确认关闭回调 const footOnOk = () => { - emits("update:modelValue", hms); + emits("update:modelValue", hms.value); if (datePicker.range) { //关闭菜单 emits("ok"); diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 6195cc11..d61040b1 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -260,11 +260,7 @@ const getDateValueByRange = () => { // 确认事件 const ok = () => { if (!props.range) { - if (props.type === "time") { - getDateValue(); - } else { - getDateValue(); - } + getDateValue(); } else { getDateValueByRange(); }