docs: update

This commit is contained in:
就眠儀式
2022-03-17 00:04:27 +08:00
parent 1c5635ec27
commit c900a02e0a
7 changed files with 42 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div>
<lay-dropdown>
<lay-input v-model="dateValue" readonly />
<lay-input :value="dateValue || modelValue" readonly />
<template #content>
<!-- 日期选择 -->
<div class="layui-laydate" v-show="showPanel === 'date'">
@@ -230,7 +230,7 @@ import { computed, nextTick, ref, watch, defineProps, defineEmits } from "vue";
import LayInput from "../input/index.vue";
import LayDropdown from "../dropdown/index.vue";
defineProps({
const props = defineProps({
modelValue: { type: String, required: false },
});
@@ -241,7 +241,6 @@ const dateList = ref<any[]>([]);
const curYear = ref(currentDate.getFullYear());
const curMonth = ref(currentDate.getMonth());
const showPanel = ref("date");
const showDropdown = ref(false);
const selectedDay = ref<number>();
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
@@ -309,35 +308,33 @@ const setDateList = (year: number, month: number) => {
const prevDays = getDayLength(year, month - 1); // 上月天数
const curFirstDayWeek = new Date(year, month, 1).getDay(); // 当月第一天星期几
const list: any[] = [];
// 填充上月最后几
// 填充上月天
for (let i = prevDays - curFirstDayWeek + 1; i <= prevDays; i++) {
list.push({
day: i,
value: +new Date(year, month - 1, i),
value: + new Date(year, month - 1, i),
isRange: false,
isSelected: false,
type: "prev",
});
}
// 填充当月
// 填充当月天数
for (let i = 1; i <= curDays; i++) {
list.push({
day: i,
value: +new Date(year, month, i),
value: + new Date(year, month, i),
isRange: false,
isSelected: false,
type: "current",
});
}
// 填充下月天数
const nextDays = 7 - (list.length % 7);
if (nextDays !== 7) {
// 填充下月
for (let i = 1; i <= nextDays; i++) {
list.push({
day: i,
value: +new Date(year, month + 1, i),
value: + new Date(year, month + 1, i),
isRange: false,
isSelected: false,
type: "next",
@@ -362,9 +359,13 @@ const handleDayClick = (item: any) => {
curMonth.value =
item.type === "prev" ? curMonth.value - 1 : curMonth.value + 1;
}
showDropdown.value = false;
};
// 确认事件
const ok = () => {
}
// 切换年月
const changeYearOrMonth = (type: "year" | "month", num: number) => {
if (type === "year") {

View File

@@ -13,6 +13,7 @@ const { t } = useI18n();
export interface LayInputProps {
name?: string;
type?: string;
value?: string;
disabled?: boolean;
modelValue?: string | number;
placeholder?: string;
@@ -41,7 +42,7 @@ const onBlur = function () {
<input
:type="type"
:name="name"
:value="modelValue"
:value="modelValue || value"
:disabled="disabled"
:placeholder="placeholder"
:class="{ 'layui-disabled': disabled }"