Commit 7552bd7a7c267962b6f459fdfc19e35e1dbee244
1 parent
513e06e5
填报--- 时间操作
Showing
5 changed files
with
57 additions
and
8 deletions
index/index.html
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <html lang="en"> | 2 | <html lang="en"> |
| 3 | <head> | 3 | <head> |
| 4 | <meta charset="UTF-8"> | 4 | <meta charset="UTF-8"> |
| 5 | - <title>Title</title> | 5 | + <title>工时系统</title> |
| 6 | <link rel="stylesheet" id="pageCssLink" type="text/css" href=""/> | 6 | <link rel="stylesheet" id="pageCssLink" type="text/css" href=""/> |
| 7 | <link rel="stylesheet" href="../resource/lib/bootstrap/css/bootstrap.min.css"> | 7 | <link rel="stylesheet" href="../resource/lib/bootstrap/css/bootstrap.min.css"> |
| 8 | <link rel="stylesheet" href="../resource/lib/bootstrap-daterangepicker/daterangepicker.css"> | 8 | <link rel="stylesheet" href="../resource/lib/bootstrap-daterangepicker/daterangepicker.css"> |
resource/public/commoncss.css
| @@ -17,6 +17,9 @@ ul,li{ | @@ -17,6 +17,9 @@ ul,li{ | ||
| 17 | .cursorpointer{ | 17 | .cursorpointer{ |
| 18 | cursor: pointer; | 18 | cursor: pointer; |
| 19 | } | 19 | } |
| 20 | +.display-none{ | ||
| 21 | + display: none; | ||
| 22 | +} | ||
| 20 | /********************************************头部公共样式*/ | 23 | /********************************************头部公共样式*/ |
| 21 | header{ | 24 | header{ |
| 22 | width: 100%; | 25 | width: 100%; |
topages/workfill/workfill.css
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | width: 226px; | 21 | width: 226px; |
| 22 | height: 40px; | 22 | height: 40px; |
| 23 | line-height: 40px; | 23 | line-height: 40px; |
| 24 | + margin-top: 10px; | ||
| 24 | font-size: 14px; | 25 | font-size: 14px; |
| 25 | color: rgba(0,0,0,.4); | 26 | color: rgba(0,0,0,.4); |
| 26 | background-color: #fff; | 27 | background-color: #fff; |
topages/workfill/workfill.html
| 1 | <div class="time-opr-wrap clearfix"> | 1 | <div class="time-opr-wrap clearfix"> |
| 2 | <div class="float-left time-opr-area"> | 2 | <div class="float-left time-opr-area"> |
| 3 | - <div class="time-opr-nowtime">2018/07/13</div> | 3 | + <div class="time-opr-nowtime" id="time-opr-nowtime"></div> |
| 4 | <div class="time-opr-btnwrap clearfix"> | 4 | <div class="time-opr-btnwrap clearfix"> |
| 5 | - <div class="time-opr-btn time-opr-prevbtn cursorpointer float-left">上一周</div> | ||
| 6 | - <div class="time-opr-btn time-opr-nextbtn cursorpointer float-left">下一周</div> | 5 | + <div class="time-opr-btn time-opr-prevbtn cursorpointer float-left" id="time-opr-prevbtn">上一周</div> |
| 6 | + <div class="time-opr-btn time-opr-nextbtn cursorpointer float-left display-none" id="time-opr-nextbtn">下一周</div> | ||
| 7 | </div> | 7 | </div> |
| 8 | </div> | 8 | </div> |
| 9 | - <div class="float-right time-opr-show text-center"> | ||
| 10 | - 2018/07/04 - 2018/07/11 | ||
| 11 | - </div> | 9 | + <div class="float-right time-opr-show text-center" id="time-opr-show"> </div> |
| 12 | </div> | 10 | </div> |
| 13 | -<div>1</div> | ||
| 14 | \ No newline at end of file | 11 | \ No newline at end of file |
| 12 | +<div>1</div> | ||
| 13 | + | ||
| 14 | +<script src="../topages/workfill/workfill.js"></script> | ||
| 15 | \ No newline at end of file | 15 | \ No newline at end of file |
topages/workfill/workfill.js
| 1 | /** | 1 | /** |
| 2 | * Created by mac on 18/7/25. | 2 | * Created by mac on 18/7/25. |
| 3 | */ | 3 | */ |
| 4 | +var weekOfday = Number(moment().format('E'));//计算今天是这周第几天 | ||
| 5 | +var clicknum = 0;//定义上下周点击次数 | ||
| 6 | +var fun = { | ||
| 7 | + init:function () { | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + //获取本周时间 | ||
| 11 | + $('#time-opr-show').text(moment().subtract('days', weekOfday-1).format('YYYY/MM/DD')+' - '+moment().subtract('days', 0).format('YYYY/MM/DD')); | ||
| 12 | + // 获取今天时间 | ||
| 13 | + var todaytime = moment().subtract('days', 0).format('YYYY/MM/DD'); | ||
| 14 | + $('#time-opr-nowtime').text(todaytime); | ||
| 15 | + }, | ||
| 16 | + timeoprprevbtn:function () { | ||
| 17 | + $('#time-opr-nextbtn').removeClass('display-none'); | ||
| 18 | + clicknum ++; | ||
| 19 | + console.log(clicknum) | ||
| 20 | + var start = weekOfday+7*clicknum-1; | ||
| 21 | + var end = weekOfday+ clicknum*7-7; | ||
| 22 | + $('#time-opr-show').text(moment().subtract('days', start).format('YYYY/MM/DD')+' - '+moment().subtract('days',end).format('YYYY/MM/DD')); | ||
| 23 | + }, | ||
| 24 | + timeoprnextbtn:function () { | ||
| 25 | + | ||
| 26 | + clicknum --; | ||
| 27 | + console.log(clicknum) | ||
| 28 | + if(clicknum == 0){ | ||
| 29 | + $('#time-opr-show').text(moment().subtract('days', weekOfday-1).format('YYYY/MM/DD')+' - '+moment().subtract('days', 0).format('YYYY/MM/DD')); | ||
| 30 | + $('#time-opr-nextbtn').addClass('display-none'); | ||
| 31 | + }else{ | ||
| 32 | + var start = weekOfday+7*clicknum-1; | ||
| 33 | + var end = weekOfday+ clicknum*7-7; | ||
| 34 | + $('#time-opr-show').text(moment().subtract('days', start).format('YYYY/MM/DD')+' - '+moment().subtract('days',end).format('YYYY/MM/DD')); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + }, | ||
| 39 | +}; | ||
| 40 | +fun.init(); | ||
| 41 | +// 上一周点击time-opr-prevbtn | ||
| 42 | +$('#time-opr-prevbtn').on('click',function () { | ||
| 43 | + fun.timeoprprevbtn(); | ||
| 44 | +}); | ||
| 45 | +// 下一周点击time-opr-nextbtn | ||
| 46 | +$('#time-opr-nextbtn').on('click',function () { | ||
| 47 | + fun.timeoprnextbtn(); | ||
| 48 | +}); | ||
| 4 | \ No newline at end of file | 49 | \ No newline at end of file |