From 7406a26385de35015dd188bc0a9e79a429edfde4 Mon Sep 17 00:00:00 2001 From: chenxuhui Date: Fri, 23 Nov 2018 09:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E8=B4=A7=E4=BB=B7=E6=A0=BC=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/saleForecastList/newBill/newBill.js | 59 ++++++++++++++++++----- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/pages/saleForecastList/newBill/newBill.js b/pages/saleForecastList/newBill/newBill.js index b06d15c..6ae81e2 100644 --- a/pages/saleForecastList/newBill/newBill.js +++ b/pages/saleForecastList/newBill/newBill.js @@ -170,25 +170,57 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function() { - console.log(app.globalData.customerArray); + var that = this; + + // 返回的用户只能是一条,所以index只能为0 var customerArr = app.globalData.customerArray; - if (customerArr.length > 0){ + if (customerArr.length > 0) { this.setData({ customer: customerArr, - customerIndex:0, + customerIndex: 0, }) } - + + // 获取存货 加载完成后计算价格政策 var goodsArr = app.globalData.goodsNameArray; if (goodsArr.length > 0) { let backGoodsArr = []; - for (var i = 0; i < goodsArr.length; i++){ + for (var i = 0; i < goodsArr.length; i++) { + + var name = goodsArr[i].Goods_Name; + var id = goodsArr[i].SaleGoods_ID; + var pp = goodsArr[i].PolicyPrice; + var price = goodsArr[i].Price; + var mainUnitRatio = goodsArr[i].Goods_MainUnitRatio; + var secondUnitRatio = goodsArr[i].Goods_SecondUnitRatio; + var unitConvertDirection = goodsArr[i].Goods_UnitConvertDirection; + var rightRatio = goodsArr[i].RightRatio; + var leftRatio = goodsArr[i].LeftRatio; + + if (pp == null){ + pp =Number(0); + } + if (rightRatio == null) { + rightRatio = Number(1); + } + if (leftRatio == null) { + leftRatio = Number(1); + } + let goodsNameObj = { - Goods_Name: goodsArr[i].Goods_Name, - Goods_ID: goodsArr[i].SaleGoods_ID, + Goods_MainUnitRatio: Number(mainUnitRatio), + Goods_SecondUnitRatio: Number(secondUnitRatio), + SaleGoods_ID: Number(id), + Goods_Name: name, + Price: Number(price), + PolicyPrice: Number(pp), + Goods_UnitConvertDirection: Number(unitConvertDirection), + RightRatio: rightRatio, + LeftRatio: leftRatio, } backGoodsArr.push(goodsNameObj) } + this.setData({ obj: backGoodsArr, }) @@ -223,15 +255,17 @@ Page({ } }, + // 添加地址 getAddrs: function(e) { this.data.addrs = e.detail.value; }, + // 添加存货 跳转存货选择页面 add: function(e) { - var that =this; + var that = this; let unitID = that.data.unit[that.data.isUnit].ID; let customerID = that.data.customer[that.data.customerIndex].ID; - if (unitID && customerID){ + if (unitID && customerID) { wx.navigateTo({ url: '../../goodaNameChooseTemplate/goodaNameChooseTemplate?unitID=' + unitID + '&customerID' + customerID, }) @@ -243,7 +277,8 @@ Page({ } }, - getCustomerItem: function(){ + // 添加购货客户 跳转客户选择页面 + getCustomerItem: function() { wx.navigateTo({ url: '../../customerChooseTemplate/customerChooseTemplate', }) @@ -384,11 +419,12 @@ Page({ showModalStatus: false, }) }, + // 选取货物后进行价格计算 itemclick1: function(e) { var that = this; var name = e.currentTarget.dataset.name; var id = e.currentTarget.dataset.data.SaleGoods_ID; - var pp = e.currentTarget.dataset.policyprice; + var pp = e.currentTarget.dataset.PolicyPrice; var price = e.currentTarget.dataset.data.Price; var Goods_MainUnitRatio = e.currentTarget.dataset.data.Goods_MainUnitRatio var Goods_SecondUnitRatio = e.currentTarget.dataset.data.Goods_SecondUnitRatio @@ -412,6 +448,7 @@ Page({ obj: that.data.obj }) }, + select: function(e) { var that = this; var which = e.currentTarget.dataset.item;