// pages/loadAppoint/allocationIndex.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { showModal: false, defaultText: '请选择', isSubmitting: false, str:' ', loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false, roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '', searchVal: '', //分页 limit: 10, requestStatu: '加载中...', page: 1, totalPages: 1, more: false, nomore: '', resData:[], show: false, loadPointId:'',//起卸地点 loadTimeId:'',//起卸时段 loadPointArray:[],//装卸点位 loadPointIndex:null, loadTimeArray:[], //装卸时间 loadTimeIndex:null, loadUserArray:[], //执行员 loadUserIndex:null, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ appointId : options.appointId, }) //起卸点位 this.getAllocationListFun() }, //列表 getAllocationListFun: function () { this.setData({ page: 1 }) let params = { current : this.data.page, size : this.data.limit, appointId : this.data.appointId, appointType : '1' } app.request.pageFirst({ url: app.API.bizloaddispatchPage, page: this, params: params, }) }, //装卸点位 loadPointData:function(){ app.request.GET({ url: app.API.loadPoint, params: {'appointType' : '1'}, page: this, successFun: true }).then(res => { this.setData({ loadPointArray:res.data.data }) }) }, //装卸时间 loadTimeData:function(){ app.request.GET({ url: app.API.loadTimeNow, params: { pointId : this.data.loadPointArray[this.data.loadPointIndex].id, }, page: this, successFun: true }).then(res => { let timeList = res.data.data timeList.forEach((element,index) => { timeList[index].time = element.beginTime + '~' + element.endTime }); this.setData({ loadTimeArray : timeList }) }) }, //装卸时间 loadUserData:function(){ app.request.GET({ url: app.API.roleUser, params: { roleName : '起卸员', }, page: this, successFun: true }).then(res => { this.setData({ loadUserArray:res.data.data }) }) }, //下拉选择 bindPickerChange: function (e) { //下拉菜单 let { pickername } = e.target.dataset let getIndex = pickername + 'Index' app.util.getPickerIndex(this, getIndex, e); switch (pickername) { case 'loadPoint': //客户 this.loadTimeData() //获取起卸时段 break; } }, // 添加S showPopup(e) { let { id, loadPoint, loadTime, userId } = e.currentTarget.dataset this.setData({ show: true, id: id, loadPointId:loadPoint,//起卸地点 loadTimeId:loadTime,//起卸时段 userId:userId }); this.loadPointData() this.loadUserData() }, onClose() { this.setData({ show: false, id: '', loadPointId:'',//起卸地点 loadTimeId:'',//起卸时段 userId:'',//执行员 }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, //页面跳转 toLink: function (e) { let { url } = e.currentTarget.dataset wx.navigateTo({ url: url }) }, //表单提交 carTaskAdd formSubmitAllocation: function ({detail:{value}}) { var warn = ""; //弹框时提示的内容 if (value.loadPointId == '') { warn = "请选择装卸点位!"; } else if(value.loadTimeId == ''){ warn = "请选择装卸时间!"; } else if(value.userId == ''){ warn = "请选择执行员!"; } if (warn != '') { app.util.checkForm(warn); } else { app.request.POST({ url: app.API.appointAdd, params: value, page: this, isLoadingTxt: '提交中...', isSubmitting: true, successFun: true }).then(res => { wx.showToast({ title: '新增成功', icon: 'success', duration: 2000, mask:true, complete: function () { setTimeout(() => { wx.navigateBack() }, 1500) //延迟时间 } }) }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ searchVal: '' }) if (wx.getStorageSync('loginStatus')) { this.getAllocationListFun(); } else { wx.stopPullDownRefresh(); } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.data.page++; let params = { current : this.data.page, size : this.data.limit, appointId : this.data.appointId, appointType : '1' } app.request.pageFirst({ url: app.API.bizloaddispatchPage, page: this, params: params, loadType: true //加载类型,是否是下拉加载 }); }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })