zhaoxiaohai 2 年 前
コミット
e03a574cc5

+ 31 - 21
packageA/orderForm/detail.js

@@ -29,14 +29,14 @@ Page({
 		this.getDetail(true);
 	},
 	/* 获取详情 */
-	getDetail(init = false) {
+	getDetail(init = false, show = true) {
 		_Http.basic({
 			"id": 20221108151302,
 			"content": {
 				nocache: true,
 				"sa_orderid": this.data.sa_orderid
 			}
-		}).then(res => {
+		}, show).then(res => {
 			console.log("订单详情", res)
 			if (res.msg != '成功') return wx.showToast({
 				title: res.msg,
@@ -317,12 +317,14 @@ Page({
 			icon: "none"
 		})
 		this.setData({
-			"detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
+			"detail.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
 		})
 		let res = await this.changeDetail();
-		if (res.msg != '成功') this.setData({
-			"detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
-		});
+		if (res.msg != '成功') {
+			this.setData({
+				"detail.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
+			});
+		}
 	},
 	/* 删除订单 */
 	deleteItem() {
@@ -363,17 +365,7 @@ Page({
 	},
 	/* 提交订单 */
 	submit() {
-		let that = this,
-			sys_enterpriseid = that.data.detail.sys_enterpriseid,
-			sa_accountclassid = that.data.detail.accountclass.sa_accountclassid;
-		if (!sys_enterpriseid) return wx.showToast({
-			title: '还未选择开票单位',
-			icon: "none"
-		});
-		if (!sa_accountclassid) return wx.showToast({
-			title: '还完成支付信息',
-			icon: "none"
-		});
+		let that = this;
 		wx.showModal({
 			title: '提示',
 			content: '是否确认提交订单?',
@@ -381,9 +373,7 @@ Page({
 				if (res.confirm) _Http.basic({
 					"id": 20221108153402,
 					"content": {
-						sa_orderid: that.data.sa_orderid,
-						sys_enterpriseid,
-						sa_accountclassid
+						sa_orderid: that.data.sa_orderid
 					},
 				}).then(s => {
 					console.log("提交订单", s)
@@ -391,6 +381,9 @@ Page({
 						title: s.msg != '成功' ? s.msg : '提交成功',
 						icon: "none"
 					});
+					if (s.msg == '成功') that.setData({
+						"detail.status": "提交"
+					})
 				})
 			}
 		})
@@ -424,5 +417,22 @@ Page({
 			icon: "none"
 		});
 		return this.data.detail.status != '新建';
-	}
+	},
+	onUnload() {
+		let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
+		let content = page.data.content;
+		content.pageNumber = 1;
+		content.pageSize = page.data.list.length;
+		_Http.basic({
+			"id": 20221224180302,
+			content
+		}).then(res => {
+			console.log("订单列表", res)
+			page.setData({
+				list: res.data,
+				"content.total": res.total,
+				amount: res.tips.amount || 0
+			})
+		})
+	},
 })

+ 2 - 8
packageA/orderForm/detail.wxml

@@ -55,14 +55,6 @@
         </view>
     </navigator>
 
-    <!--   <navigator url="#" class="row">
-        <view class="label">支付账户</view>
-        <view style="font-size: 28rpx;">
-            {{detail.accountclass.accountname || '暂无'}}
-            <van-icon name="arrow" />
-        </view>
-    </navigator> -->
-
     <view class="row">
         <view class="label">支付账户</view>
         <view style="font-size: 28rpx;">
@@ -74,6 +66,8 @@
         <view class="label">是否使用返利金(余额:{{detail.accountclass.rebate_amount}})</view>
         <checkbox disabled="{{detail.status!='新建'}}" checked="{{detail.rebate_used==1}}" color='var(--assist)' />
     </navigator>
+
+
     <view class="row" wx:if="{{detail.rebate_used==1}}">
         <view class="label">返利金支付(最多订单金额20%)</view>
         <input disabled="{{detail.status!='新建'}}" bindtap="isEdit" type="digit" class="remarks" placeholder-class='placeholder' value="{{detail.accountclass.rebate_amount}}" placeholder="使用金额" />

+ 12 - 2
packageA/orderForm/modules/product/index.js

@@ -71,7 +71,9 @@ Component({
 		}) {
 			let obj = detail,
 				index = this.data.list.findIndex(v => v.itemid == detail.itemid),
-				data = this.data.list[index];
+				data = this.data.list[index],
+				calculatePrice = data.qty != obj.qty;
+
 			if (data.qty == obj.qty && data.remarks == obj.remarks && data.needdate == obj.needdate) return;
 			_Http.basic({
 				"id": 20221109093602,
@@ -92,7 +94,15 @@ Component({
 					...data,
 					...obj
 				};
-				if (res.msg == '成功') data.amount = parseInt((data.qty * data.price).toFixed(2))
+				if (res.msg == '成功' && calculatePrice) {
+					let page = getCurrentPages()[getCurrentPages().length - 1];
+					let amount = page.data.detail.amount - data.amount;
+					data.amount = ((data.qty - 0) * (data.price - 0)).toFixed(2);
+					amount = amount + (data.amount - 0);
+					page.setData({
+						"detail.amount": amount
+					})
+				}
 				this.setData({
 					[`list[${index}]`]: data
 				})