🐛(component): datePicker 修复年选择器清空后的bug,并新增三个事件
This commit is contained in:
parent
30b4e18bb3
commit
3a04d0bb80
@ -100,7 +100,7 @@ watch(
|
|||||||
|
|
||||||
//关闭回调
|
//关闭回调
|
||||||
const footOnOk = () => {
|
const footOnOk = () => {
|
||||||
emits("update:modelValue", Month.value);
|
emits("update:modelValue", Month.value?Month.value:-1);
|
||||||
if (datePicker.range) {
|
if (datePicker.range) {
|
||||||
//关闭菜单
|
//关闭菜单
|
||||||
emits("ok");
|
emits("ok");
|
||||||
|
@ -116,7 +116,7 @@ const scrollTo = () => {
|
|||||||
|
|
||||||
//关闭回调
|
//关闭回调
|
||||||
const footOnOk = () => {
|
const footOnOk = () => {
|
||||||
emits("update:modelValue", Year.value);
|
emits("update:modelValue", Year.value?Year.value:-1);
|
||||||
if (datePicker.range) {
|
if (datePicker.range) {
|
||||||
//关闭菜单
|
//关闭菜单
|
||||||
emits("ok");
|
emits("ok");
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
v-model="dateValue"
|
v-model="dateValue"
|
||||||
v-if="!range"
|
v-if="!range"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
|
@blur="$emit('blur')"
|
||||||
|
@focus="$emit('focus')"
|
||||||
:allow-clear="!disabled && allowClear"
|
:allow-clear="!disabled && allowClear"
|
||||||
:size="size"
|
:size="size"
|
||||||
@clear="
|
@clear="
|
||||||
@ -37,6 +39,8 @@
|
|||||||
:placeholder="startPlaceholder"
|
:placeholder="startPlaceholder"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
|
@blur="$emit('blur')"
|
||||||
|
@focus="$emit('focus')"
|
||||||
class="start-input"
|
class="start-input"
|
||||||
:size="size"
|
:size="size"
|
||||||
>
|
>
|
||||||
@ -50,6 +54,8 @@
|
|||||||
v-model="dateValue[1]"
|
v-model="dateValue[1]"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
|
@blur="$emit('blur')"
|
||||||
|
@focus="$emit('focus')"
|
||||||
class="end-input"
|
class="end-input"
|
||||||
:size="size"
|
:size="size"
|
||||||
@clear="
|
@clear="
|
||||||
@ -181,7 +187,7 @@ const endPlaceholder = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const dropdownRef = ref(null);
|
const dropdownRef = ref(null);
|
||||||
const $emits = defineEmits(["update:modelValue"]);
|
const $emits = defineEmits(["update:modelValue",'change','blur','focus']);
|
||||||
const hms = ref({
|
const hms = ref({
|
||||||
hh: 0,
|
hh: 0,
|
||||||
mm: 0,
|
mm: 0,
|
||||||
@ -261,8 +267,10 @@ const getDateValue = () => {
|
|||||||
}
|
}
|
||||||
if (props.timestamp) {
|
if (props.timestamp) {
|
||||||
$emits("update:modelValue", dayjs(dayjsVal).unix() * 1000);
|
$emits("update:modelValue", dayjs(dayjsVal).unix() * 1000);
|
||||||
|
$emits("change",dayjs(dayjsVal).unix() * 1000);
|
||||||
} else {
|
} else {
|
||||||
$emits("update:modelValue", dayjsVal);
|
$emits("update:modelValue", dayjsVal);
|
||||||
|
$emits("change",dayjsVal);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
unWatch = false;
|
unWatch = false;
|
||||||
@ -273,6 +281,7 @@ const getDateValueByRange = () => {
|
|||||||
if (rangeValue.first === "" || rangeValue.last === "") {
|
if (rangeValue.first === "" || rangeValue.last === "") {
|
||||||
dateValue.value = ["", ""];
|
dateValue.value = ["", ""];
|
||||||
$emits("update:modelValue", dateValue.value);
|
$emits("update:modelValue", dateValue.value);
|
||||||
|
$emits("change",dateValue.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let format = "YYYY-MM-DD";
|
let format = "YYYY-MM-DD";
|
||||||
@ -292,6 +301,7 @@ const getDateValueByRange = () => {
|
|||||||
dayjs(rangeValue.last).format(format),
|
dayjs(rangeValue.last).format(format),
|
||||||
];
|
];
|
||||||
$emits("update:modelValue", dateValue.value);
|
$emits("update:modelValue", dateValue.value);
|
||||||
|
$emits("change",dateValue.value);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
unWatch = false;
|
unWatch = false;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -303,6 +303,18 @@ export default {
|
|||||||
| contentClass | 内容自定义Class | `string` `Array<string \| object>` `object` | -- | -- |-- |
|
| contentClass | 内容自定义Class | `string` `Array<string \| object>` `object` | -- | -- |-- |
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: title Date Picker 事件
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: table
|
||||||
|
|
||||||
|
| 事件 | 描述 | 参数 |
|
||||||
|
| ----- | ------------------- | -------------------------- |
|
||||||
|
| change| 原生 change 事件 | (value : 同v-model) |
|
||||||
|
| focus | 原生 focus事件 | event : Event |
|
||||||
|
| blur | 原生 blur 事件 | event : Event |
|
||||||
|
:::
|
||||||
|
|
||||||
::: contributor datePicker
|
::: contributor datePicker
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user