Merge branch 'develop' of https://gitee.com/lockingreal/layui-vue into develop

This commit is contained in:
lockingreal 2022-03-27 12:32:58 +08:00
commit 9ec29424cf
9 changed files with 153 additions and 99 deletions

View File

@ -106,7 +106,7 @@ export default {
::: demo
<template>
<lay-menu level="true" v-model:selectedKey="selectedKey" inverted="true" v-model:openKeys="openKeys3" :tree="true">
<lay-menu :level="isLevel" v-model:selectedKey="selectedKey" inverted="true" v-model:openKeys="openKeys3" :tree="true">
<lay-menu-item id="1">首页</lay-menu-item>
<lay-menu-item id="2">首页</lay-menu-item>
<lay-menu-item id="3">首页</lay-menu-item>
@ -134,10 +134,12 @@ import { ref } from 'vue'
export default {
setup() {
const openKeys3 = ref(["7"])
const selectedKey = ref("5")
const isLevel = ref(false);
const openKeys3 = ref(["7"]);
const selectedKey = ref("5");
return {
isLevel,
openKeys3,
selectedKey
}

View File

@ -42,7 +42,7 @@ export default {
:::
::: title 基础使用
::: title 淡入淡出
:::
::: demo 使用 `lay-transition` 标签, 为元素提供过渡动画
@ -75,4 +75,27 @@ export default {
}
</script>
:::
::: title Transition 属性
:::
::: table
| 属性 | 描述 | 类型 |默认值 | 可选值 |
| ------------ | ---------------- | ------------- | ---- | ---- |
| enable | 启用 | `boolean` | `true` | `true` `false` |
| type | 类型 | `string` | `collapse` | -- |
:::
::: title Transition 属性值
:::
::: table
| 属性值 | 描述 |
| ------------ | ---------------- |
| collapse | 折叠动画 |
| fade | 淡入淡出 |
:::

View File

@ -11,6 +11,17 @@
<template>
<lay-timeline>
<lay-timeline-item title="0.4.0">
<ul>
<a name="0-4-3"> </a>
<li>
<h3>0.4.3 <span class="layui-badge-rim">2022-03-27</span></h3>
<ul>
<li>[修复] menu 组件 level 属性的语义与实际功能相悖。</li>
<li>[修复] input 组件 height 高度固定 38 px。</li>
<li>[修复] step 组件 line 样式。</li>
</ul>
</li>
</ul>
<ul>
<a name="0-4-2"> </a>
<li>

View File

@ -308,7 +308,7 @@ export default {
<style>
.layui-layout-document > .layui-header {
z-index: 9999;
z-index: 99;
width: 100%;
position: fixed;
background: #393d49;
@ -319,6 +319,7 @@ export default {
overflow-x: hidden;
position: fixed;
margin-top: 60px;
z-index: 99;
height: calc(100% - 60px);
box-shadow: 2px 0 8px 0 rgb(29 35 41 / 5%);
}

View File

@ -0,0 +1,43 @@
/**
*
*/
const getYears = () => {
let years = [];
for (let i = 1970; i < getYear() + 100; i++) {
years.push(i);
}
return years;
};
/**
*
*/
const getDate = () => {
return new Date();
};
/**
*
*/
const getYear = () => {
return getDate().getFullYear();
};
/**
*
*/
const getMonth = () => {
return getDate().getMonth();
};
/**
*
*
* @param year
* @param month
*/
const getDayLength = (year: number, month: number): number => {
return new Date(year, month + 1, 0).getDate();
};
export { getDayLength, getYears, getDate, getMonth, getYear };

View File

@ -17,8 +17,10 @@
></i
>
<div class="laydate-set-ym">
<span @click="showYearPanel">{{ curYear }} </span
><span @click="showPanel = 'month'">{{ curMonth + 1 }} </span>
<span @click="showYearPanel">{{ currentYear }} </span
><span @click="showPanel = 'month'"
>{{ currentMonth + 1 }} </span
>
</div>
<i
class="layui-icon laydate-icon laydate-next-m"
@ -100,9 +102,9 @@
<li
v-for="item of yearList"
:key="item"
:class="[{ 'layui-this': curYear === item }]"
:class="[{ 'layui-this': currentYear === item }]"
@click="
curYear = item;
currentYear = item;
showPanel = 'date';
"
>
@ -136,8 +138,10 @@
></i
>
<div class="laydate-set-ym">
<span @click="showYearPanel">{{ curYear }} </span
><span @click="showPanel = 'month'">{{ curMonth + 1 }} </span>
<span @click="showYearPanel">{{ currentYear }} </span
><span @click="showPanel = 'month'"
>{{ currentMonth + 1 }} </span
>
</div>
<i
class="layui-icon laydate-icon laydate-next-y"
@ -151,10 +155,10 @@
v-for="item of MONTH_NAME"
:key="item"
:class="[
{ 'layui-this': MONTH_NAME.indexOf(item) === curMonth },
{ 'layui-this': MONTH_NAME.indexOf(item) === currentMonth },
]"
@click="
curMonth = MONTH_NAME.indexOf(item);
currentMonth = MONTH_NAME.indexOf(item);
showPanel = 'date';
"
>
@ -178,7 +182,7 @@
</div>
</div>
<!-- 事件选择器 -->
<!-- 时间选择器 -->
<div class="layui-laydate" v-if="showPanel == 'time'">
<div class="layui-laydate-main laydate-main-list-0 laydate-time-show">
<div class="layui-laydate-header">
@ -188,12 +192,8 @@
</div>
<div class="layui-laydate-content" style="height: 210px">
<ul class="layui-laydate-list laydate-time-list">
<li
class="num-list"
v-for="item in hms.insertEls"
:key="item.type"
>
<ol class="scroll" @click="chooseTime">
<li class="num-list" v-for="item in els" :key="item.type">
<ol class="scroll" @click="choseTime">
<li
v-for="(it, index) in item.count"
:id="item.type + index.toString()"
@ -231,28 +231,20 @@
</template>
<script lang="ts" setup>
import { computed, nextTick, ref, watch, defineProps, defineEmits } from "vue";
import {
computed,
nextTick,
ref,
watch,
defineProps,
defineEmits,
onMounted,
} from "vue";
import LayInput from "../input/index.vue";
import LayDropdown from "../dropdown/index.vue";
export interface LayDatePickerProps {
modelValue?: string;
type: "date" | "datetime" | "year" | "time" | "month";
}
const props = withDefaults(defineProps<LayDatePickerProps>(), {
modelValue: "",
type: "date",
});
import { getDayLength, getYears, getDate, getMonth, getYear } from "./day";
const $emits = defineEmits(["update:modelValue"]);
const currentDate = new Date();
const yearList = ref<number[]>([]);
const dateList = ref<any[]>([]);
const curYear = ref(currentDate.getFullYear());
const curMonth = ref(currentDate.getMonth());
const showPanel = ref("date");
const selectedDay = ref<number>();
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
const MONTH_NAME = [
@ -270,26 +262,33 @@ const MONTH_NAME = [
"12月",
];
const hms = ref({
hh: "00",
mm: "00",
ss: "00",
insertEls: [
{
count: 24,
type: "hh",
},
{
count: 60,
type: "mm",
},
{
count: 60,
type: "ss",
},
],
const hms = ref({ hh: "00", mm: "00", ss: "00" });
const els = [
{ count: 24, type: "hh" },
{ count: 60, type: "mm" },
{ count: 60, type: "ss" },
];
export interface LayDatePickerProps {
modelValue?: string;
type: "date" | "datetime" | "year" | "time" | "month";
}
const props = withDefaults(defineProps<LayDatePickerProps>(), {
modelValue: "",
type: "date",
});
const currentDate = getDate();
const currentYear = ref(getYear());
const currentMonth = ref(getMonth());
const yearList = ref<number[]>(getYears());
const dateList = ref<any[]>([]);
const showPanel = ref("date");
const selectedDay = ref<number>();
//
const dateValue = computed<string>(() => {
if (!selectedDay.value) return "";
const d = new Date(selectedDay.value);
@ -301,18 +300,6 @@ const dateValue = computed<string>(() => {
return currentValue;
});
// 100
(() => {
for (let i = 1970; i < curYear.value + 100; i++) {
yearList.value.push(i);
}
})();
//
const getDayLength = (year: number, month: number): number => {
return new Date(year, month + 1, 0).getDate();
};
//
const setDateList = (year: number, month: number) => {
const curDays = getDayLength(year, month); //
@ -355,10 +342,11 @@ const setDateList = (year: number, month: number) => {
dateList.value = list;
};
// ,
watch(
[curYear, curMonth],
[currentYear, currentMonth],
() => {
setDateList(curYear.value, curMonth.value);
setDateList(currentYear.value, currentMonth.value);
},
{ immediate: true }
);
@ -367,8 +355,8 @@ watch(
const handleDayClick = (item: any) => {
selectedDay.value = item.value;
if (item.type !== "current") {
curMonth.value =
item.type === "prev" ? curMonth.value - 1 : curMonth.value + 1;
currentMonth.value =
item.type === "prev" ? currentMonth.value - 1 : currentMonth.value + 1;
}
};
@ -378,18 +366,17 @@ const ok = () => {};
//
const changeYearOrMonth = (type: "year" | "month", num: number) => {
if (type === "year") {
curYear.value += num;
currentYear.value += num;
} else {
let month = curMonth.value + num;
let month = currentMonth.value + num;
if (month > 11) {
month = 0;
curYear.value++;
currentYear.value++;
} else if (month < 0) {
month = 11;
curYear.value--;
currentYear.value--;
}
curMonth.value = month;
currentMonth.value = month;
}
};
@ -403,23 +390,8 @@ const showYearPanel = () => {
});
};
const showHmPanel = ref(false);
const openHmPanel = () => {
let activeEl = document.querySelectorAll(".hms-change .isactive") as any;
let count = 0;
const initScrollIntoView = () => {
if (count > activeEl.length) return;
activeEl[count].scrollIntoView({ behavior: "smooth" });
count++;
setTimeout(initScrollIntoView, Number(activeEl[count].dataset.value) * 16);
};
initScrollIntoView();
showHmPanel.value = !showHmPanel.value;
};
const chooseTime = (e: any) => {
// - hms
const choseTime = (e: any) => {
if (e.target.nodeName == "LI") {
let { value, type } = e.target.dataset;
hms.value[type as keyof typeof hms.value] = value;

View File

@ -21,6 +21,8 @@
.layui-input-wrapper {
width: 100%;
height: 38px;
line-height: 38px;
border-width: 1px;
border-style: solid;
display: inline-flex;

View File

@ -327,8 +327,8 @@
padding: 5px 17px 5px 17px;
}
.layui-nav-tree.level {
.layui-nav-itemed > .layui-nav-child {
.layui-nav-tree.not-level {
.layui-nav-child {
background-color: transparent;
}
}

View File

@ -27,7 +27,7 @@ const props = withDefaults(defineProps<LayMenuProps>(), {
tree: false,
theme: "dark",
inverted: false,
level: false,
level: true,
collapse: false,
collapseTransition: true,
});
@ -82,7 +82,7 @@ provide("isCollapseTransition", isCollapseTransition);
<ul
class="layui-nav"
:class="[
level ? 'level' : '',
level ? '' : 'not-level',
inverted ? 'inverted' : '',
tree ? 'layui-nav-tree' : '',
theme === 'dark' ? 'layui-nav-dark' : 'layui-nav-light',