// home/pages/dispatch/dispatch.js const { dispatch,selectDispatchEngineer } = require("../../../api/api"); Page({ data: { radio:'', name:'',//员工姓名 staffLists:[],//员工列表 }, onLoad(options) { this.setData({ entryId:options.projectId }); this.getStaffList(); }, onReady() { }, onShow() { }, /** 搜索输入事件 **/ keyWordsChange(e) { this.setData({ name: e.detail, }); }, /** 搜索 **/ keyWordsSearch(e){ this.getStaffList(); }, /** 员工列表 **/ getStaffList(){ selectDispatchEngineer({ userId:wx.getStorageSync('userId'), name:this.data.name }).then(res=>{ if(res.code==200){ this.setData({ staffLists:res.data }); }else{ wx.showToast({ title: res.msg, icon:'none' }) } }); }, /** 单选 **/ onChange(event) { this.setData({ radio: event.detail, }); }, /** 单选点击 **/ onClick(event) { const { name } = event.currentTarget.dataset; this.setData({ radio: name, }); }, /** 返回 **/ back(e) { wx.navigateBack(); }, /** 提交 **/ submit(){ if(!this.data.radio){ wx.showToast({ title: '请先选择安装师傅', icon:'none' }) return; } dispatch({ userId:wx.getStorageSync('userId'), entryId:this.data.entryId, engineerIds:[this.data.radio], }).then(res=>{ if(res.code==200){ wx.showToast({ title: '派工成功', icon:'none' }) setTimeout(()=>{ wx.navigateBack(); },1500); }else{ wx.showToast({ title: res.errMsg, icon:'none' }) } }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })