fuxubing 4 年 前
コミット
a16173b078

+ 76 - 87
client/pages/servant/taskreminder/taskreminder.axml

@@ -1,87 +1,76 @@
 <view class="tasks-page">
-<!---客户信息-->
-    <view class="tasks-head">
-      <view class="cell-title">
-        <label>王阿姨</label>
-        <view class="cell-right">
-          <image mode="scaleToFill" src="/image/switch-grey.png"/>
-          <label>切换到其他家庭</label>
-        </view>
+  <!---客户信息-->
+  <view class="tasks-head">
+    <view class="cell-title">
+      <label>王阿姨</label>
+      <view class="cell-right">
+        <image mode="scaleToFill" src="/image/switch-grey.png"/>
+        <label>切换到其他家庭</label>
       </view>
-      <view class="cell-list">
-        <label>周一▪</label>
-        <label>周二▪</label>
-        <label>周三▪</label>
-        <label>周四▪</label>
-        <label>周五▪</label>
-        <label>周六▪</label>
-        <label>周日</label>
-      </view>
-        <view class="cell-type">
-          保姆工种:<label>钟点工</label>
+    </view>
+    <view class="cell-list">
+      <label>周一▪</label>
+      <label>周二▪</label>
+      <label>周三▪</label>
+      <label>周四▪</label>
+      <label>周五▪</label>
+      <label>周六▪</label>
+      <label>周日</label>
+    </view>
+    <view class="cell-type">
+          保姆工种:
+      <label>钟点工</label>
+    </view>
+  </view>
+  <!---一周任务查看器-->
+  <view class="tasks-line">
+    <view class="common-page-padding tasks-tik">
+      <view class="tik-title">
+        <label>今天</label>
+        <view class="tik-right" onTap="showtime">
+          <image mode="scaleToFill" src="/image/icon-calendar.png"/>
+          <label>查看其它日期</label>
         </view>
       </view>
-      <!---一周任务查看器-->
-    <view class="tasks-line">
-      <view class="common-page-padding tasks-tik">
-        <view class="tik-title">
-          <label>今天</label>
-          <view class="tik-right" onTap="showtime">
-            <image mode="scaleToFill" src="/image/icon-calendar.png"/>
-            <label>查看其它日期</label>
-          </view>
-        </view>
-        <view class="tik-week" a:for="{{datelist}}" key="{{index}}">
-          <view class="tik-week-item {{item.cssName}}" onTap="changeWeekTime"  data-id="{{id}}">
-            <view>{{item.title}}</view>
-            <view>{{item.day}}
+      <view class="tik-week" a:for="{{datelist}}" key="{{index}}">
+        <view class="tik-week-item {{item.cssName}}" onTap="changeWeekTime" data-id="{{id}}">
+          <view>{{item.title}}</view>
+          <view>{{item.day}}
             <text a:if={{item.cssName}}>\n▪</text>
-            </view>
           </view>
         </view>
       </view>
-      <!--任务列表-->
-      <view class="common-page-padding tasks-list">
-        <view class="cell-title">
-          <label>任务提醒</label>
-          <view class="tik-right">
-            <image mode="scaleToFill" src="/image/icon-edit.png"/>
-            <label>编辑每日任务</label>
-          </view>
-        </view>
-        <!--有提醒任务-->
-        <view a:if="{{isreminds}}">
-          <view class="tasks-list-item">
-            <text>洗衣服</text>
-            <view class="tasks-item-yes">
-              <image mode="scaleToFill" src="/image/icon-yes.png"/>
-            </view>
-            <view class="tasks-item-no" onTap="showcancel">
-              <image mode="scaleToFill" src="/image/icon-no.png"/>
-            </view>
+    </view>
+    <!--任务列表-->
+    <view class="common-page-padding tasks-list">
+      <view class="cell-title">
+        <label>任务提醒</label>
+        <!--<view class="tik-right"><image mode="scaleToFill" src="/image/icon-edit.png"/><label>编辑每日任务</label></view> -->
+      </view>
+      <!--有提醒任务-->
+      <view a:if="{{isreminds}}">
+        <view class="tasks-list-item" a:for="{{taskList}}" key="{{index}}">
+          <text a:if="{{item.state == 0}}"> {{item.itemName}}</text>
+          <view class="tasks-item-yes" a:if="{{item.state == 0}}">
+            <image mode="scaleToFill" src="/image/icon-yes.png"/>
           </view>
-          <view class="tasks-list-item">
-            <text>做完饭</text>
-            <view class="tasks-item-yes">
-              <image mode="scaleToFill" src="/image/icon-yes.png"/>
-            </view>
-            <view class="tasks-item-no" onTap="showcancel">
-              <image mode="scaleToFill" src="/image/icon-no.png"/>
-            </view>
+          <view class="tasks-item-no" onTap="showcancel" a:if="{{item.state == 0}}">
+            <image mode="scaleToFill" src="/image/icon-no.png"/>
           </view>
-          <view class="tasks-list-item">
-            打扫卧室
+          <view class="tasks-list-item" a:if="{{item.state == 1}}">
+            <text> {{item.itemName}}</text>
+            <image src="/image/icon-yes.png"/>
           </view>
-          <view class="tasks-list-item">
-            <text>打扫房间</text>
-            <label  class="nogood">任务不详细</label>
+          <view class="tasks-list-item" a:if="{{item.state == 2}}">
+            <text> {{item.itemName}}</text>
+            <label class="nogood">{{item.incompleteReason}}</label>
             <view class="tasks-item-yes">
               <image mode="scaleToFill" src="/image/icon-no.png"/>
             </view>
           </view>
         </view>
         <!--没有任务-->
-        <view  a:if="{{!isreminds}}">
+        <view a:if="{{!isreminds}}">
           <view class="notasks">
             <text>还没有任务</text>
           </view>
@@ -91,34 +80,34 @@
       <view a:if="{{isreminds}}" class="tast-moneybox">
         <view class="tasks-list-money">
           <view class="tasks-list-pay">今日花销合计</view>
-          <view class="tasks-list-pay-right"><input placeholder="请输入"/><text>元</text></view>
+          <view class="tasks-list-pay-right">
+            <input placeholder="请输入"/>
+            <text>元</text></view>
         </view>
-         <view class="tasks-set">
-          <button type="primary"  hover-class="active-button"  onTap="createServant">提交</button>
+        <view class="tasks-set">
+          <button type="primary" hover-class="active-button" onTap="createServant">提交</button>
         </view>
       </view>
     </view>
-  <!---弹出日历--->
-  <modal show="{{showchangetime}}">
-    <calendar
-    type="single"
-    onSelect="handleSelect" />
-  </modal>
-  <!--弹出取消原因-->
-  <modal show="{{showcancelbox}}">
-    <view class="cancel-box">
+    <!---弹出日历--->
+    <modal show="{{showchangetime}}">
+      <calendar type="single" onSelect="handleSelect" />
+    </modal>
+    <!--弹出取消原因-->
+    <modal show="{{showcancelbox}}">
+      <view class="cancel-box">
         <text>取消原因</text>
         <radio-group class="radio-group weui-input">
-          <label a:for="{{cancellist}}"  a:key={{value}}>
+          <label a:for="{{cancellist}}" a:key={{value}}>
             <radio value="{{item.value}}" class="radio" checked="{{item.checked}}"/>{{item.label}}
           </label>
         </radio-group>
-    </view>
-    <view class="am-modal-buttons--vertical" onTap="hidecnacelbox" >
+      </view>
+      <view class="am-modal-buttons--vertical" onTap="hidecnacelbox">
       取消
-    </view>
-    <view class="am-modal-buttons--vertical">
+      </view>
+      <view class="am-modal-buttons--vertical">
       确认选择
-    </view>
-  </modal>
-</view>
+      </view>
+    </modal>
+  </view>

+ 77 - 44
client/pages/servant/taskreminder/taskreminder.js

@@ -1,61 +1,66 @@
 var util = require('../../../util/util.js')
+import request from '../../../util/http'
+import apiUrl1 from '../../../util/apiUrl1'
+var app = getApp();
 Page({
   data: {
-    showchangetime:false,
-    nowselectTime:util.formatDate(new Date()),
-    datelist:[{title:"周一",date:0,cssName:'',id:1,day:0},{title:"周二",date:0,cssName:'',id:2,day:0},{title:"周三",date:0,cssName:'',id:3,day:0},{title:"周四",date:0,cssName:'',id:4,day:0},{title:"周五",date:0,cssName:'',id:5,day:0},{title:"周六",date:0,cssName:'',id:6,day:0},{title:"周天",date:0,cssName:'',id:7,day:0}],
-    isreminds:true,
-    showcancelbox:false,
-    cancellist:[{value:'1', label:'任务太多', checked:true},{value:'2', label:'我不会', checked:false},{value:'3', label:'任务不详细', checked:false}]
+    showchangetime: false,
+    nowselectTime: util.formatDate(new Date()),
+    datelist: [{ title: "周一", date: 0, cssName: '', id: 1, day: 0 }, { title: "周二", date: 0, cssName: '', id: 2, day: 0 }, { title: "周三", date: 0, cssName: '', id: 3, day: 0 }, { title: "周四", date: 0, cssName: '', id: 4, day: 0 }, { title: "周五", date: 0, cssName: '', id: 5, day: 0 }, { title: "周六", date: 0, cssName: '', id: 6, day: 0 }, { title: "周天", date: 0, cssName: '', id: 7, day: 0 }],
+    isreminds: true,
+    showcancelbox: false,
+    cancellist: [{ value: '1', label: '任务太多', checked: true }, { value: '2', label: '我不会', checked: false }, { value: '3', label: '任务不详细', checked: false }],
+    taskList: [],
   },
   onLoad() {
     //加载选中的时间
     console.log(this.data.nowselectTime);
-    let that=this;
+    let that = this;
     that.getWeekStartDate(this.data.nowselectTime);
     let data = this.data.datelist;
-    for(let i=0;i<7;i++){
-      if(this.data.weekdateday[i]==this.data.nowDay){
-        data[i].date=this.data.weekdate[i];
-        data[i].day=this.data.weekdateday[i];
-        data[i].cssName='tik-week-item-select'
+    for (let i = 0; i < 7; i++) {
+      if (this.data.weekdateday[i] == this.data.nowDay) {
+        data[i].date = this.data.weekdate[i];
+        data[i].day = this.data.weekdateday[i];
+        data[i].cssName = 'tik-week-item-select'
       }
-      else{
-        data[i].date=this.data.weekdate[i];
-        data[i].day=this.data.weekdateday[i];
+      else {
+        data[i].date = this.data.weekdate[i];
+        data[i].day = this.data.weekdateday[i];
       }
     }
     this.setData({
       datelist: data
     });
     //处理时间完成
+     this.selectDayTaskItem();
   },
-  showcancel(){
+  showcancel() {
     this.setData({
       showcancelbox: true
     });
   },
-  hidecnacelbox(){
-     this.setData({
+  hidecnacelbox() {
+    this.setData({
       showcancelbox: false
     });
   },
-  dateAdd:function(startDate,days) {
-  startDate = new Date(startDate);
-  startDate = +startDate + days * 1000 * 60 * 60 * 24;
-  startDate = new Date(startDate);
-  //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
-  return startDate.getDate();
-},
-  datedayAdd:function(startDate,days) {
-  startDate = new Date(startDate);
-  startDate = +startDate + days * 1000 * 60 * 60 * 24;
-  startDate = new Date(startDate);
-  var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
-  
-  return nextStartDate;
-},
-   //获取本周的开始日期
+  dateAdd: function (startDate, days) {
+    startDate = new Date(startDate);
+    startDate = +startDate + days * 1000 * 60 * 60 * 24;
+    startDate = new Date(startDate);
+    //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
+    return startDate.getDate();
+  },
+  datedayAdd: function (startDate, days) {
+    startDate = new Date(startDate);
+    startDate = +startDate + days * 1000 * 60 * 60 * 24;
+    startDate = new Date(startDate);
+    var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
+
+    return nextStartDate;
+  },
+  //获取本周的开始日期
   getWeekStartDate(nowday) {
     let that = this;
     this.now = new Date(nowday);
@@ -63,30 +68,58 @@ Page({
     this.nowMonth = this.now.getMonth(); //当前月 
     this.nowDay = this.now.getDate(); //当前日 
     this.setData({
-      nowDay:this.nowDay
+      nowDay: this.nowDay
     });//保存当前日
     this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天 
     let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1));
-    
-    let weekdateday=[this.dateAdd(dateStart,0),this.dateAdd(dateStart,1),this.dateAdd(dateStart,2),this.dateAdd(dateStart,3),this.dateAdd(dateStart,4),this.dateAdd(dateStart,5),this.dateAdd(dateStart,6)];
-    let weekdate=[this.datedayAdd(dateStart,0),this.datedayAdd(dateStart,1),this.datedayAdd(dateStart,2),this.datedayAdd(dateStart,3),this.datedayAdd(dateStart,4),this.datedayAdd(dateStart,5),this.datedayAdd(dateStart,6)];
+
+    let weekdateday = [this.dateAdd(dateStart, 0), this.dateAdd(dateStart, 1), this.dateAdd(dateStart, 2), this.dateAdd(dateStart, 3), this.dateAdd(dateStart, 4), this.dateAdd(dateStart, 5), this.dateAdd(dateStart, 6)];
+    let weekdate = [this.datedayAdd(dateStart, 0), this.datedayAdd(dateStart, 1), this.datedayAdd(dateStart, 2), this.datedayAdd(dateStart, 3), this.datedayAdd(dateStart, 4), this.datedayAdd(dateStart, 5), this.datedayAdd(dateStart, 6)];
     this.setData({
       weekdate: weekdate,
-      weekdateday:weekdateday
+      weekdateday: weekdateday
     })
 
   },
-  changeWeekTime(e){
+  changeWeekTime(e) {
     console.log(e.target.id);
-    let changetime=e.target;
+    let changetime = e.target;
   },
-  
-  showtime(){
+
+  showtime() {
     this.setData({
       showchangetime: true,
     });
   },
   handleSelect(e) {
-      console.log(e[0]);
+    console.log(e[0]);
+  },
+
+  // 查询保姆每日任务
+  selectDayTaskItem() {
+    let params = {
+      "employRelationNo": app.globalData.employRelationNo,
+      "date": this.data.nowselectTime
+    }
+    request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
+      console.log(data);
+      // 未设置任务
+      if (data == null) {
+        this.setData({
+          isreminds: false,
+        });
+      } else {
+        // 今天有任务
+        this.setData({
+          taskList: data,
+        });
+      }
+    }
+
+    ).catch(e => {
+      console.log(e);
+
+    })
   },
+
 });