!45 日期组件和input的readonly一些问题处理

Merge pull request !45 from 鄢鹏权/develop
This commit is contained in:
就眠儀式 2022-04-03 12:41:58 +00:00 committed by Gitee
commit b865ed08d7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 54 additions and 102 deletions

View File

@ -14,6 +14,7 @@
::: demo ::: demo
<template> <template>
选择的时间:{{endTime}}
<lay-date-picker v-model="endTime"></lay-date-picker> <lay-date-picker v-model="endTime"></lay-date-picker>
</template> </template>
@ -23,7 +24,7 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const endTime = ref("2022-03-04 17:35:00"); const endTime = ref("2022-03-14 17:35:00");
return { return {
endTime endTime
@ -40,6 +41,7 @@ export default {
::: demo ::: demo
<template> <template>
选择的时间:{{endTime2}}
<lay-date-picker type="datetime" v-model="endTime2"></lay-date-picker> <lay-date-picker type="datetime" v-model="endTime2"></lay-date-picker>
</template> </template>
@ -66,6 +68,7 @@ export default {
::: demo ::: demo
<template> <template>
选择的时间:{{endTime3}}
<lay-date-picker type="year" v-model="endTime3"></lay-date-picker> <lay-date-picker type="year" v-model="endTime3"></lay-date-picker>
</template> </template>
@ -92,6 +95,7 @@ export default {
::: demo ::: demo
<template> <template>
选择的时间:{{endTime4}}
<lay-date-picker type="month" v-model="endTime4"></lay-date-picker> <lay-date-picker type="month" v-model="endTime4"></lay-date-picker>
</template> </template>

View File

@ -8,36 +8,29 @@
</lay-input> </lay-input>
<template #content> <template #content>
<!-- 日期选择 --> <!-- 日期选择 -->
<div <div class="layui-laydate" v-show="showPane === 'date' || showPane === 'datetime'">
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
class="layui-icon laydate-icon laydate-prev-y" class="layui-icon laydate-icon laydate-prev-y"
@click="changeYearOrMonth('year', -1)" @click="changeYearOrMonth('year', -1)"
></i ></i>
><i <i
class="layui-icon laydate-icon laydate-prev-m" class="layui-icon laydate-icon laydate-prev-m"
@click="changeYearOrMonth('month', -1)" @click="changeYearOrMonth('month', -1)"
></i ></i>
>
<div class="laydate-set-ym"> <div class="laydate-set-ym">
<span @click="showYearPanel">{{ currentYear }} </span <span @click="showYearPanel">{{ currentYear }} </span>
><span @click="showPane = 'month'" <span @click="showPane = 'month'">{{ currentMonth + 1 }} </span>
>{{ currentMonth + 1 }} </span
>
</div> </div>
<i <i
class="layui-icon laydate-icon laydate-next-m" class="layui-icon laydate-icon laydate-next-m"
@click="changeYearOrMonth('month', 1)" @click="changeYearOrMonth('month', 1)"
></i ></i>
><i <i
class="layui-icon laydate-icon laydate-next-y" class="layui-icon laydate-icon laydate-next-y"
@click="changeYearOrMonth('year', 1)" @click="changeYearOrMonth('year', 1)"
></i ></i>
>
</div> </div>
<div class="layui-laydate-content"> <div class="layui-laydate-content">
<table> <table>
@ -66,9 +59,7 @@
'layui-this': item.value === currentDay, 'layui-this': item.value === currentDay,
}" }"
@click="handleDayClick(item)" @click="handleDayClick(item)"
> >{{ item.day }}</td>
{{ item.day }}
</td>
</tr> </tr>
</template> </template>
</tbody> </tbody>
@ -80,44 +71,31 @@
v-if="type === 'datetime'" v-if="type === 'datetime'"
@click="showPane = 'time'" @click="showPane = 'time'"
class="laydate-btns-time" class="laydate-btns-time"
>选择时间</span >选择时间</span>
>
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear" @click="clear" <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span>
>清空</span <span lay-type="now" class="laydate-btns-now" @click="now">现在</span>
><span lay-type="now" class="laydate-btns-now" @click="now" <span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
>现在</span
><span lay-type="confirm" class="laydate-btns-confirm" @click="ok"
>确定</span
>
</div> </div>
</div> </div>
</div> </div>
<!-- 年份选择器 --> <!-- 年份选择器 -->
<div <div class="layui-laydate" v-show="showPane === 'year' || showPane === 'yearmonth'">
class="layui-laydate"
v-show="showPane === 'year' || showPane === 'yearmonth'"
>
<div class="layui-laydate-main laydate-main-list-0 laydate-ym-show"> <div class="layui-laydate-main laydate-main-list-0 laydate-ym-show">
<div class="layui-laydate-header"> <div class="layui-laydate-header">
<div class="laydate-set-ym"> <div class="laydate-set-ym">
<span class="laydate-time-text">选择年份</span> <span class="laydate-time-text">选择年份</span>
</div> </div>
</div> </div>
<div <div class="layui-laydate-content" style="height: 220px; overflow-y: auto">
class="layui-laydate-content"
style="height: 220px; overflow-y: auto"
>
<ul class="layui-laydate-list laydate-year-list"> <ul class="layui-laydate-list laydate-year-list">
<li <li
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="handleYearClick(item)" @click="handleYearClick(item)"
> >{{ item }}</li>
{{ item }}
</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -126,16 +104,11 @@
class="layui-laydate-preview" class="layui-laydate-preview"
title="当前选中的结果" title="当前选中的结果"
style="color: rgb(102, 102, 102)" style="color: rgb(102, 102, 102)"
>2022</span >{{ dateValue }}</span>
>
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear" @click="clear" <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span>
>清空</span <span lay-type="now" class="laydate-btns-now" @click="now">现在</span>
><span lay-type="now" class="laydate-btns-now" @click="now" <span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
>现在</span
><span lay-type="confirm" class="laydate-btns-confirm" @click="ok"
>确定</span
>
</div> </div>
</div> </div>
</div> </div>
@ -147,23 +120,18 @@
<i <i
class="layui-icon laydate-icon laydate-prev-y" class="layui-icon laydate-icon laydate-prev-y"
@click="changeYearOrMonth('year', -1)" @click="changeYearOrMonth('year', -1)"
></i ></i>
>
<div class="laydate-set-ym"> <div class="laydate-set-ym">
<span <span
@click="showYearPanel" @click="showYearPanel"
v-if="showPane === 'date' || showPane === 'datetime'" v-if="showPane === 'date' || showPane === 'datetime'"
>{{ currentYear }} </span >{{ currentYear }} </span>
> <span @click="showPane = 'month'">{{ currentMonth + 1 }} </span>
<span @click="showPane = 'month'"
>{{ currentMonth + 1 }} </span
>
</div> </div>
<i <i
class="layui-icon laydate-icon laydate-next-y" class="layui-icon laydate-icon laydate-next-y"
@click="changeYearOrMonth('year', 1)" @click="changeYearOrMonth('year', 1)"
></i ></i>
>
</div> </div>
<div class="layui-laydate-content" style="height: 220px"> <div class="layui-laydate-content" style="height: 220px">
<ul class="layui-laydate-list laydate-month-list"> <ul class="layui-laydate-list laydate-month-list">
@ -174,9 +142,7 @@
{ 'layui-this': MONTH_NAME.indexOf(item) === currentMonth }, { 'layui-this': MONTH_NAME.indexOf(item) === currentMonth },
]" ]"
@click="handleMonthClick(item)" @click="handleMonthClick(item)"
> >{{ item.slice(0, 3) }}</li>
{{ item.slice(0, 3) }}
</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -185,16 +151,11 @@
class="layui-laydate-preview" class="layui-laydate-preview"
title="当前选中的结果" title="当前选中的结果"
style="color: rgb(102, 102, 102)" style="color: rgb(102, 102, 102)"
>2022-03</span >{{ dateValue }}</span>
>
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear" @click="clear" <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span>
>清空</span <span lay-type="now" class="laydate-btns-now" @click="now">现在</span>
><span lay-type="now" class="laydate-btns-now" @click="now" <span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
>现在</span
><span lay-type="confirm" class="laydate-btns-confirm" @click="ok"
>确定</span
>
</div> </div>
</div> </div>
</div> </div>
@ -223,29 +184,18 @@
? 'layui-this' ? 'layui-this'
: '', : '',
]" ]"
> >{{ index.toString().padStart(2, "0") }}</li>
{{ index.toString().padStart(2, "0") }}
</li>
</ol> </ol>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="layui-laydate-footer"> <div class="layui-laydate-footer">
<span <span @click="showPane = 'date'" v-if="type != 'time'" class="laydate-btns-time">返回日期</span>
@click="showPane = 'date'"
v-if="type != 'time'"
class="laydate-btns-time"
>返回日期</span
>
<div class="laydate-footer-btns"> <div class="laydate-footer-btns">
<span lay-type="clear" class="laydate-btns-clear" @click="clear" <span lay-type="clear" class="laydate-btns-clear" @click="clear">清空</span>
>清空</span <span lay-type="now" class="laydate-btns-now" @click="now">现在</span>
><span lay-type="now" class="laydate-btns-now" @click="now" <span lay-type="confirm" class="laydate-btns-confirm" @click="ok">确定</span>
>现在</span
><span lay-type="confirm" class="laydate-btns-confirm" @click="ok"
>确定</span
>
</div> </div>
</div> </div>
</div> </div>

View File

@ -7,11 +7,10 @@ export default {
<script setup lang="ts"> <script setup lang="ts">
import "./index.less"; import "./index.less";
import { withDefaults } from "vue"; import { withDefaults } from "vue";
import { String } from "../../types";
export interface LayEmptyProps { export interface LayEmptyProps {
description?: String; description?: string;
image?: String; image?: string;
} }
const props = withDefaults(defineProps<LayEmptyProps>(), { const props = withDefaults(defineProps<LayEmptyProps>(), {
@ -24,9 +23,7 @@ const props = withDefaults(defineProps<LayEmptyProps>(), {
<div class="layui-empty-image"> <div class="layui-empty-image">
<img class="layui-empty-image-default" src="./index.svg" /> <img class="layui-empty-image-default" src="./index.svg" />
</div> </div>
<div class="layui-empty-description"> <div class="layui-empty-description">{{ description }}</div>
{{ description }}
</div>
<div class="layui-empty-extra"> <div class="layui-empty-extra">
<slot name="extra"></slot> <slot name="extra"></slot>
</div> </div>

View File

@ -8,19 +8,19 @@ export default {
import "./index.less"; import "./index.less";
import { useSlots } from "vue"; import { useSlots } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { Boolean, String } from "../../types";
const { t } = useI18n(); const { t } = useI18n();
const slots = useSlots(); const slots = useSlots();
export interface LayInputProps { export interface LayInputProps {
name?: String; name?: string;
type?: String; type?: string;
value?: String; value?: string;
disabled?: Boolean; disabled?: boolean;
modelValue?: String; readonly?: boolean;
placeholder?: String; modelValue?: string;
allowClear?: Boolean; placeholder?: string;
allowClear?: boolean;
} }
const props = withDefaults(defineProps<LayInputProps>(), {}); const props = withDefaults(defineProps<LayInputProps>(), {});
@ -73,6 +73,7 @@ const onBlur = () => {
@focus="onFocus" @focus="onFocus"
@blur="onBlur" @blur="onBlur"
@change="onChange" @change="onChange"
:readonly="props.readonly"
/> />
<span class="layui-input-suffix" v-if="slots.suffix"> <span class="layui-input-suffix" v-if="slots.suffix">
<slot name="suffix"></slot> <slot name="suffix"></slot>