|
@@ -1,5 +1,6 @@
|
|
|
import request from '../../../util/http'
|
|
|
import apiUrl from '../../../util/apiUrl'
|
|
|
+import apiUrl1 from '../../../util/apiUrl1'
|
|
|
var app = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
@@ -11,93 +12,79 @@ Page({
|
|
|
onShow() {
|
|
|
this.initDailyTaskList();
|
|
|
},
|
|
|
+ //数据加载
|
|
|
initDailyTaskList() {
|
|
|
let params = {
|
|
|
}
|
|
|
request.httpServiceGet(apiUrl.getDailyTaskList, params).then(data => {
|
|
|
- console.log(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: data
|
|
|
+ allList: dailytasklist
|
|
|
});
|
|
|
} 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,
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ allList: dailytasklist
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- })
|
|
|
- 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 employRelationNo = app.globalData.employRelationNo;
|
|
|
+ let dailytasklist=[];
|
|
|
+ for(let i=0;i<this.data.allList.length;i++){
|
|
|
+ let itemIds='';
|
|
|
+ for(let j=0;j<this.data.allList[i].TaskItems.length;j++){
|
|
|
+ if(this.data.allList[i].TaskItems[j].checked){
|
|
|
+ itemIds += '"'+this.data.allList[i].TaskItems[j].id+'"' +',';
|
|
|
+ }
|
|
|
}
|
|
|
- */
|
|
|
- let params = {
|
|
|
+ itemIds=itemIds.substring(0,itemIds.length - 1);
|
|
|
+ dailytasklist.push({categoryId:this.data.allList[i].categoryId,itemIds:[itemIds]});
|
|
|
}
|
|
|
- request.httpServicePost(apiUrl.completeEditDailyTask, params).then(data => {
|
|
|
- console.log(data);
|
|
|
-
|
|
|
- }).catch(e => {
|
|
|
- console.log(e);
|
|
|
-
|
|
|
- })
|
|
|
+ request.httpServicePost(apiUrl1.createDayTaskItem,{employRelationNo:employRelationNo,taskItems:dailytasklist}).then(data=>{
|
|
|
+ my.alert({
|
|
|
+ title: '提示',
|
|
|
+ content: '保存完成',
|
|
|
+ buttonText: '确定',
|
|
|
+ success: () => {
|
|
|
+ my.navigateBack();
|
|
|
+ }
|
|
|
+ } );
|
|
|
+ });
|
|
|
},
|
|
|
});
|