纸通宝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.
 

126 lines
4.2 KiB

// pages/process/order-check/index.js
import Dialog from '../../../components/dialog/dialog'
import { pricingOrder, cancelOrder, getFactoryOrderInfo, getPaperList} from "../../../api/saas"
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
paperList: null,
form: null,
deductType: 1,
columns: [],
visible: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({ title: '正在获取', mask: true })
getPaperList().then(result => {
this.data.paperList = result.data.records
this.data.columns = []
for (let index = 0; index < this.data.paperList.length; index++) {
this.data.columns.push(this.data.paperList[index].name)
}
this.setData({ safeBottom: app.globalData.safeBottom, columns: this.data.columns })
}).catch(err => {
wx.hideLoading()
this.setData({ safeBottom: app.globalData.safeBottom })
util.showToast(err)
})
getFactoryOrderInfo(options.id).then(result => {
wx.hideLoading()
this.setData({ form: result.data })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
showPlate: function (e) {
this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard')
this.keyboard.show(this.data.form.plateNumber, 0)
},
onPlatenumber: function({detail}){
if(detail && detail.plateNumber){
this.setData({ ['form.plateNumber']: detail.plateNumber })
}
},
showCategory: function(){
this.setData({ visible: true })
},
onConfirm: function({detail}){
this.data.form.productId = this.data.paperList[detail.index].categoryId
this.setData({ visible: false, ['form.productCategoryName']: detail.value })
},
onHide: function(){
this.setData({ visible: false })
},
changeDeductType: function(e){
if(Number(e.currentTarget.dataset.type) == 1){
this.setData({ deductType: e.currentTarget.dataset.type, ['form.deductPercent']: null })
} else {
this.setData({ deductType: e.currentTarget.dataset.type, ['form.deductWeight']: null })
}
},
bindInput: function (e) {
this.data.form[e.target.id] = e.detail.value
},
paddingOrder: function(){
this.setData({ ['form.isWithoutTare']: !this.data.form.isWithoutTare })
},
cancelOrder: function(e){
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => {
wx.showLoading({ title: '处理中', mask: true })
cancelOrder(this.data.form.id).then(result => {
wx.hideLoading()
util.showBackToast('订单已经删除')
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
})
},
priceOrder: function(){
if(util.isEmpty(this.data.form.productId) || Number(this.data.form.productId) <= 0){
util.showToast('请选择废纸品类')
return
}
if(util.isEmpty(this.data.form.unitPrice) || Number(this.data.form.unitPrice) <= 0){
util.showToast('请输入单价')
return
}
if(this.data.deductType == 1 && (util.isEmpty(this.data.form.deductWeight) || Number(this.data.form.deductWeight) <= 0)){
util.showToast('请输入扣重')
return
}
if(this.data.deductType == 2 && (util.isEmpty(this.data.form.deductPercent) || Number(this.data.form.deductPercent) <= 0)){
util.showToast('请输入扣点')
return
}
wx.showLoading({ title: '处理中', mask: true })
pricingOrder(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('定价成功')
event.emit('OrderMessage', { what: 12, desc: 'pricingOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
viewImage: function (e) {
var imgList = []
for (let index = 0; index < this.data.form.preWeighingPicture.length; index++) {
imgList.push(this.data.this.data.form.preWeighingPicture[index].url)
}
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url })
}
})