123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import request from '../../../util/http'
- import apiUrl from '../../../util/apiUrl'
- import apiUrl1 from '../../../util/apiUrl1'
- var app = getApp();
- Page({
- data: {
- allList: []
- },
- onLoad(options) {
- console.log(options);
- },
- onShow() {
- this.initDailyTaskList();
- },
- //数据加载
- initDailyTaskList() {
- let params = {
- }
- request.httpServiceGet(apiUrl.getDailyTaskList, params).then(data => {
- if (data.length > 0) {
- //添加选中的状态列
- let dailytasklist = data;
- var that = this;
- for(let i=0;i<dailytasklist.length;i++){
- for(let j=0;j<dailytasklist[i].TaskItems.length;j++){
- dailytasklist[i].TaskItems[j].checked=false;
- }
- }
- this.setData({
- allList: dailytasklist
- });
- } else {
- this.setData({
- allList: []
- });
- }
- }).catch(e => {
- console.log(e);
- })
- },
- //点击选中任务
- toggleWashinGandnursing(e) {
- let currentIndex= e.target.dataset.index;//类型ID
- let id = e.target.dataset.id;//选中当前ID
- let dailytasklist=this.data.allList;
- for(let i=0;i<dailytasklist.length;i++){
- if(dailytasklist[i].categoryId==currentIndex){
- for(let j=0;j<dailytasklist[i].TaskItems.length;j++){
- if(dailytasklist[i].TaskItems[j].id==id){
- if(dailytasklist[i].TaskItems[j].checked){
- dailytasklist[i].TaskItems[j].checked=false;
- }else{
- dailytasklist[i].TaskItems[j].checked=true;
- }
- }
- }
- }
- }
- this.setData({
- allList: dailytasklist
- });
- },
- //提交数据
- dailytasksdeit() {
- let employRelationNo = app.globalData.employRelationNo;
- let dailytasklist=[];
- for(let i=0;i<this.data.allList.length;i++){
- let itemIds=[];
- let t=0;
- for(let j=0;j<this.data.allList[i].TaskItems.length;j++){
- if(this.data.allList[i].TaskItems[j].checked==true){
- itemIds[t]=this.data.allList[i].TaskItems[j].id;
- t++;
- }
- }
- if(itemIds.length>0){
- dailytasklist.push({categoryId:this.data.allList[i].categoryId,itemIds:itemIds});
- }
- }
- request.httpServicePost(apiUrl1.createDayTaskItem,{employRelationNo:employRelationNo,taskItems:dailytasklist}).then(data=>{
- my.alert({
- title: '提示',
- content: '保存完成',
- buttonText: '确定',
- success: () => {
- my.navigateBack();
- }
- } );
- });
- },
- });
|