/** * Created by mac on 18/7/25. */ var weekOfday = Number(moment().format('E'));//计算今天是这周第几天 var clicknum = 0;//定义上下周点击次数 var fun = { init:function () { //debugger; $("#loginName").text(fn.getUserName()); //初始化项目 $('.work-projectName').selectpicker('render'); //获取本周时间 $('#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); // fun.logout(); //获取项目 fun.getAsraProject(); }, 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')); } }, //退出 logout:function(){ $(document).on('click','#logoutId',function(){ fn.loginOut(); }); }, /***获取项目下拉框.*/ getAsraProject:function(){ //debugger; fn.getAsraProject("",function(data){ var html=""; $.each(data,function(index,row){ html+=''; }); if(html != null && html != ""){ for(var i=1;i<8;i++){ $("#work-projectName"+i).empty(); $("#work-projectName"+i).append(html); $("#work-projectName"+i).selectpicker('refresh'); } } }); } }; fun.init(); // 上一周点击time-opr-prevbtn $('#time-opr-prevbtn').on('click',function () { fun.timeoprprevbtn(); }); // 下一周点击time-opr-nextbtn $('#time-opr-nextbtn').on('click',function () { fun.timeoprnextbtn(); }); //提交事件 $(document).on('click','.workfill-list-btn',function () { var _this=$(this); if(_this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon').hasClass('display-none')){ _this.text('提交'); _this.parent().parent().find(".workfill-list-container").attr("contenteditable","true"); }else { _this.text('编辑'); _this.parent().parent().find(".workfill-list-container").attr("contenteditable","false"); } _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon').toggleClass('display-none'); var projectName=_this.parent().parent().find('.workfill-list-projectnamewrap .workfill-projectCon .work-projectName').find("option:selected").text(); _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-list-projectname').toggleClass('display-none'); _this.parent().parent().find('.workfill-list-projectnamewrap .workfill-list-projectname').text(projectName); });