123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- // 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()
- })
- }
- },
- })
|