// index.js // 获取应用实例 const app = getApp(); const util = require('../../../utils/jmsUtil.js'); const api = require('../../../api/jms.js'); import moment from 'moment' Page({ data: { serviceId:'', keywords:'', wholeList:[], workerList:[], workerId:'', scrollShow:false, orderInfo:{ changeReason:{ label: '请选择(必填)', value:'' }, }, selectValue:'', selectVisible:false, selectKey:'', }, // 事件处理函数 onLoad(options) { if(options.serviceid){ this.setData({ serviceId:options.serviceid }); } this.getWorkerList(); }, getWorkerList(){ util.request(api.ServiceOrderPerson, { pageNo: 1, pageSize: 1000 }, 'POST').then(res=>{ if (res.errno == 0) { this.setData({ wholeList:res.data.list, workerList:res.data.list, }); }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }); }, inputClue(e){ let obj=e.currentTarget.dataset.obj; let item=`clueInfo.${obj}`; this.setData({ [item]:e.detail.value }); // console.log(this.data.clueInfo); }, selectClue(e){ let obj=e.currentTarget.dataset.obj; this.setData({ selectKey:obj, selectVisible:true }); console.log(this.data.selectKey); }, onPickerConfirm(e){ console.log(e); let obj={ label:e.detail.value.text, value:e.detail.value.value } this.setData({ 'orderInfo.changeReason':obj, selectVisible:false }); }, onPickerCancel(){ this.setData({ selectVisible:true }); }, inputWorker(e){ // console.log(e); let keyworks=e.detail.value; let list=this.data.wholeList; let newList=[]; if(keyworks==''){ newList=this.data.wholeList; this.setData({ workerId:'' }); }else{ list.forEach(item=>{ if(item.name.indexOf(keyworks)>-1){ newList.push(item); } }); } this.setData({ workerList:newList }); }, selectWorker(){ this.setData({ scrollShow:true }); }, workerTap(e){ let id=e.currentTarget.dataset.id; let name=e.currentTarget.dataset.name; this.setData({ workerId:id, keywords:name, scrollShow:false, }) }, confTap(){ if(this.data.workerId==''){ wx.showToast({ title: '请选择服务者', icon:'none' }); }else{ wx.showLoading({ title: '加载中', }) let params={ serviceId: this.data.serviceId, tempWorkerId: this.data.workerId, } util.request(api.SelectServiceOrderPerson, params , 'POST').then(res=>{ wx.hideLoading(); if (res.errno == 0) { wx.showModal({ title: '提示', content: '操作成功', showCancel:false, complete: (res) => { if (res.cancel) { } if (res.confirm) { wx.navigateBack({ delta:1 }); } } }) }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }).catch(err=>{ wx.hideLoading(); }); } }, })