dailytasks.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import request from '../../../util/http'
  2. import apiUrl from '../../../util/apiUrl'
  3. var app = getApp();
  4. Page({
  5. data: {
  6. allList: []
  7. },
  8. onLoad(options) {
  9. console.log(options);
  10. },
  11. onShow() {
  12. this.initDailyTaskList();
  13. },
  14. initDailyTaskList() {
  15. let params = {
  16. }
  17. request.httpServiceGet(apiUrl.getDailyTaskList, params).then(data => {
  18. console.log(data);
  19. if (data.length > 0) {
  20. this.setData({
  21. allList: data
  22. });
  23. } else {
  24. this.setData({
  25. allList: []
  26. });
  27. // my.alert({
  28. // content:JSON.stringify(data.dataList)
  29. // });
  30. }
  31. }).catch(e => {
  32. console.log(e);
  33. })
  34. },
  35. toggleWashinGandnursing(e) {
  36. // let id = e.target.dataset.id;
  37. let currentIndex= e.target.dataset.index;
  38. console.log('index=' + currentIndex);
  39. // console.log(id.currentIndex);
  40. let id=e.target.dataset.id;
  41. let isNew=this.data.allList[currentIndex].every(item=>{return id!=item.id});
  42. if(isNew){
  43. let newArr=this.data.allList[currentIndex];
  44. let obj={
  45. index:id,
  46. }
  47. newArr.push(obj);
  48. let newArrClass=this.data.allList[currentIndex];
  49. newArrClass.push(id);
  50. this.setData({
  51. workSelectedList:newArr,
  52. workSelectedClassList:newArrClass
  53. })
  54. }else{
  55. let spliceIndex='';
  56. this.data.workSelectedList.forEach((item,index)=> {
  57. if(item.index==id){
  58. console.log(item,index);
  59. spliceIndex=index;
  60. return;
  61. }
  62. })
  63. let newArr=this.data.workSelectedList;
  64. let newArrClass=this.data.workSelectedClassList;
  65. newArr.splice(spliceIndex,1);
  66. newArrClass.splice(newArrClass.indexOf(id),1);
  67. this.setData({
  68. workSelectedList:newArr,
  69. workSelectedClassList:newArrClass
  70. })
  71. }
  72. },
  73. dailytasksdeit() {
  74. /**
  75. * {
  76. "employRelationNo": "string",
  77. "taskItems": [
  78. {
  79. "categoryId": 0,
  80. "itemIds": [
  81. "string"
  82. ]
  83. }
  84. ]
  85. }
  86. */
  87. let params = {
  88. }
  89. request.httpServicePost(apiUrl.completeEditDailyTask, params).then(data => {
  90. console.log(data);
  91. }).catch(e => {
  92. console.log(e);
  93. })
  94. },
  95. });