Browse Source

订单产品移除部分字段 修改数量受起订量增量控制

xiaohaizhao 2 years ago
parent
commit
13579ce533

+ 21 - 8
packageA/orderForm/modules/product/list/index.js

@@ -1,3 +1,5 @@
+import currency from "../../../../../utils/currency";
+
 Component({
 	properties: {
 		list: Array,
@@ -17,19 +19,30 @@ Component({
 				data,
 				name
 			} = e.currentTarget.dataset;
-			if (name == 'qty' && e.detail.value == 0) {
-				this.setData({
-					list: this.data.list
-				})
-				return wx.showToast({
-					title: '商品数量不可为0!',
-					icon: "none"
+			if (name == 'qty') {
+				if (data.orderminqty > e.detail.value) {
+					wx.showToast({
+						title: '输入数量低于最低起订量!',
+						icon: "none"
+					})
+					data.qty = data.orderminqty;
+				} else if (data.orderminqty < e.detail.value) {
+					var currencyRounding = value => currency(value, {
+						increment: data.orderaddqty
+					});
+					data.qty = currency(currencyRounding(currency(e.detail.value).subtract(data.orderminqty)).format()).add(data.orderminqty).value;
+				} else {
+					data.qty = e.detail.value;
+				}
+				let i = this.data.list.findIndex(v => v.sa_orderitemsid == data.sa_orderitemsid);
+				if (i != -1) this.setData({
+					[`list[${i}].qty`]: data.qty
 				})
 			}
 			this.triggerEvent("changeProduct", {
 				sa_orderitemsid: data.sa_orderitemsid,
 				itemid: data.itemid,
-				qty: name == 'qty' ? e.detail.value : data.qty,
+				qty: data.qty,
 				remarks: name == 'remarks' ? e.detail.value : data.remarks,
 				needdate: data.needdate || "",
 				deliverydate: data.deliverydate || ""

+ 2 - 6
packageA/orderForm/modules/product/list/index.wxml

@@ -19,14 +19,10 @@
                     <text class="line-1" style="margin-right: 6rpx;">型号:{{item.model||' --'}}</text>
                     <text class="line-1">规格:{{item.spec||' --'}}</text>
                 </view>
-                <view class="subfield">
+                <!-- <view class="subfield">
                     <text class="line-1" style="margin-right: 6rpx;">材质:{{item.material||' --'}}</text>
                     <text class="line-1">标准:{{item.standards||' --'}}</text>
-                </view>
-                <view class="subfield">
-                    <text class="line-1" style="margin-right: 6rpx;">已发数量:{{item.deliedqty||' --'}}</text>
-                    <text class="line-1" style="margin-right: 6rpx;">可退数量:{{item.returnqty||' --'}}</text>
-                </view>
+                </view> -->
                 <view style="margin-top: 8rpx;">
                     <text class="price">{{handleHide.query(item.price,hidePrice)}}</text>
                     <!-- <text class="old-price">{{handleHide.query(item.marketprice,hidePrice)}}</text> -->