zoukankan      html  css  js  c++  java
  • 【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 }

    例如:

  • 相关阅读:
    好的博客
    left join 后边的on条件 小记
    ElasticSearch构建订单服务的博客
    nacos mysql8.0修改
    maven配置
    idea常用配置
    http状态码
    Web Application:Exploded和Web Application:Archive
    将一个简单远程调用的方式例子改为异步调用 -- 2
    将一个简单远程调用的方式例子改为异步调用
  • 原文地址:https://www.cnblogs.com/xiaostudy/p/12670372.html
Copyright © 2011-2022 走看看