// pages/workDetail/workDetail.js var app = getApp() Page({ data: { iconShow: false, //是否显示图标弹窗 commitShow: false, //上报组长 inpShow: true, //显示输入框还是显示完成 detail: [], one: false, two: false, three: false, four: false, id: '', value: '', screenHeight: '', //屏幕可视高度 alarmShow: false, //是否显示警报弹窗【true 显示 false 不显示】 topNum: 0, //返回顶部 alarmState: 0, // 【0 限制警报类型 1 不限制报警类型】 page: 1, //当前页面 skipDetail: false, }, onLoad: function (options) { var that = this; that.setData({ screenHeight: app.globalData.screenHeight, }) that.setData({ id: options.id }) that.status(); }, input: function (e) { this.setData({ value: e.detail.value }); }, status: function () { wx.showLoading({ title: '加载中...', }) var that = this; app.request('work_order/workOrderDetail?work_order_id=' + that.data.id, '', 'GET').then(res => { console.log(res); wx.hideLoading(); that.setData({ detail: res.data, skipDetail: true }) if (res.data.planned == 4) { that.setData({ one: true, two: true, three: true, four: true }) } else if (res.data.planned == 3) { that.setData({ one: true, two: true, three: true }) } else if (res.data.planned == 2) { that.setData({ one: true, two: true }) } else if (res.data.planned == 1) { that.setData({ one: true }) } }) }, /** * 查看警报 */ alarm() { this.setData({ alarmShow: true }); this.getAlarm(); }, getAlarm() { wx.showLoading({ title: '加载中...', }) app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState, '', 'GET').then(res => { wx.hideLoading(); this.setData({ alarmList: res.data }) console.log(res) }) }, closeAlarm() { this.setData({ alarmShow: false }) }, alarmChoose(e) { let state = e.currentTarget.dataset.state; this.setData({ alarmState: state, alarmList: [] }) this.getAlarm(); this.goTop(); }, // moreAlarm() { // let that = this; // var page = that.data.page + 1; // app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState + '&page='+page, '', 'GET').then(res => { // let alarm = res.data // this.setData({ // alarmList: that.data.alarmList.concat(alarm) // }) // }) // }, goTop: function (e) { // 一键回到顶部 this.setData({ topNum: 0 }); }, goHome: function () { if (this.data.skipDetail) { wx.reLaunch({ url: '/pages/logs/logs?bike_no=' + this.data.detail.bike_no, }) }else{ wx.showToast({ title: '页面加载完后再试', icon:'none' }) } }, //打开图标弹窗 openICon() { if (this.data.detail.planned == 4) { wx.showToast({ title: '已完成', icon: 'none' }) } else { this.setData({ iconShow: true }) } }, //关闭图标弹窗 closeIcon() { this.setData({ iconShow: false, commitShow: false, inpShow: false }) }, //领取工单 getWork() { wx.showLoading({ title: '接单中..', }) var that = this; app.request('work_order/receive?work_order_id=' + this.data.id, '', 'GET').then(res => { wx.hideLoading(); that.status() wx.showToast({ title: '接单成功', icon: 'none' }) that.setData({ iconShow: false }) }) }, //上报组长 reported() { this.setData({ commitShow: true, iconShow: false, inpShow: true, }) }, //完成 finish() { this.setData({ iconShow: false, commitShow: true, inpShow: false, }) }, //取消按钮 cancel() { this.setData({ commitShow: false }) }, //确定按钮 submit() { wx.showLoading({ title: '加载中...', }) var that = this; let condition = this.data.inpShow if (condition == true) { //调上报组长接口 var data = { work_order_id: that.data.id, remark: that.data.value } app.request('work_order/upgrade', data, 'POST').then(res => { wx.hideLoading(); console.log(res); wx.showToast({ title: '上报成功', icon: 'none' }) that.setData({ inpShow: false, iconShow: false, commitShow: false }) that.status() }) } else { app.request('work_order/over?work_order_id=' + that.data.id, '', 'GET').then(res => { wx.showToast({ title: '处理完成', icon: 'none' }) that.setData({ inpShow: false, iconShow: false, commitShow: false }) that.status() }) } }, })