chore: 发布 0.4.4

This commit is contained in:
就眠儀式 2022-03-29 17:28:14 +08:00
parent 76a9e9c04e
commit 5344cc2564
4 changed files with 129 additions and 41 deletions

View File

@ -60,6 +60,58 @@ export default {
::: :::
::: title 年份选择
:::
::: demo
<template>
<lay-date-picker type="year" v-model="endTime"></lay-date-picker>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const endTime = ref("2022-03-04 17:35:00");
return {
endTime
}
}
}
</script>
:::
::: title 月份选择
:::
::: demo
<template>
<lay-date-picker type="month" v-model="endTime"></lay-date-picker>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const endTime = ref("2022-03-04 17:35:00");
return {
endTime
}
}
}
</script>
:::
::: comment ::: comment
::: :::

View File

@ -18,10 +18,15 @@
<ul> <ul>
<li>[新增] button 组件 prefix-icon 属性。</li> <li>[新增] button 组件 prefix-icon 属性。</li>
<li>[新增] button 组件 suffix-icon 属性。</li> <li>[新增] button 组件 suffix-icon 属性。</li>
<li>[新增] date-picker 组件 清空 操作, 清空选择日期。</li>
<li>[新增] date-picker 组件 确认 操作, 关闭选择面板。</li>
<li>[新增] date-picker 组件 type 属性 year 值, 支持 年份 选择。</li>
<li>[新增] date-picker 组件 type 属性 month 值, 支持 月份 选择。</li>
<li>[修复] date-picker 组件 type 属性为 datetime 时候面板不显示。</li>
<li>[新增] card 组件 shadow 属性, 可选值 hover, always, never。</li> <li>[新增] card 组件 shadow 属性, 可选值 hover, always, never。</li>
<li>[新增] table 组件 row 和 row-double 时间的 event 参数。</li> <li>[新增] table 组件 row 和 row-double 时间的 event 参数。</li>
<li>[新增] table 组件 contextmenu 行右键事件。</li> <li>[新增] table 组件 contextmenu 行右键事件。</li>
<li>[支持] Cdn 直接导入。</li> <li>[支持] cdn 直接导入使用</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -1,6 +1,6 @@
{ {
"name": "@layui/layui-vue", "name": "@layui/layui-vue",
"version": "0.4.3", "version": "0.4.4",
"author": "就眠儀式", "author": "就眠儀式",
"license": "MIT", "license": "MIT",
"description": "a component library for Vue 3 base on layui-vue", "description": "a component library for Vue 3 base on layui-vue",

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<lay-dropdown> <lay-dropdown ref="dropdownRef">
<lay-input :name="name" :value="dateValue || modelValue" readonly> <lay-input :name="name" :value="dateValue || modelValue" readonly>
<template #prefix> <template #prefix>
<lay-icon type="layui-icon-date"></lay-icon> <lay-icon type="layui-icon-date"></lay-icon>
@ -8,7 +8,10 @@
</lay-input> </lay-input>
<template #content> <template #content>
<!-- 日期选择 --> <!-- 日期选择 -->
<div class="layui-laydate" v-show="showPane === 'date'"> <div
class="layui-laydate"
v-show="showPane === 'date' || showPane === 'datetime'"
>
<div class="layui-laydate-main laydate-main-list-0"> <div class="layui-laydate-main laydate-main-list-0">
<div class="layui-laydate-header"> <div class="layui-laydate-header">
<i <i
@ -80,10 +83,10 @@
>选择时间</span >选择时间</span
> >
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear">清空</span <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span
><span lay-type="now" class="laydate-btns-now" @click="now" ><span lay-type="now" class="laydate-btns-now" @click="now"
>现在</span >现在</span
><span lay-type="confirm" class="laydate-btns-confirm">确定</span> ><span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
</div> </div>
</div> </div>
</div> </div>
@ -105,10 +108,7 @@
v-for="item of yearList" v-for="item of yearList"
:key="item" :key="item"
:class="[{ 'layui-this': currentYear === item }]" :class="[{ 'layui-this': currentYear === item }]"
@click=" @click="handleYearClick(item)"
currentYear = item;
showPane = 'date';
"
> >
{{ item }} {{ item }}
</li> </li>
@ -123,10 +123,10 @@
>2022</span >2022</span
> >
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear">清空</span <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span
><span lay-type="now" class="laydate-btns-now" @click="now" ><span lay-type="now" class="laydate-btns-now" @click="now"
>现在</span >现在</span
><span lay-type="confirm" class="laydate-btns-confirm">确定</span> ><span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
</div> </div>
</div> </div>
</div> </div>
@ -141,8 +141,9 @@
></i ></i
> >
<div class="laydate-set-ym"> <div class="laydate-set-ym">
<span @click="showYearPanel">{{ currentYear }} </span
><span @click="showPane = 'month'" <span @click="showYearPanel" v-if="showPane === 'date' || showPane === 'datetime'">{{ currentYear }} </span>
<span @click="showPane = 'month'"
>{{ currentMonth + 1 }} </span >{{ currentMonth + 1 }} </span
> >
</div> </div>
@ -160,10 +161,7 @@
:class="[ :class="[
{ 'layui-this': MONTH_NAME.indexOf(item) === currentMonth }, { 'layui-this': MONTH_NAME.indexOf(item) === currentMonth },
]" ]"
@click=" @click="handleMonthClick(item)"
currentMonth = MONTH_NAME.indexOf(item);
showPane = 'date';
"
> >
{{ item.slice(0, 3) }} {{ item.slice(0, 3) }}
</li> </li>
@ -178,10 +176,10 @@
>2022-03</span >2022-03</span
> >
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear">清空</span <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span
><span lay-type="now" class="laydate-btns-now" @click="now" ><span lay-type="now" class="laydate-btns-now" @click="now"
>现在</span >现在</span
><span lay-type="confirm" class="laydate-btns-confirm">确定</span> ><span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
</div> </div>
</div> </div>
</div> </div>
@ -223,10 +221,10 @@
>返回日期</span >返回日期</span
> >
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear">清空</span <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span
><span lay-type="now" class="laydate-btns-now" @click="now" ><span lay-type="now" class="laydate-btns-now" @click="now"
>现在</span >现在</span
><span lay-type="confirm" class="laydate-btns-confirm">确定</span> ><span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
</div> </div>
</div> </div>
</div> </div>
@ -242,8 +240,9 @@ import moment from "moment";
import LayIcon from "../icon/index"; import LayIcon from "../icon/index";
import LayInput from "../input/index.vue"; import LayInput from "../input/index.vue";
import LayDropdown from "../dropdown/index.vue"; import LayDropdown from "../dropdown/index.vue";
import { getDayLength, getYears, getDate, getMonth, getYear } from "./day"; import { getDayLength, getYears, getMonth, getYear } from "./day";
const dropdownRef = ref(null);
const $emits = defineEmits(["update:modelValue"]); const $emits = defineEmits(["update:modelValue"]);
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"]; const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
@ -271,8 +270,8 @@ const els = [
export interface LayDatePickerProps { export interface LayDatePickerProps {
modelValue?: string; modelValue?: string;
type: "date" | "datetime" | "year" | "time" | "month"; type?: "date" | "datetime" | "year" | "time" | "month";
name: string; name?: string;
} }
const props = withDefaults(defineProps<LayDatePickerProps>(), { const props = withDefaults(defineProps<LayDatePickerProps>(), {
@ -288,8 +287,20 @@ const yearList = ref<number[]>(getYears());
const dateList = ref<any[]>([]); const dateList = ref<any[]>([]);
const showPane = ref("date"); const showPane = ref("date");
watch(
() => props.type,
() => {
showPane.value = props.type;
},
{ immediate: true }
);
// //
const dateValue = computed<string>(() => { const dateValue = computed<string>(() => {
if(currentDay.value === -1) {
$emits("update:modelValue", "");
return "";
}
let momentVal; let momentVal;
let momentObj = moment(currentDay.value) let momentObj = moment(currentDay.value)
.hour(hms.value.hh) .hour(hms.value.hh)
@ -366,17 +377,11 @@ watch(
{ immediate: true } { immediate: true }
); );
//
const handleDayClick = (item: any) => {
currentDay.value = item.value;
if (item.type !== "current") {
currentMonth.value =
item.type === "prev" ? currentMonth.value - 1 : currentMonth.value + 1;
}
};
// //
const ok = () => {}; const ok = () => {
// @ts-ignore
dropdownRef.value.hide();
};
// //
const now = () => { const now = () => {
@ -384,7 +389,9 @@ const now = () => {
}; };
// //
const clear = () => {}; const clear = () => {
currentDay.value = -1;
};
// //
const changeYearOrMonth = (type: "year" | "month", num: number) => { const changeYearOrMonth = (type: "year" | "month", num: number) => {
@ -406,11 +413,35 @@ const changeYearOrMonth = (type: "year" | "month", num: number) => {
// //
const showYearPanel = () => { const showYearPanel = () => {
showPane.value = "year"; showPane.value = "year";
nextTick(() => { };
(
document.querySelector(".year-panel-item.active") as HTMLElement //
).scrollIntoView({ block: "center" }); const handleYearClick = (item: any) => {
}); currentYear.value = item;
if (props.type === "year") {
currentDay.value = moment().year(item).valueOf();
} else {
showPane.value = "date";
}
};
//
const handleMonthClick = (item: any) => {
currentMonth.value = MONTH_NAME.indexOf(item);
if (props.type === "month") {
currentDay.value = moment().month(MONTH_NAME.indexOf(item)).valueOf();
} else {
showPane.value = "date";
}
};
//
const handleDayClick = (item: any) => {
currentDay.value = item.value;
if (item.type !== "current") {
currentMonth.value =
item.type === "prev" ? currentMonth.value - 1 : currentMonth.value + 1;
}
}; };
// - hms // - hms