import request from '../../../util/http' import apiUrl from '../../../util/apiUrl' var app = getApp(); Page({ data: { allList: [] }, onLoad(options) { console.log(options); }, onShow() { this.initDailyTaskList(); }, initDailyTaskList() { let params = { } request.httpServiceGet(apiUrl.getDailyTaskList, params).then(data => { console.log(data); if (data.length > 0) { this.setData({ allList: data }); } else { this.setData({ allList: [] }); // my.alert({ // content:JSON.stringify(data.dataList) // }); } }).catch(e => { console.log(e); }) }, toggleWashinGandnursing(e) { // let id = e.target.dataset.id; let currentIndex= e.target.dataset.index; console.log('index=' + currentIndex); // console.log(id.currentIndex); let id=e.target.dataset.id; let isNew=this.data.allList[currentIndex].every(item=>{return id!=item.id}); if(isNew){ let newArr=this.data.allList[currentIndex]; let obj={ index:id, } newArr.push(obj); let newArrClass=this.data.allList[currentIndex]; newArrClass.push(id); this.setData({ workSelectedList:newArr, workSelectedClassList:newArrClass }) }else{ let spliceIndex=''; this.data.workSelectedList.forEach((item,index)=> { if(item.index==id){ console.log(item,index); spliceIndex=index; return; } }) let newArr=this.data.workSelectedList; let newArrClass=this.data.workSelectedClassList; newArr.splice(spliceIndex,1); newArrClass.splice(newArrClass.indexOf(id),1); this.setData({ workSelectedList:newArr, workSelectedClassList:newArrClass }) } }, dailytasksdeit() { /** * { "employRelationNo": "string", "taskItems": [ { "categoryId": 0, "itemIds": [ "string" ] } ] } */ let params = { } request.httpServicePost(apiUrl.completeEditDailyTask, params).then(data => { console.log(data); }).catch(e => { console.log(e); }) }, });