From 305eff05e5ab871f54ab7ade156dd2e6859b982a Mon Sep 17 00:00:00 2001 From: castleiMac Date: Sun, 3 Apr 2022 20:35:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=AD=A3]=20=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E5=8F=B3=E4=B8=8B=E8=A7=92=E7=9A=84=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=80=BC=E6=8F=90=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/datePicker/index.vue | 338 +++++++++++++++++------------ 1 file changed, 203 insertions(+), 135 deletions(-) diff --git a/src/component/datePicker/index.vue b/src/component/datePicker/index.vue index 8f7979ef..749c6be5 100644 --- a/src/component/datePicker/index.vue +++ b/src/component/datePicker/index.vue @@ -1,162 +1,205 @@ @@ -240,10 +283,35 @@ const dateValue = computed(() => { return ""; } let momentVal; - let momentObj = moment(currentDay.value || props.modelValue) - momentVal = momentObj.format(fmtMap[props.type]) - if (momentVal != props.modelValue) - $emits("update:modelValue", momentVal); + let momentObj = moment(currentDay.value) + .hour(hms.value.hh) + .minute(hms.value.mm) + .second(hms.value.ss); + + switch (props.type) { + case "date": + momentVal = momentObj.format("YYYY-MM-DD"); + break; + case "datetime": + momentVal = momentObj.format("YYYY-MM-DD HH:mm:ss"); + break; + case "year": + momentVal = momentObj.format("YYYY"); + break; + case "month": + momentVal = momentObj.format("MM"); + break; + case "time": + momentVal = momentObj.format("HH:mm:ss"); + break; + case "yearmonth": + momentVal = momentObj.format("YYYY-MM"); + break; + default: + momentVal = momentObj.format(); + break; + } + $emits("update:modelValue", momentVal); return momentVal; });