首页 > 其他 > 详细

季度半年度选择器

时间:2020-03-11 09:52:10      阅读:263      评论:0      收藏:0      [点我收藏+]

 

技术分享图片技术分享图片

 

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>季度半年度选择器</title>

    <style>
    body{padding: 20px;}
    .demo-input{padding-left: 10px; height: 38px; min-width: 262px; line-height: 38px; border: 1px solid #e6e6e6;  background-color: #fff;  border-radius: 2px;}
    .demo-footer{padding: 50px 0; color: #999; font-size: 14px;}
    .demo-footer a{padding: 0 5px; color: #01AAED;}
    </style>
    <script src="laydate/jquery-1.11.1.min.js"></script> <!-- 改成你的路径 -->
    <script src="laydate/laydate.js"></script> <!-- 改成你的路径 -->
</head>

<body>
    <input type="text" class="demo-input" placeholder="请选择季度" id="season">
    <input type="text" class="demo-input" placeholder="请选择半年度" id="year">
    <input type="text" class="demo-input" placeholder="" id="reporting_date">



    <script>
        function seasonFunction(){
            renderSeasonDate(document.getElementById(season), 1);
            function renderSeasonDate(ohd, sgl) {
                var ele = $(ohd);
                laydate.render({
                    elem: ohd,
                    type: month,
                    format: yyyy-第M季度,
                    range: sgl ? null : ~,
                    min: "1900-1-1",
                    max: "2999-12-31",
                    btns: [confirm],
                    ready: function () {
                        var hd = $("#layui-laydate" + ele.attr("lay-key"));
                        if (hd.length > 0) {
                            hd.click(function () {
                                ren($(this));
                            });
                        }
                        ren(hd);
                    },

                    done: function (value) {
                        var finaltime = ‘‘;
                        if (value){
                            value = value.split(-);
                            var year = value[0];
                            var season = value[1];
                            if (season == 第1季度){
                                var timeend = 03-31;
                                finaltime =  year + - + timeend;
                            }
                            if (season == 第2季度){
                                var timeend = 06-30;
                                finaltime =  year + - + timeend
                            }
                            if (season == 第3季度){
                                var timeend = 09-30;
                                finaltime = year + - + timeend
                            }
                            if (season == 第4季度){
                                var timeend = 12-31;
                                finaltime = year + - + timeend
                            }
                        }
                        $(#reporting_date).val(finaltime);
                    
                    }

                });
                var ren = function (thiz) {
                    var mls = thiz.find(".laydate-month-list");
                    mls.each(function (i, e) {
                        $(this).find("li").each(function (inx, ele) {
                            var cx = ele.innerHTML;
                            if (inx < 4) {
                                ele.innerHTML = cx.replace(//g, "季度").replace(//g, "第1").replace(//g, "第2").replace(//g, "第3").replace(//g, "第4");
                            } else {
                                ele.style.display = "none";
                            }
                        });
                    });
                }
            }
        }
        seasonFunction()

        function yearFunction(){
            renderYearDate(document.getElementById(year), 1);
            function renderYearDate(ohd, sgl) {
                var ele = $(ohd);
                laydate.render({
                    elem: ohd,
                    type: month,
                    format: yyyy-h半年,
                    range: sgl ? null : ~,
                    min: "1900-1-1",
                    max: "2999-12-31",
                    btns: [ confirm],
                    ready: function () {
                        var hd = $("#layui-laydate" + ele.attr("lay-key"));
                        if (hd.length > 0) {
                            hd.click(function () {
                                ren($(this));
                            });
                        }
                        ren(hd);
                    },

                    done: function (value) {
                        var finaltime = ‘‘;
                        if (value){
                            value = value.split(-);
                            var year = value[0];
                            var halfyear = value[1];

                            if (halfyear == 上半年){
                                var timeend = 06-30;
                                finaltime = year + - + timeend
                            }
                            if (halfyear == 下半年){
                                var timeend = 12-31;
                                finaltime = year + - + timeend
                            }
                        }
                        $(#reporting_date).val(finaltime);
                    
                    }

                });
                var ren = function (thiz) {
                    var mls = thiz.find(".laydate-month-list");
                    mls.each(function (i, e) {
                        $(this).find("li").each(function (inx, ele) {
                            var cx = ele.innerHTML;
                            if (inx < 2) {
                                cx = cx.replace(//g, "半年");
                                ele.innerHTML = cx.replace(//g, "").replace(//g, "");

                            } else {
                                ele.style.display = "none";
                            }
                        });
                    });
                }
            }
        }
        yearFunction()
    </script>
</body>

</html>

 

季度半年度选择器

原文:https://www.cnblogs.com/zhangguosheng1121/p/12460438.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!