Blame view

topages/workfill/workfill.js 2.79 KB
d34df23d   liuqimichale   头部公用
1
2
3
  /**
   * Created by mac on 18/7/25.
   */
7552bd7a   liuqimichale   填报--- 时间操作
4
5
6
7
8
  var weekOfday = Number(moment().format('E'));//计算今天是这周第几天
  var clicknum = 0;//定义上下周点击次数
  var fun = {
      init:function () {
  
7dd4675c   Andy   add 工时填报添加插件
9
10
          //初始化项目
          $('.work-projectName').selectpicker('render');
7552bd7a   liuqimichale   填报--- 时间操作
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
          //获取本周时间
          $('#time-opr-show').text(moment().subtract('days', weekOfday-1).format('YYYY/MM/DD')+' - '+moment().subtract('days', 0).format('YYYY/MM/DD'));
          // 获取今天时间
          var todaytime  = moment().subtract('days', 0).format('YYYY/MM/DD');
          $('#time-opr-nowtime').text(todaytime);
      },
      timeoprprevbtn:function () {
          $('#time-opr-nextbtn').removeClass('display-none');
          clicknum ++;
          console.log(clicknum)
          var start = weekOfday+7*clicknum-1;
          var end = weekOfday+ clicknum*7-7;
          $('#time-opr-show').text(moment().subtract('days', start).format('YYYY/MM/DD')+' - '+moment().subtract('days',end).format('YYYY/MM/DD'));
      },
      timeoprnextbtn:function () {
  
          clicknum --;
          console.log(clicknum)
          if(clicknum == 0){
              $('#time-opr-show').text(moment().subtract('days', weekOfday-1).format('YYYY/MM/DD')+' - '+moment().subtract('days', 0).format('YYYY/MM/DD'));
              $('#time-opr-nextbtn').addClass('display-none');
          }else{
              var start = weekOfday+7*clicknum-1;
              var end = weekOfday+ clicknum*7-7;
              $('#time-opr-show').text(moment().subtract('days', start).format('YYYY/MM/DD')+' - '+moment().subtract('days',end).format('YYYY/MM/DD'));
          }
  
  
      },
  };
  fun.init();
  // 上一周点击time-opr-prevbtn
  $('#time-opr-prevbtn').on('click',function () {
      fun.timeoprprevbtn();
  });
  // 下一周点击time-opr-nextbtn
  $('#time-opr-nextbtn').on('click',function () {
      fun.timeoprnextbtn();
e2a48bfd   Andy   add
49
  });
d8c028fb   Andy   编辑 提交 切换
50
  
e2a48bfd   Andy   add
51
  //提交事件
d8c028fb   Andy   编辑 提交 切换
52
  $(document).on('click','.workfill-list-btn',function () {
e2a48bfd   Andy   add
53
      var _this=$(this);
d8c028fb   Andy   编辑 提交 切换
54
      if(_this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon').hasClass('display-none')){
d199cade   Andy   add
55
          _this.text('提交');
d8c028fb   Andy   编辑 提交 切换
56
          _this.parent().parent().find(".workfill-list-container").attr("contenteditable","true");
d199cade   Andy   add
57
58
      }else {
          _this.text('编辑');
d8c028fb   Andy   编辑 提交 切换
59
          _this.parent().parent().find(".workfill-list-container").attr("contenteditable","false");
d199cade   Andy   add
60
61
      }
      _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon').toggleClass('display-none');
d8c028fb   Andy   编辑 提交 切换
62
      var projectName=_this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon .work-projectName').find("option:selected").text();
d199cade   Andy   add
63
      _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-list-projectname').toggleClass('display-none');
d8c028fb   Andy   编辑 提交 切换
64
65
      _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-list-projectname').text(projectName);
  
e2a48bfd   Andy   add
66
67
  
  });