// pages/process/order-check/index.js import Scene from '../../index/scene' import { repeatSideOrder, getPaperList, getSideOrderInfo} from "../../../api/saas" const event = require('../../../utils/event') const util = require('../../../utils/util') const math = require('../../../utils/math') const app = getApp() Scene({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, paperList: null, form: null, columns: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.id){ wx.showLoading({ title: '正在获取', mask: true }) getPaperList({pageNum: 1, pageSize: 100}).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, paperList: this.data.paperList }) }).catch(err => { this.setData({ safeBottom: app.globalData.safeBottom }) util.showToast(err) }) getSideOrderInfo({ id: options.id }).then(result => { wx.hideLoading() result.data.sign = 1 if(Number(result.data.deductPercent) <= 0){ result.data.deductPercent = null } this.data.amout = math.times(result.data.settleWeight, result.data.unitPrice) this.setData({ form: result.data, amout: this.data.amout }) }).catch(err => { wx.hideLoading() util.showToast(err) }) } }, onProductChange: function({detail}){ this.data.form.productCategoryInfos[detail.index] = detail.item var estimatedAmount = 0 for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) { const element = this.data.form.productCategoryInfos[index] if(!util.isEmpty(element.settlePrice) && Number(element.settlePrice) > 0){ estimatedAmount = math.plus(estimatedAmount, element.settlePrice) } } this.setData({ ['form.settleTotalAmount']: estimatedAmount.toFixed(2) }) }, checkOrder: function(){ var weightNoteList = [] for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) { const element = this.data.form.productCategoryInfos[index] if(util.isEmpty(element.settleUnitPrice) || Number(element.settleUnitPrice) <= 0){ util.showToast('请输入第' + (index + 1) + '项废纸品类结算单价') return } var item = {grossWeight: element.grossWeight, tareWeight: element.tareWeight,weightNoteImage: element.weightNoteImage } item.scrapPaperPurchaseOrderId = element.scrapPaperPurchaseOrderId weightNoteList.push(item) } repeatSideOrder({ id: this.data.form.id, editOrderPriceDto: data }).then(result => { wx.hideLoading() event.emit('OrderMessage', { what: 12, desc: 'repeatSideOrder' }) util.showBackToast('订单审核已通过') }).catch(err => { wx.hideLoading() util.showToast(err) }) } })