|
|
@ -1,6 +1,6 @@ |
|
|
// pages/process/order-check/index.js
|
|
|
// pages/process/order-check/index.js
|
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import Dialog from '../../../components/dialog/dialog' |
|
|
import { pricingOrder, cancelOrder, getFactoryOrderInfo, getPaperPrice} from "../../../api/saas" |
|
|
|
|
|
|
|
|
import { pricingOrder, cancelOrder, getFactoryOrderInfo, getPaperList} from "../../../api/saas" |
|
|
const event = require('../../../utils/event') |
|
|
const event = require('../../../utils/event') |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
@ -23,10 +23,16 @@ Page({ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
if(options.id){ |
|
|
if(options.id){ |
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
getPaperPrice().then(result => { |
|
|
|
|
|
this.setData({ safeBottom: app.globalData.safeBottom, paperList: result.data }) |
|
|
|
|
|
|
|
|
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 => { |
|
|
}).catch(err => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
|
|
|
this.setData({ safeBottom: app.globalData.safeBottom }) |
|
|
util.showToast(err) |
|
|
util.showToast(err) |
|
|
}) |
|
|
}) |
|
|
getFactoryOrderInfo(options.id).then(result => { |
|
|
getFactoryOrderInfo(options.id).then(result => { |
|
|
@ -50,33 +56,30 @@ Page({ |
|
|
showCategory: function(){ |
|
|
showCategory: function(){ |
|
|
this.setData({ visible: true }) |
|
|
this.setData({ visible: true }) |
|
|
}, |
|
|
}, |
|
|
onConfirm: function({ picker, value, index }){ |
|
|
|
|
|
this.setData({ visible: false }) |
|
|
|
|
|
|
|
|
onConfirm: function({detail}){ |
|
|
|
|
|
this.data.form.productId = this.data.paperList[detail.index].categoryId |
|
|
|
|
|
this.setData({ visible: false, ['form.productCategoryName']: detail.value }) |
|
|
}, |
|
|
}, |
|
|
onHide: function(){ |
|
|
onHide: function(){ |
|
|
this.setData({ visible: false }) |
|
|
this.setData({ visible: false }) |
|
|
}, |
|
|
}, |
|
|
changeDeductType: function(e){ |
|
|
changeDeductType: function(e){ |
|
|
if(e.currentTarget.dataset.type == 1){ |
|
|
|
|
|
this.setData({ deductType: e.currentTarget.dataset.type, [form.deductPercent]: null }) |
|
|
|
|
|
|
|
|
if(Number(e.currentTarget.dataset.type) == 1){ |
|
|
|
|
|
this.setData({ deductType: e.currentTarget.dataset.type, ['form.deductPercent']: null }) |
|
|
} else { |
|
|
} else { |
|
|
this.setData({ deductType: e.currentTarget.dataset.type, [form.deductWeight]: null }) |
|
|
|
|
|
|
|
|
this.setData({ deductType: e.currentTarget.dataset.type, ['form.deductWeight']: null }) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
bindInput: function (e) { |
|
|
bindInput: function (e) { |
|
|
this.data.form[e.target.id] = e.detail.value |
|
|
this.data.form[e.target.id] = e.detail.value |
|
|
}, |
|
|
}, |
|
|
onChange: function({ detail }) { |
|
|
|
|
|
// 需要手动对 checked 状态进行更新
|
|
|
|
|
|
this.setData({ ['form.isDefault']: detail ? 1 : 0 }) |
|
|
|
|
|
}, |
|
|
|
|
|
paddingOrder: function(){ |
|
|
paddingOrder: function(){ |
|
|
this.setData({ ['form.weighingType']: !this.data.form.weighingType }) |
|
|
|
|
|
|
|
|
this.setData({ ['form.isWithoutTare']: !this.data.form.isWithoutTare }) |
|
|
}, |
|
|
}, |
|
|
cancelOrder: function(e){ |
|
|
cancelOrder: function(e){ |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => { |
|
|
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => { |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
cancelOrder({ id: this.data.form.id }).then(result => { |
|
|
|
|
|
|
|
|
cancelOrder(this.data.form.id).then(result => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
util.showBackToast('订单已经删除') |
|
|
util.showBackToast('订单已经删除') |
|
|
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) |
|
|
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) |
|
|
@ -87,6 +90,22 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
priceOrder: function(){ |
|
|
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 }) |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
pricingOrder(this.data.form).then(result => { |
|
|
pricingOrder(this.data.form).then(result => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |