Browse Source

任务编辑

yangyongyong 4 years ago
parent
commit
e7048e0da5

+ 6 - 6
client/app.json

@@ -6,22 +6,22 @@
     "pages/servant/servantCenter/servantCenter",
     "pages/customer/createServant/createServant",
     "pages/customer/dailytasks/dailytasks",
-     "pages/customer/servantdetail/servantdetail",
+    "pages/customer/servantdetail/servantdetail",
     "pages/servant/servantdetail/servantdetail",
     "pages/customer/customerCenter/customerCenter",
     "pages/common/selectRole/selectRole",
     "pages/customer/monthReport/monthReport",
     "pages/customer/editServant/editServant",
-     "pages/customer/taskreminder/taskreminder",
+    "pages/customer/taskreminder/taskreminder",
     "pages/servant/taskreminder/taskreminder",
     "pages/servant/servantlist/servantlist",
     "pages/common/userGuide/userGuide",
-    "pages/servant/servantsettings/servantsettings"
+    "pages/servant/servantsettings/servantsettings",
+    "pages/servant/servantedit/servantedit"
   ],
   "window": {
     "defaultTitle": "保姆管家",
-    "navigationBarTextStyle":"black",
-    "titleBarColor":"#F3F3F3"
-
+    "navigationBarTextStyle": "black",
+    "titleBarColor": "#F3F3F3"
   }
 }

+ 2 - 2
client/pages/customer/dailytasks/dailytasks.axml

@@ -1,9 +1,9 @@
 <view class="common-page-padding daily-servant-page">
-  <view a:for="{{allList}}" key="{{index}}"
+  <view a:for="{{allList}}" key="{{index}}">
     <view class="common-card dailyitem">
       <view class="cell-title">{{item.categoryName}}</view>
       <view class="daily-list">
-        <view a:for="{{item.TaskItems}}" class="daily-item {{item.TaskItems.indexOf(item.index)!=-1 ?'work-item-selected':''}}" a:for-index='sdddd' key="{{index}}" data-id="{{item.id}}" data-index="{{index}}" onTap="toggleWashinGandnursing">{{item.itemName}}</view>
+        <view a:for="{{item.TaskItems}}"  a:for-item="dailyitem" class="daily-item {{dailyitem.checked==true ?'daily-item-selected':''}}" a:for-item="dailyitem" a:for-index='sdddd' key="{{index}}" data-id="{{dailyitem.id}}" data-index="{{dailyitem.categoryId}}" onTap="toggleWashinGandnursing">{{dailyitem.itemName}}</view>
       </view>
     </view>
   </view>

+ 51 - 64
client/pages/customer/dailytasks/dailytasks.js

@@ -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();
+        }
+      } );
+    });
   },
 });

+ 2 - 23
client/pages/servant/servantlist/servantlist.axml

@@ -1,28 +1,7 @@
 <view class="common-page-padding servantlistpage">
 <!---服务列表-->
-  <view class="servantlistitem">
-     <view class="servantlistitem-left">打扫类</view>
-     <view class="servantlistitem-right">
-      <image mode="scaleToFill" src="/image/icon-right.png"/>
-     </view>
-  </view>
-  <view class="servantlistitem">
-     <view class="servantlistitem-left">做饭类</view>
-     <view class="servantlistitem-right">
-      <image mode="scaleToFill" src="/image/icon-right.png"/>
-     </view>
-  </view>
-  <view class="servantlistitem">
-     <view class="servantlistitem-left">
-      打扫类
-      <label class="noset">未设置</label>
-     </view>
-     <view class="servantlistitem-right">
-      <image mode="scaleToFill" src="/image/icon-right.png"/>
-     </view>
-  </view>
-  <view class="servantlistitem">
-     <view class="servantlistitem-left">做饭类</view>
+  <view class="servantlistitem" a:for="{{servantlist}}" key="{{index}}" data-id="{{item.subtypeNo}}" onTap="toEditPage">
+     <view class="servantlistitem-left">{{item.subjectType}}</view>
      <view class="servantlistitem-right">
       <image mode="scaleToFill" src="/image/icon-right.png"/>
      </view>

+ 32 - 1
client/pages/servant/servantlist/servantlist.js

@@ -1,4 +1,35 @@
+import request from '../../../util/http'
+import apiUrl from '../../../util/apiUrl1'
+import util from '../../../util/util'
+import moment from 'moment'
+var app = getApp();
 Page({
   data: {},
-  onLoad() {},
+  onLoad() {
+    this.loadpage();
+  },
+  loadpage(){
+    let params = {}
+    request.httpServiceGet(apiUrl.getSubjectWhenEdit, params).then(data => {
+      if (data.length > 0) {
+        //添加选中的状态列
+        let servantlist = data;
+        this.setData({
+          servantlist: servantlist
+        });
+      } else {
+        this.setData({
+          servantlist: []
+        });
+      }
+    }).catch(e => {
+      console.log(e);
+    })
+  },
+  toEditPage(e){
+    let subtypeNo=e.target.dataset.id;
+    my.navigateTo({
+      url: '../servantedit/servantedit?subtypeNo='+subtypeNo
+    });
+  },
 });

+ 7 - 2
client/util/apiUrl1.js

@@ -3,9 +3,14 @@ let baseService='/servantappletservice';
 const servantappletservicePath = baseService+'/servantlove/getSubjectWhenFirst';
 //新设置服务标准
 const insertNewservantappletservicePath = baseService+'/servantlove/insertNewServantLove';
+//设置每日任务
+const createDayTaskItem = baseService+'/taskItem/createDayTaskItem';
+//编辑时获取已选择的题目答案
+const getSubjectWhenEdit = baseService+'/servantlove/getSubjectWhenEdit';
 
 export default{
 servantappletservicePath,
 insertNewservantappletservicePath,
-}
-
+createDayTaskItem,
+getSubjectWhenEdit,
+}