123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- var util = require('../../../util/util.js')
- import request from '../../../util/http'
- import apiUrl1 from '../../../util/apiUrl1'
- import apiUrl from '../../../util/apiUrl'
- 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 }],
- taskList: [],
- servantName: '',//保姆姓名
- weekday: '',//日前
- servantTypeValue: '',//保姆工种,
- cost: "",
- taskId: "",
- incompleteReason: 1,
- buttonsText: [
- { text: '取消' },
- { text: '确认选择', extClass: 'buttonBold' },
- ],
- },
- onLoad() {
- //加载选中的时间
- let that=this;
- that.getWeekStartDate(this.data.nowselectTime);
- that.setnowweek();
- this.selectDayTaskItem();
- //this.selectDayTaskCost();
- this.homelist();//计算家庭数量
- },
- setnowweek(){
- 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'
- }
- else{
- data[i].date=this.data.weekdate[i];
- data[i].day=this.data.weekdateday[i];
- data[i].cssName=''
- }
- }
- this.setData({
- datelist: data,
- servantName: app.globalData.servantInfo.employerName,
- weekday: app.globalData.servantInfo.servantTaskPeriod.workDay,
- servantTypeValue: app.globalData.servantInfo.servantType
- });
- },
- showcancel(e) {
- this.setData({
- showcancelbox: true,
- taskId: e.target.dataset.id
- });
- console.log(this.data.taskId);
- },
- showyes(e) {
- console.log(e.target.dataset.id);
- let id = e.target.dataset.id;
- request.httpServicePost(apiUrl1.servantTaskSubmitPath, { id: id, state: 1 }).then(data => {
- my.alert({
- title: '提示',
- content: '提交完成',
- buttonText: '确定',
- success: () => {
- this.selectDayTaskItem();
- }
- });
- });
- },
- 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);
- this.nowYear = this.now.getFullYear(); //当前年
- this.nowMonth = this.now.getMonth(); //当前月
- this.nowDay = this.now.getDate(); //当前日
- this.setData({
- nowDay: this.nowDay
- });//保存当前日
- this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
- let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek));
- 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
- })
- },
- changeWeekTime(e) {
- //切换选中的样式
- let weeklist=this.data.datelist;
- let selectedtabid=e.target.dataset.id;
- for(let i=0;i<weeklist.length;i++){
- if(weeklist[i].id==selectedtabid){
- weeklist[i].cssName="tik-week-item-select";
- }else{
- weeklist[i].cssName="";
- }
- }
- //设置当前选中的时间
- this.setData({
- nowselectTime:e.target.dataset.value,
- datelist:weeklist
- });
- this.selectDayTaskItem();
- //this.selectDayTaskCost();
- },
-
- showtime(){
- this.setData({
- showchangetime: true,
- });
- },
- //日历选中
- handleSelect(e) {
- this.setData({
- nowselectTime:util.formatDate(e[0]),
- showchangetime:false,
- nowDay:new Date(util.formatDate(e[0])).getDay()
- });
- this.getWeekStartDate(util.formatDate(e[0]));
- this.setnowweek();
- this.selectDayTaskItem();
- //this.selectDayTaskCost();
- },
- // 查询保姆每日任务
- selectDayTaskItem() {
- let params = {
- "employRelationNo": app.globalData.employRelationNo,
- "date": this.data.nowselectTime
- }
- request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
- // 未设置任务
- if (data.servantTasks.length == 0) {
- this.setData({
- isreminds: false,
- workDay: true,
- isremindscose:false
- });
- } else {
- //判断是否是休息日
- if(data.workDay){
- // 今天有任务
- this.setData({
- taskList: data,
- isreminds: true,
- workDay: true,
- isremindscose:true
- });
- }else{ //今天休息
- this.setData({
- workDay: false,
- isremindscose:false
- });
- }
- }
- }
- ).catch(e => {
- console.log(e);
- })
- },
- //今日花销合计
- bindKeyInput(e) {
- let costval=e.detail.value;
- if ((/^[0-9]*$/.test(e.detail.value))) {
- this.setData({
- cost: costval,
- costvalue:costval
- });
- }else{
- this.setData({
- cost: costval,
- costvalue:null
- });
- }
- },
- //提交保姆今日花销
- createServant() {
- let employRelationNo = app.globalData.employRelationNo;
- let date = this.data.nowselectTime;
- let cost = this.data.cost;
- request.httpServicePost(apiUrl1.insertDailyCostPath, { employRelationNo: employRelationNo, spendDate: date, cost: cost }).then(data => {
- my.alert({
- title: '提示',
- content: '提交完成',
- buttonText: '确定',
- success: () => {
- my.navigateBack();
- }
- });
- });
- },
- swiperChange(e) {
- console.log(e.detail.value);
- this.setData({
- incompleteReason: e.detail.value,
- });
- },
- switchList(){
- my.navigateTo({
- url: '../myCustomerList/myCustomerList'
- });
- },
- //计算家庭数量
- homelist(){
- let params={
- "servantId":app.globalData.userInfo.id,
- "pageNo": 1,
- "pageSize": 100,
- }
- request.httpServicePost(apiUrl.findByServantIdListPath,params).then(data=>{
- console.log('多个家庭:'+data);
- if(data.dataList.length>1){
- this.setData({
- homecssname:true
- });
- }else{
- this.setData({
- homecssname:false
- });
- }
- }).catch(e=>{
- console.log(e);
- })
- },
- hidecnacelbox() {
- this.setData({
- showcancelbox: false
- });
- },
- //确定提交任务
- confirmbox() {
- let id = this.data.taskId;
- let incompleteReason = this.data.incompleteReason;
- request.httpServicePost(apiUrl1.servantTaskSubmitPath, { id: id, state: 2, incompleteReason: incompleteReason }).then(data => {
- my.alert({
- title: '提示',
- content: '提交完成',
- buttonText: '确定',
- success: () => {
- this.setData({
- showcancelbox: false
- });
- this.selectDayTaskItem();
- }
- });
- });
- },
- onReasonModalClick(e){
- if(e.target.dataset.index==0){
- this.setData({
- showcancelbox: false
- });
- }else{
- this.confirmbox();
- }
- }
- });
|