【layui】laydate的年度類型設值,不能使用done方法時,翻頁不設值


 

當done方法使用不行時,只能使用change方法時

 1 /**
 2  * laydate的year類型設值,在change方法調用
 3  *
 4  * @param thiz change里面的this
 5  * @param value change的參數value
 6  * @param date change的參數date
 7  */
 8 function laydateYearSetValue(thiz, value, date) {
 9     if (thiz.min.year <= date.year && date.year <= thiz.max.year) {
10         $(thiz.elem).val(value);
11     } else if (date.year < thiz.min.year) {
12         $(thiz.elem).val(thiz.min.year);
13     } else if (date.year > thiz.max.year) {
14         $(thiz.elem).val(thiz.max.year);
15     }
16     if (undefined == thiz.myYear) {
17         thiz.beforeValue = parseInt($(thiz.elem).val());
18         thiz.myYearListLength = $(".laydate-year-list")[0].getElementsByTagName("li").length;
19         if (thiz.value) {
20             thiz.myYear = (parseInt(thiz.value) - (thiz.myYearListLength - 1)/2) + "年 - " + (parseInt(thiz.value) + (thiz.myYearListLength - 1)/2) + "年";
21         } else {
22             thiz.myYear = (new Date().getFullYear() - (thiz.myYearListLength - 1)/2) + "年 - " + (new Date().getFullYear() + (thiz.myYearListLength - 1)/2) + "年";
23         }
24         if ($('.laydate-set-ym').find('span[lay-type="year"]').html() == thiz.myYear) {
25             $("#layui-laydate" + $(thiz.elem).attr('lay-key')).remove();
26         } else {
27             thiz.myYear = $('.laydate-set-ym').find('span[lay-type="year"]').html();
28         }
29     } else {
30         if (Math.abs(parseInt(value) - thiz.beforeValue) < thiz.myYearListLength) {
31             $("#layui-laydate" + $(thiz.elem).attr('lay-key')).remove();
32         } else {
33             thiz.beforeValue = parseInt($(thiz.elem).val());
34             if ($('.laydate-set-ym').find('span[lay-type="year"]').html() == thiz.myYear) {
35                 $("#layui-laydate" + $(thiz.elem).attr('lay-key')).remove();
36             } else {
37                 thiz.myYear = $('.laydate-set-ym').find('span[lay-type="year"]').html();
38             }
39         }
40     }
41 }

 

 

例如:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM