纸通宝SAAS仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

104 lines
3.6 KiB

// pages/storage/index/index.js
import Scene from '../../index/scene'
import Dialog from '../../../components/dialog/dialog'
import { getPoundInfo, repeatPound, deletePound } from "../../../api/saas"
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
form: null,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({ title: '正在获取', mask: true })
getPoundInfo(options.id).then(result => {
wx.hideLoading()
result.data.emptyWeighingPicture = []
if(result.data.firstWeightImageUrl1){
result.data.emptyWeighingPicture.push(result.data.firstWeightImageUrl1)
} else {
result.data.emptyWeighingPicture.push('error')
}
if(result.data.firstWeightImageUrl2){
result.data.emptyWeighingPicture.push(result.data.firstWeightImageUrl2)
} else {
result.data.emptyWeighingPicture.push('error')
}
result.data.totalWeighingPicture = []
if(result.data.secondWeightImageUrl1){
result.data.totalWeighingPicture.push(result.data.secondWeightImageUrl1)
} else if(Number(result.data.secondWeight) > 0){
result.data.totalWeighingPicture.push('error')
}
if(result.data.secondWeightImageUrl2){
result.data.totalWeighingPicture.push(result.data.secondWeightImageUrl2)
} else if(Number(result.data.secondWeight) > 0){
result.data.totalWeighingPicture.push('error')
}
this.setData({ safeBottom: app.globalData.safeBottom, form: result.data })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
repeatForm: function(){
Dialog.confirm({ title: '温馨提示', message: '磅单数据有问题,确定重新过磅?' }).then(() => {
wx.showLoading({ title: '正在处理', mask: true })
repeatPound({id: this.data.form.id}).then(result => {
wx.hideLoading()
util.showBackToast('磅单处理成功')
event.emit('OrderMessage', { what: 20, desc: 'cancelPound' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
})
},
deleteForm: function(){
Dialog.confirm({ title: '温馨提示', message: '确定删除该磅单?' }).then(() => {
wx.showLoading({ title: '正在处理', mask: true })
deletePound({id: this.data.form.id}).then(result => {
wx.hideLoading()
util.showBackToast('磅单已经删除')
event.emit('OrderMessage', { what: 20, desc: 'cancelPound' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
})
},
submitForm: function(){
wx.redirectTo({ url: `/pages/storage/order-create/index?id=${this.data.form.id}` })
},
viewImage: function (e) {
var imgList = []
if(e.currentTarget.dataset.type == 1){
for (let index = 0; index < this.data.form.totalWeighingPicture.length; index++) {
var url = this.data.form.totalWeighingPicture[index]
if(!util.isEmpty(url) && 'error' != url){
imgList.push(url)
}
}
} else {
for (let index = 0; index < this.data.form.emptyWeighingPicture.length; index++) {
var url = this.data.form.emptyWeighingPicture[index]
if(!util.isEmpty(url) && 'error' != url){
imgList.push(url)
}
}
}
if(imgList.length){
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url })
}
}
})