taskreminder.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. var util = require('../../../util/util.js')
  2. import apiUrl1 from '../../../util/apiUrl1'
  3. import request from '../../../util/http'
  4. var app = getApp();
  5. Page({
  6. data: {
  7. showchangetime:false,
  8. nowselectTime:util.formatDate(new Date()),
  9. datelist:[{title:"周一",date:0,cssName:'',id:1,day:0},{title:"周二",date:0,cssName:'',id:2,day:0},{title:"周三",date:0,cssName:'',id:3,day:0},{title:"周四",date:0,cssName:'',id:4,day:0},{title:"周五",date:0,cssName:'',id:5,day:0},{title:"周六",date:0,cssName:'',id:6,day:0},{title:"周天",date:0,cssName:'',id:7,day:0}],
  10. isreminds:true,
  11. showcancelbox:false,
  12. cancellist:[{value:'1', label:'任务太多', checked:true},{value:'2', label:'我不会', checked:false},{value:'3', label:'任务不详细', checked:false}],
  13. servantName: '',//保姆姓名
  14. weekday: '',//日前
  15. servantTypeValue: '',//保姆工种,
  16. taskList: [],
  17. },
  18. onLoad() {
  19. //加载选中的时间
  20. console.log(this.data.nowselectTime);
  21. let that=this;
  22. that.getWeekStartDate(this.data.nowselectTime);
  23. let data = this.data.datelist;
  24. for(let i=0;i<7;i++){
  25. if(this.data.weekdateday[i]==this.data.nowDay){
  26. data[i].date=this.data.weekdate[i];
  27. data[i].day=this.data.weekdateday[i];
  28. data[i].cssName='tik-week-item-select'
  29. }
  30. else{
  31. data[i].date=this.data.weekdate[i];
  32. data[i].day=this.data.weekdateday[i];
  33. }
  34. }
  35. this.setData({
  36. datelist: data,
  37. servantName: app.globalData.relationInfo.servantName,
  38. weekday: app.globalData.relationInfo.servantTaskPeriod.workDay,
  39. servantTypeValue: app.globalData.relationInfo.servantType
  40. });
  41. //处理时间完成
  42. this.selectDayTaskItem()
  43. },
  44. showcancel(){
  45. this.setData({
  46. showcancelbox: true
  47. });
  48. },
  49. hidecnacelbox(){
  50. this.setData({
  51. showcancelbox: false
  52. });
  53. },
  54. dateAdd:function(startDate,days) {
  55. startDate = new Date(startDate);
  56. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  57. startDate = new Date(startDate);
  58. //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  59. return startDate.getDate();
  60. },
  61. datedayAdd:function(startDate,days) {
  62. startDate = new Date(startDate);
  63. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  64. startDate = new Date(startDate);
  65. var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  66. return nextStartDate;
  67. },
  68. //获取本周的开始日期
  69. getWeekStartDate(nowday) {
  70. let that = this;
  71. this.now = new Date(nowday);
  72. this.nowYear = this.now.getFullYear(); //当前年
  73. this.nowMonth = this.now.getMonth(); //当前月
  74. this.nowDay = this.now.getDate(); //当前日
  75. this.setData({
  76. nowDay:this.nowDay
  77. });//保存当前日
  78. this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
  79. let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1));
  80. let weekdateday=[this.dateAdd(dateStart,0),this.dateAdd(dateStart,1),this.dateAdd(dateStart,2),this.dateAdd(dateStart,3),this.dateAdd(dateStart,4),this.dateAdd(dateStart,5),this.dateAdd(dateStart,6)];
  81. let weekdate=[this.datedayAdd(dateStart,0),this.datedayAdd(dateStart,1),this.datedayAdd(dateStart,2),this.datedayAdd(dateStart,3),this.datedayAdd(dateStart,4),this.datedayAdd(dateStart,5),this.datedayAdd(dateStart,6)];
  82. this.setData({
  83. weekdate: weekdate,
  84. weekdateday:weekdateday
  85. })
  86. },
  87. changeWeekTime(e){
  88. console.log(e.target.id);
  89. let changetime=e.target;
  90. },
  91. showtime(){
  92. this.setData({
  93. showchangetime: true,
  94. });
  95. },
  96. handleSelect(e) {
  97. console.log(e[0]);
  98. },
  99. // 查询保姆每日任务
  100. selectDayTaskItem() {
  101. let params = {
  102. "employRelationNo": app.globalData.employRelationNo,
  103. "date": this.data.nowselectTime
  104. }
  105. request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
  106. console.log("今日任务=" + data);
  107. // 未设置任务
  108. if (data.length == 0) {
  109. this.setData({
  110. isreminds: false,
  111. });
  112. } else {
  113. // 今天有任务
  114. this.setData({
  115. taskList: data,
  116. });
  117. }
  118. }
  119. ).catch(e => {
  120. console.log(e);
  121. })
  122. },
  123. });