1004749546@qq.com hace 4 años
padre
commit
1b6bd73e2a
Se han modificado 1 ficheros con 11 adiciones y 9 borrados
  1. 11 9
      pages/order/waitOrderDetail.vue

+ 11 - 9
pages/order/waitOrderDetail.vue

@@ -28,13 +28,13 @@
 					<view>重量(kg)</view>
 					<view>合计金额(元)</view>
 				</view>
-				<view v-if="list.length && list[curIndex].typeList.length" v-for="item in list[curIndex].typeList" :key="item.id" class="item flex justify_between align_center">
+				<view v-if="list.length && list[curIndex].typeList.length" v-for="(item,index) in list[curIndex].typeList" :key="item.id" class="item flex justify_between align_center">
 					<view class="flex align_center">
 						<text class="item-name">{{item.name}}</text>
-						<u-input type="digit" @input="numberToFixed(item,'customerPrice',2)" :custom-style="inputLeftStyle" input-align="center" :clearable="false" v-model="item.customerPrice" placeholder="输入单价" />
+						<u-input type="digit" @input="numberToFixed(item,'customerPrice',index)" :custom-style="inputLeftStyle" input-align="center" :clearable="false" v-model="item.customerPrice" placeholder="输入单价" />
 					</view>
 					<view class="flex flex_1 align_center">
-						<u-input type="digit" @input="numberToFixed(item,'rubbishWeight',2)" :custom-style="inputRightStyle" input-align="center" :clearable="false" v-model="item.rubbishWeight" placeholder="请输入重量" />
+						<u-input type="digit" @input="numberToFixed(item,'rubbishWeight',index)" :custom-style="inputRightStyle" input-align="center" :clearable="false" v-model="item.rubbishWeight" placeholder="请输入重量" />
 					</view>
 					<view class="flex_1 flex align_center justify_center">{{item.totalAmount}}</view>
 				</view>
@@ -126,11 +126,13 @@
 				if(this.list.length){
 					this.list.map(item =>{
 						item.typeList.map(k =>{
-							total = total + (k.customerPrice*k.rubbishWeight)
+							if(k.totalAmount){
+								total = total + Number(k.totalAmount)
+							}
 						})
 					})
 				} 
-				return total.toFixed(2)
+				return total
 			},
 			// 总重量
 			totalWeight() {
@@ -138,7 +140,7 @@
 				if(this.list.length){
 					this.list.map(item =>{
 						item.typeList.map(k =>{
-							total = total + k.rubbishWeight
+							total = total + Number(k.rubbishWeight) 
 						})
 					})
 				} 
@@ -147,12 +149,12 @@
 		},
 		methods: {
 			// 小数点后两位
-			numberToFixed: function (item,key, num) {
+			numberToFixed: function (item,key, index) {
 			  let val = item[key]
-			  let ret = numberToFixed(val, num, 999999)
+			  let ret = numberToFixed(val, 2, 999999)
 			  this.$nextTick(() => {
 				item[key] = Number(ret)
-				item.totalAmount = (item.customerPrice * item.rubbishWeight).toFixed(2)
+				item.totalAmount = item.customerPrice ?(item.customerPrice * item.rubbishWeight).toFixed(2) : 0
 			  })
 			},
 			// 打电话