feat(laydate): 时间选择器根据 format 格式显隐 (#1656)

pull/1682/head
morning-star 2024-02-28 09:08:40 +08:00 committed by GitHub
parent 71b8433449
commit 05d8138143
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 2 deletions

View File

@ -85,12 +85,14 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.layui-laydate .layui-laydate-list{position: absolute; left: 0; top: 0; width: 100%; height: 100%; padding: 10px; box-sizing: border-box; background-color: #fff;}
.layui-laydate .layui-laydate-list>li{position: relative; display: inline-block; width: 33.3%; height: 36px; line-height: 36px; margin: 3px 0; vertical-align: middle; text-align: center; cursor: pointer; list-style: none;}
.layui-laydate .laydate-month-list>li{width: 25%; margin: 17px 0;}
.laydate-time-list{}
.layui-laydate .laydate-time-list>li{height: 100%; margin: 0; line-height: normal; cursor: default;}
.laydate-time-list{display: table;}
.layui-laydate .laydate-time-list>li{display: table-cell; height: 100%; margin: 0; line-height: normal; cursor: default;}
.layui-laydate .laydate-time-list p{position: relative; top: -4px; margin: 0; line-height: 29px;}
.layui-laydate .laydate-time-list ol{height: 181px; overflow: hidden;}
.layui-laydate .laydate-time-list>li:hover ol{overflow-y: auto;}
.layui-laydate .laydate-time-list ol li{width: 130%; padding-left: 33px; height: 30px; line-height: 30px; text-align: left; cursor: pointer;}
.layui-laydate .laydate-time-list-hide-1 ol li{padding-left: 53px;}
.layui-laydate .laydate-time-list-hide-2 ol li{padding-left: 117px;}
/* 提示 */
.layui-laydate-hint{position: absolute; top: 115px; left: 50%; width: 250px; margin-left: -125px; line-height: 20px; padding: 15px; text-align: center; font-size: 12px; color: #FF5722;}
@ -183,3 +185,5 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.laydate-theme-fullpanel .laydate-time-show .laydate-set-ym span[lay-type="year"],
.laydate-theme-fullpanel .laydate-time-show .laydate-set-ym span[lay-type="month"] {display: inline-block !important;}
.laydate-theme-fullpanel .laydate-btns-time{display: none;}
.laydate-theme-fullpanel .laydate-time-list-hide-1 ol li{padding-left: 49px;}
.laydate-theme-fullpanel .laydate-time-list-hide-2 ol li{padding-left: 107px;}

View File

@ -1410,6 +1410,22 @@
}
};
var setTimeListVisibility = function(){
var showHour = options.format.indexOf('H') !== -1;
var showMinute = options.format.indexOf('m') !== -1;
var showSecond = options.format.indexOf('s') !== -1;
var liElem = ul.children;
var hideCount = 0;
lay.each([showHour, showMinute, showSecond], function(i, isShow){
if(!isShow){
liElem[i].className += ' layui-hide';
hideCount++;
}
})
ul.className += (' laydate-time-list-hide-' + hideCount);
}
//初始化时间对象
if(options.range){
if(!that[startEnd]){
@ -1429,6 +1445,7 @@
ul.appendChild(li);
});
setTimeStatus();
setTimeListVisibility();
}
//插入容器