// pages/storage/index/index.js import Scene from '../../index/scene' import Dialog from '../../../components/dialog/dialog' import { getOutOrderInfo, auditOutOrder } from "../../../api/saas" const util = require('../../../utils/util') const event = require('../../../utils/event') const app = getApp() Scene({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, form: null, poundInfo: null, orderInfo: null, activeNames: [], fileList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.id){ wx.showLoading({ title: '正在获取', mask: true }) getOutOrderInfo(options.id).then(result => { result.data.weightNote.emptyWeighingPicture = [] if(result.data.weightNote.firstWeightImageUrls1){ result.data.weightNote.emptyWeighingPicture.push(result.data.weightNote.firstWeightImageUrls1) } if(result.data.weightNote.firstWeightImageUrls2){ result.data.weightNote.emptyWeighingPicture.push(result.data.weightNote.firstWeightImageUrls2) } result.data.weightNote.totalWeighingPicture = [] if(result.data.weightNote.secondWeightImageUrls1){ result.data.weightNote.totalWeighingPicture.push(result.data.weightNote.secondWeightImageUrls1) } if(result.data.weightNote.secondWeightImageUrls2){ result.data.weightNote.totalWeighingPicture.push(result.data.weightNote.secondWeightImageUrls2) } if(result.data.outboundDeliveryOrderSettlementInfo){ this.data.fileList = [] if(result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr){ for (let index = 0; index < result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr.length; index++) { const element = result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr[index] this.data.fileList.push({ url: element}) } } this.setData({ safeBottom: app.globalData.safeBottom, poundInfo: result.data.weightNote, orderInfo: result.data.outboundDeliveryOrder, form: result.data.outboundDeliveryOrderSettlementInfo, fileList: this.data.fileList }) } else { this.setData({ safeBottom: app.globalData.safeBottom, poundInfo: result.data.weightNote, orderInfo: result.data.outboundDeliveryOrder }) } wx.hideLoading() }).catch(err => { wx.hideLoading() util.showToast(err) }) } }, onChange: function({detail}) { this.setData({ activeNames: detail }) }, submitForm: function(e){ if(e.currentTarget.id == 'refuse'){ Dialog.confirm({ title: '温馨提示', message: '确定此出货单有问题,进行驳回?' }).then(() => { wx.showLoading({ title: '正在处理', mask: true }) auditOutOrder({id: this.data.form.id, auditStatus: 0 }).then(result => { wx.hideLoading() util.showBackToast('出货单已经驳回') event.emit('OrderMessage', { what: 21, desc: 'cancelOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) }) } else { wx.showLoading({ title: '正在处理', mask: true }) auditOutOrder({id: this.data.form.id, auditStatus: 1 }).then(result => { wx.hideLoading() util.showBackToast('出货单已经通过审核') event.emit('OrderMessage', { what: 21, desc: 'cancelOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) } }, settleForm: function(){ wx.redirectTo({ url: `/pages/storage/order-settlement/index?id=${this.data.orderInfo.id}` }) } })