【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