From 3a04d0bb80417bf05b656206b9f8eb3082a3e8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0o=E5=BC=A0=E4=B8=8D=E6=AD=AAo0?= Date: Tue, 8 Nov 2022 17:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(component):=20datePicker=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B9=B4=E9=80=89=E6=8B=A9=E5=99=A8=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E5=90=8E=E7=9A=84bug,=E5=B9=B6=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=89=E4=B8=AA=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/datePicker/components/MonthPanel.vue | 2 +- .../component/datePicker/components/YearPanel.vue | 2 +- package/component/src/component/datePicker/index.vue | 12 +++++++++++- .../src/document/zh-CN/components/datePicker.md | 12 ++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/package/component/src/component/datePicker/components/MonthPanel.vue b/package/component/src/component/datePicker/components/MonthPanel.vue index 81be8417..2725524e 100644 --- a/package/component/src/component/datePicker/components/MonthPanel.vue +++ b/package/component/src/component/datePicker/components/MonthPanel.vue @@ -100,7 +100,7 @@ watch( //关闭回调 const footOnOk = () => { - emits("update:modelValue", Month.value); + emits("update:modelValue", Month.value?Month.value:-1); if (datePicker.range) { //关闭菜单 emits("ok"); diff --git a/package/component/src/component/datePicker/components/YearPanel.vue b/package/component/src/component/datePicker/components/YearPanel.vue index 45e85f30..cdcb704c 100644 --- a/package/component/src/component/datePicker/components/YearPanel.vue +++ b/package/component/src/component/datePicker/components/YearPanel.vue @@ -116,7 +116,7 @@ const scrollTo = () => { //关闭回调 const footOnOk = () => { - emits("update:modelValue", Year.value); + emits("update:modelValue", Year.value?Year.value:-1); if (datePicker.range) { //关闭菜单 emits("ok"); diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 8be863ff..34afff57 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -21,6 +21,8 @@ v-model="dateValue" v-if="!range" @change="onChange" + @blur="$emit('blur')" + @focus="$emit('focus')" :allow-clear="!disabled && allowClear" :size="size" @clear=" @@ -37,6 +39,8 @@ :placeholder="startPlaceholder" :disabled="disabled" @change="onChange" + @blur="$emit('blur')" + @focus="$emit('focus')" class="start-input" :size="size" > @@ -50,6 +54,8 @@ v-model="dateValue[1]" :disabled="disabled" @change="onChange" + @blur="$emit('blur')" + @focus="$emit('focus')" class="end-input" :size="size" @clear=" @@ -181,7 +187,7 @@ const endPlaceholder = computed(() => { }); const dropdownRef = ref(null); -const $emits = defineEmits(["update:modelValue"]); +const $emits = defineEmits(["update:modelValue",'change','blur','focus']); const hms = ref({ hh: 0, mm: 0, @@ -261,8 +267,10 @@ const getDateValue = () => { } if (props.timestamp) { $emits("update:modelValue", dayjs(dayjsVal).unix() * 1000); + $emits("change",dayjs(dayjsVal).unix() * 1000); } else { $emits("update:modelValue", dayjsVal); + $emits("change",dayjsVal); } setTimeout(() => { unWatch = false; @@ -273,6 +281,7 @@ const getDateValueByRange = () => { if (rangeValue.first === "" || rangeValue.last === "") { dateValue.value = ["", ""]; $emits("update:modelValue", dateValue.value); + $emits("change",dateValue.value); return; } let format = "YYYY-MM-DD"; @@ -292,6 +301,7 @@ const getDateValueByRange = () => { dayjs(rangeValue.last).format(format), ]; $emits("update:modelValue", dateValue.value); + $emits("change",dateValue.value); setTimeout(() => { unWatch = false; }, 0); diff --git a/package/document-component/src/document/zh-CN/components/datePicker.md b/package/document-component/src/document/zh-CN/components/datePicker.md index 44a47485..229365d7 100644 --- a/package/document-component/src/document/zh-CN/components/datePicker.md +++ b/package/document-component/src/document/zh-CN/components/datePicker.md @@ -303,6 +303,18 @@ export default { | contentClass | 内容自定义Class | `string` `Array` `object` | -- | -- |-- | ::: +::: title Date Picker 事件 +::: + +::: table + +| 事件 | 描述 | 参数 | +| ----- | ------------------- | -------------------------- | +| change| 原生 change 事件 | (value : 同v-model) | +| focus | 原生 focus事件 | event : Event | +| blur | 原生 blur 事件 | event : Event | +::: + ::: contributor datePicker :::