From 9545a596b9ba3f35e8a528b957d31542f3cf11a5 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期四, 01 九月 2022 16:24:52 +0800
Subject: [PATCH] #

---
 pages/basics/offLines.vue |  197 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 167 insertions(+), 30 deletions(-)

diff --git a/pages/basics/offLines.vue b/pages/basics/offLines.vue
index 661ee50..7875456 100644
--- a/pages/basics/offLines.vue
+++ b/pages/basics/offLines.vue
@@ -1,18 +1,6 @@
 <template>
 	<view>
-		<!-- 鍟嗗搧鐮佽緭鍏ユ -->
-		<view class="square-2">
-			<view class="square-title">
-				<view class="title-sign"><view class="sign"></view></view>
-				<view class="title-text"><text>鍟嗗搧鐮�</text></view>
-			</view>
-			<view class="square-content">
-				<view class="content-input">
-					<input type="text" v-model="matnr" placeholder="鎵爜 / 杈撳叆" @input="find" :focus="focus">
-					<uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
-				</view>
-			</view>
-		</view>
+		
 		<!-- 搴撲綅鐮佽緭鍏ユ -->
 		<view class="square-2">
 			<view class="square-title">
@@ -21,8 +9,22 @@
 			</view>
 			<view class="square-content">
 				<view class="content-input">
-					<input type="text" v-model="locno" placeholder="鎵爜 / 杈撳叆" @input="find" :focus="focus">
-					<uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
+					<input type="text" v-model="locno" placeholder="鎵爜 / 杈撳叆" :focus="locnoFocus">
+					<uni-icons type="closeempty" size="20" color="#dadada" @click="remove('locno')"></uni-icons>
+				</view>
+			</view>
+		</view>
+		
+		<!-- 鍟嗗搧鐮佽緭鍏ユ -->
+		<view class="square-2">
+			<view class="square-title">
+				<view class="title-sign"><view class="sign"></view></view>
+				<view class="title-text"><text>鍟嗗搧鐮�</text></view>
+			</view>
+			<view class="square-content">
+				<view class="content-input">
+					<input type="text" v-model="matnr" placeholder="鎵爜 / 杈撳叆" @input="findMat" :focus="matnrFocus">
+					<uni-icons type="closeempty" size="20" color="#dadada" @click="remove('matnr')"></uni-icons>
 				</view>
 			</view>
 		</view>
@@ -46,7 +48,10 @@
 					<view><text style="width: 400rpx;">鍝佸悕锛歿{item.maktx}}</text></view>
 					<view><text style="width: 400rpx;">鎵瑰彿锛歿{item.batch}}</text></view>
 					<view>
-						<text style="width: 400rpx;">鏁伴噺锛歿{item.anfme}}</text>
+						<text style="width: 400rpx;">鎬绘暟閲忥細{{item.anfme}}</text><text style="width: 400rpx;">涓嬫灦鏁伴噺锛歿{item.qty}}</text>
+					</view>
+					<view>
+						
 					</view>
 				</view>
 				<view class="data-list-right">
@@ -72,6 +77,27 @@
 				<button class="cu-btn bg-blue " @click="comb()">涓嬫灦</button>
 			</label>
 		</view>
+		
+		<!-- 寮圭獥 -->
+		<!-- 淇敼鏁伴噺 -->
+		<uni-popup ref="revise" background-color="#fff">
+			<view class="revise-box">
+				<view class="revise-box-top">
+					<view class="color-block-blue"></view>
+					<text class="title">淇敼鏁伴噺</text>
+				</view>
+				<view class="changeBox">
+					<view class="num-box">
+						<uni-number-box :value="qty" :max="9999" color="#747474"  @change="changeValue"/>
+					</view> 
+				</view>
+				<view class="revise-box-buttom">
+					<view>
+						<button class="cu-btn bg-blue" @click="confirm()">纭</button>
+					</view>
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 	
 </template>
@@ -81,28 +107,125 @@
 		data() {
 		 	return {
 				matnr: '',
-				locno: '',
+				locno: 'NA003',
 				matList: [],
-				focus:true
+				locnoFocus:true,
+				matnrFocus:false,
+				res:'',
+				qty:0
 			}
 		},
+		mounted(){
+			const UIP = uni.getStorageSync('UIP');
+			this.baseIP = UIP;
+			const UPORT = uni.getStorageSync('UPORT');
+			this.basePORT = UPORT
+			const PROJ = uni.getStorageSync('UPROJ');
+			this.baseUrl = PROJ
+			this.getUrl()
+		},
 		methods: {
+			// 鑾峰彇url
+			getUrl() {
+				this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
+			},
+			// 鎼滅储
+			findMat() {
+				this.res = ''
+				let that = this,
+					url = '/mobile/mat/find/auth',
+					data = {locNo: that.locno, matnr: that.matnr},
+					method = "GET";
+					that.res=''
+				that.request(url,data,method);
+				setTimeout(function() {
+					that.res = that.res.data
+					that.checkMat(that.res)
+				}, 100);
+				
+				
+			},
+			// 涓嬫灦鎸夐挳
 			comb() {
-				let that = this
+				this.res = ''
 				var offSaleParam = {}
-				offSaleParam['locNo'] = 'NA003'
-				offSaleParam['matnr'] = 'YJ2022081808312309'
-				offSaleParam['anfme'] = 4
+				offSaleParam['locNo'] = this.locno
+				offSaleParam['matnr'] = this.matnr
+				offSaleParam['anfme'] = this.matList[0].qty
+				let that = this,
+					url = '/mobile/mat/offSale/auth',
+					data = JSON.stringify(offSaleParam),
+					method = "POST"
+				that.request(url,data,method)
+				setTimeout(function() {
+					if(that.res.code === 200) {
+						that.resst()
+						uni.showToast({title: that.res.msg, icon: "none",position: 'top'})
+					}
+				}, 100);
+				
+			},
+			revise(item,index) {
+				// this.qty = this.matList[index].anfme
+				this.rowNum = index
+				this.eject()
+			},
+			eject(type) {
+				this.type = type
+				// open 鏂规硶浼犲叆鍙傛暟 绛夊悓鍦� uni-popup 缁勪欢涓婄粦瀹� type灞炴��
+				this.$refs.revise.open(type)
+			},
+			confirm() {
+				this.matList[this.rowNum].qty = this.qty
+				this.$refs.revise.close()
+				this.$forceUpdate() // 寮哄埗鍒锋柊
+			},
+			changeValue(value) {
+				this.qty = value
+			},
+			// 娓呯┖input
+			remove(e) {
+				this[e] = ''
+			},
+			// 閲嶇疆鎸夐挳
+			resst() {
+				this.matList = []
+				this.locno = ''
+				this.matnr = ''
+			},
+			// 娣诲姞鍟嗗搧
+			addMat(mat) {
+				mat['qty'] = 0
+				this.matList.unshift(mat)
+			},
+			checkMat(mat) {
+				var len = this.matList.length
+				var add = true
+				for (var i = 0; i < len; i++) {
+					if (mat.matnr == this.matList[i].matnr) {
+						this.matList[i].anfme += mat.anfme 
+						this.$forceUpdate() // 寮哄埗鍒锋柊
+						add = false
+					}
+				}
+				if (add) {
+					mat['qty'] = 0
+					this.matList.unshift(mat)
+				}
+			},
+			// 閫氱敤鏂规硶
+			request(url,data,method){
+				let that = this
 				uni.request({
-					url:'http://localhost:8081/lywms/mobile/mat/offSale/auth',
-					data:JSON.stringify(offSaleParam),
-					method:'POST',
+					url: this.commonUrl + url,
+					data: data,
+					header:{'token':uni.getStorageSync('token')},
+					method: method,
 					success(result) {
-						var res = result
+						var res = result.data
 						console.log(res);
-						if (res.code === 200) {
-							uni.showToast({title: res.msg, icon: "none", position: 'top'});
-							that.resst()
+						if ( res.code === 200 ) {
+							that.res = res
 						} else if(res.code === 403) {
 							uni.showToast({title: res.msg, icon: "none", position: 'top'})
 							setTimeout(() => {
@@ -111,14 +234,28 @@
 								});
 							}, 1000);
 						} else {
+							console.log(res.msg);
 							uni.showToast({title: res.msg, icon: "none",position: 'top'})
 						}
+						
 					}
 				})
-			}
+			},
 		}
 	 }
 </script>
 
 <style>
+	@import url(@/static/css/putOnSale.css);
+	.footer {
+		width: 100%;
+		height: 100rpx;
+		line-height: 100rpx;
+		background-color: #FFF;
+		position: fixed;
+		bottom: 0;
+		border-top: 1px solid #d8d8d8;
+		border-radius: 20rpx 20rpx 0 0 ;
+		z-index: 1;
+	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1