This commit is contained in:
2024-09-24 17:04:44 +08:00
parent 6cd84e0021
commit 30528311c1
77 changed files with 2251 additions and 1361 deletions

View File

@@ -341,7 +341,10 @@ const _sfc_main$7 = defineComponent({
emits("update:hoverDate", -1);
return;
}
emits("update:hoverDate", parseInt(event.target.dataset.unix));
emits(
"update:hoverDate",
parseInt(event.target.dataset.unix)
);
};
const ifHasRangeHoverClass = computed(() => {
return function(item) {
@@ -435,12 +438,22 @@ const _sfc_main$6 = defineComponent({
t("datePicker.november"),
t("datePicker.december")
]);
watch([datePicker.currentYear, datePicker.currentMonth], () => {
dateList.value = setDateList(datePicker.currentYear.value, datePicker.currentMonth.value);
}, { immediate: true });
watch(() => props.modelValue, () => {
Day.value = props.modelValue;
});
watch(
[datePicker.currentYear, datePicker.currentMonth],
() => {
dateList.value = setDateList(
datePicker.currentYear.value,
datePicker.currentMonth.value
);
},
{ immediate: true }
);
watch(
() => props.modelValue,
() => {
Day.value = props.modelValue;
}
);
const changeYearOrMonth = (type, num) => {
if (type === "year") {
datePicker.currentYear.value += num;
@@ -572,13 +585,17 @@ const _sfc_main$5 = defineComponent({
onMounted(() => {
scrollTo();
});
watch(() => props.modelValue, () => {
hms.value = {
hh: props.modelValue.hh,
mm: props.modelValue.mm,
ss: props.modelValue.ss
};
}, { deep: true });
watch(
() => props.modelValue,
() => {
hms.value = {
hh: props.modelValue.hh,
mm: props.modelValue.mm,
ss: props.modelValue.ss
};
},
{ deep: true }
);
const scrollTo = () => {
nextTick(() => {
timePanelRef.value.childNodes.forEach((element) => {
@@ -734,9 +751,12 @@ const _sfc_main$4 = defineComponent({
onMounted(() => {
scrollTo();
});
watch(() => Year, () => {
Year.value = props.modelValue;
});
watch(
() => Year,
() => {
Year.value = props.modelValue;
}
);
const scrollTo = () => {
nextTick(() => {
let scrollTop = 0;
@@ -874,11 +894,17 @@ const _sfc_main$3 = defineComponent({
footOnOk();
}
};
watch(() => props.modelValue, () => {
Month.value = props.modelValue;
});
watch(
() => props.modelValue,
() => {
Month.value = props.modelValue;
}
);
const footOnOk = () => {
emits("update:modelValue", Month.value || Month.value === 0 ? Month.value : -1);
emits(
"update:modelValue",
Month.value || Month.value === 0 ? Month.value : -1
);
if (datePicker.range) {
emits("ok");
return;
@@ -1026,10 +1052,14 @@ const _sfc_main$2 = defineComponent({
startTime.month = month;
}
};
watch(() => [startTime.year, startTime.month], () => {
prevDateList.value = setDateList(startTime.year, startTime.month);
nextDateList.value = setDateList(startTime.year, startTime.month + 1);
}, { immediate: true });
watch(
() => [startTime.year, startTime.month],
() => {
prevDateList.value = setDateList(startTime.year, startTime.month);
nextDateList.value = setDateList(startTime.year, startTime.month + 1);
},
{ immediate: true }
);
const dropdownTimePanelRefLeft = ref();
const dropdownTimePanelRefRight = ref();
const dropdownYearPanelRefLeft = ref();
@@ -1355,12 +1385,15 @@ const _sfc_main$1 = defineComponent({
}
}
};
watch(() => [props.startTime, props.endTime], () => {
startTime.year = props.startTime ? dayjs(props.startTime).year() : dayjs().year();
startTime.unix = props.startTime ? dayjs(props.startTime).hour(0).minute(0).second(0).valueOf() : -1;
endTime.year = props.endTime ? dayjs(props.endTime).year() : dayjs().year();
endTime.unix = props.startTime ? dayjs(props.endTime).hour(0).minute(0).second(0).valueOf() : -1;
});
watch(
() => [props.startTime, props.endTime],
() => {
startTime.year = props.startTime ? dayjs(props.startTime).year() : dayjs().year();
startTime.unix = props.startTime ? dayjs(props.startTime).hour(0).minute(0).second(0).valueOf() : -1;
endTime.year = props.endTime ? dayjs(props.endTime).year() : dayjs().year();
endTime.unix = props.startTime ? dayjs(props.endTime).hour(0).minute(0).second(0).valueOf() : -1;
}
);
const dropdownYearPanelRefLeft = ref();
const dropdownYearPanelRefRight = ref();
const closeLeftYearPanel = () => {
@@ -1382,7 +1415,9 @@ const _sfc_main$1 = defineComponent({
};
const footOnNow = () => {
startTime.year = dayjs().year();
startTime.unix = dayjs(startTime.year + "-" + (dayjs().month() + 1)).valueOf();
startTime.unix = dayjs(
startTime.year + "-" + (dayjs().month() + 1)
).valueOf();
endTime.unix = -1;
hoverMonth.value = -1;
};
@@ -1402,7 +1437,9 @@ const _sfc_main$1 = defineComponent({
hoverMonth.value = -1;
return;
}
hoverMonth.value = parseInt(event.target.dataset.unix);
hoverMonth.value = parseInt(
event.target.dataset.unix
);
};
const ifHasRangeHoverClass = computed(() => {
return function(item) {
@@ -1468,7 +1505,9 @@ const _sfc_main$1 = defineComponent({
"data-unix": unref(getUnix)(item, "left"),
class: normalizeClass({
"layui-this": unref(getUnix)(item, "left") === startTime.unix || unref(getUnix)(item, "left") === endTime.unix,
"laydate-range-hover": unref(ifHasRangeHoverClass)(unref(getUnix)(item, "left")),
"laydate-range-hover": unref(ifHasRangeHoverClass)(
unref(getUnix)(item, "left")
),
"layui-laydate-current": (startTime.unix === -1 || endTime.unix === -1) && unref(getUnix)(item, "left") === unref(dayjs)().startOf("month").valueOf()
}),
onClick: ($event) => handleMonthClick(unref(getUnix)(item, "left")),
@@ -1512,7 +1551,9 @@ const _sfc_main$1 = defineComponent({
"data-unix": unref(getUnix)(item, "right"),
class: normalizeClass({
"layui-this": unref(getUnix)(item, "right") === startTime.unix || unref(getUnix)(item, "right") === endTime.unix,
"laydate-range-hover": unref(ifHasRangeHoverClass)(unref(getUnix)(item, "right")),
"laydate-range-hover": unref(ifHasRangeHoverClass)(
unref(getUnix)(item, "right")
),
"layui-laydate-current": (startTime.unix === -1 || endTime.unix === -1) && unref(getUnix)(item, "right") === unref(dayjs)().startOf("month").valueOf()
}),
onClick: ($event) => handleMonthClick(unref(getUnix)(item, "right")),
@@ -1686,50 +1727,58 @@ const _sfc_main = defineComponent({
dropdownRef.value.hide();
showPanel.value = props.type;
};
watch(() => props.type, () => {
showPanel.value = props.type;
if (props.type === "yearmonth" && !props.range) {
showPanel.value = "year";
}
}, { immediate: true });
watch(() => props.modelValue, () => {
if (unWatch) {
return;
}
let initModelValue = props.range && props.modelValue ? props.modelValue[0] || "" : props.modelValue;
if (props.type === "month" || props.type === "year") {
initModelValue += "";
}
hms.value.hh = isNaN(dayjs(initModelValue).hour()) ? 0 : dayjs(initModelValue).hour();
hms.value.mm = isNaN(dayjs(initModelValue).minute()) ? 0 : dayjs(initModelValue).minute();
hms.value.ss = isNaN(dayjs(initModelValue).second()) ? 0 : dayjs(initModelValue).second();
if (initModelValue.length === 8 && props.type === "time") {
let modelValue = initModelValue;
modelValue = "1970-01-01 " + modelValue;
hms.value.hh = dayjs(modelValue).hour();
hms.value.mm = dayjs(modelValue).minute();
hms.value.ss = dayjs(modelValue).second();
}
currentYear.value = initModelValue ? getYear(initModelValue) : -1;
currentMonth.value = initModelValue ? getMonth(initModelValue) : -1;
currentDay.value = initModelValue ? getDay(initModelValue) : -1;
if (props.type === "date" || props.type === "datetime") {
if (currentYear.value === -1)
currentYear.value = dayjs().year();
if (currentMonth.value === -1)
currentMonth.value = dayjs().month();
if (props.timestamp) {
currentDay.value = initModelValue ? dayjs(parseInt(initModelValue)).startOf("date").unix() * 1e3 : -1;
watch(
() => props.type,
() => {
showPanel.value = props.type;
if (props.type === "yearmonth" && !props.range) {
showPanel.value = "year";
}
}
rangeValue.first = initModelValue;
rangeValue.last = props.range && props.modelValue ? props.modelValue[1] || "" : "";
if (!props.range) {
getDateValue();
} else {
getDateValueByRange();
}
}, { immediate: true });
},
{ immediate: true }
);
watch(
() => props.modelValue,
() => {
if (unWatch) {
return;
}
let initModelValue = props.range && props.modelValue ? props.modelValue[0] || "" : props.modelValue;
if (props.type === "month" || props.type === "year") {
initModelValue += "";
}
hms.value.hh = isNaN(dayjs(initModelValue).hour()) ? 0 : dayjs(initModelValue).hour();
hms.value.mm = isNaN(dayjs(initModelValue).minute()) ? 0 : dayjs(initModelValue).minute();
hms.value.ss = isNaN(dayjs(initModelValue).second()) ? 0 : dayjs(initModelValue).second();
if (initModelValue.length === 8 && props.type === "time") {
let modelValue = initModelValue;
modelValue = "1970-01-01 " + modelValue;
hms.value.hh = dayjs(modelValue).hour();
hms.value.mm = dayjs(modelValue).minute();
hms.value.ss = dayjs(modelValue).second();
}
currentYear.value = initModelValue ? getYear(initModelValue) : -1;
currentMonth.value = initModelValue ? getMonth(initModelValue) : -1;
currentDay.value = initModelValue ? getDay(initModelValue) : -1;
if (props.type === "date" || props.type === "datetime") {
if (currentYear.value === -1)
currentYear.value = dayjs().year();
if (currentMonth.value === -1)
currentMonth.value = dayjs().month();
if (props.timestamp) {
currentDay.value = initModelValue ? dayjs(parseInt(initModelValue)).startOf("date").unix() * 1e3 : -1;
}
}
rangeValue.first = initModelValue;
rangeValue.last = props.range && props.modelValue ? props.modelValue[1] || "" : "";
if (!props.range) {
getDateValue();
} else {
getDateValueByRange();
}
},
{ immediate: true }
);
const onChange = () => {
if (dropdownRef.value)
dropdownRef.value.hide();