From 05d81381431dc3306e7c2f8b982671ad36b5c8cf Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Wed, 28 Feb 2024 09:08:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(laydate):=20=E6=97=B6=E9=97=B4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E6=A0=B9=E6=8D=AE=20format=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E6=98=BE=E9=9A=90=20(#1656)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/modules/laydate.css | 8 ++++++-- src/modules/laydate.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/css/modules/laydate.css b/src/css/modules/laydate.css index 18d163b3..998b8b98 100644 --- a/src/css/modules/laydate.css +++ b/src/css/modules/laydate.css @@ -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;} diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 2e7d30f0..9fc52e8b 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -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(); } //插入容器