From 3e7daebe18087c0511302081583f6af85c1deb95 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期二, 26 七月 2022 15:10:56 +0800
Subject: [PATCH] #

---
 pages/basics/bad.vue |  203 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 195 insertions(+), 8 deletions(-)

diff --git a/pages/basics/bad.vue b/pages/basics/bad.vue
index 5362521..cb6ac71 100644
--- a/pages/basics/bad.vue
+++ b/pages/basics/bad.vue
@@ -1,5 +1,6 @@
 <template>
 	<view>
+	<!-- 妫�绱㈢獥鍙� -->
 		<view class="square-2">
 			<view class="square-title">
 				<view class="title-sign"><view class="sign"></view></view>
@@ -7,17 +8,46 @@
 			</view>
 			<view class="square-content">
 				<view class="content-input">
-					<input>
-					<uni-icons type="closeempty" size="20" color="#dadada"></uni-icons>
+					<input v-model="barcode" placeholder="鎵爜 / 杈撳叆" @input="addMat" :focus="barcodeFocus">
+					<uni-icons type="closeempty" size="20" color="#dadada" @click="clearInput('barcode')"></uni-icons>
 				</view>
 			</view>
 		</view>
+	<!-- 鍟嗗搧鍒楄〃 -->
+		<view class="square-1">
+			<view class="square-title">
+				<view class="title-sign"><view class="sign"></view></view>
+				<view class="title-text"><text>鍟嗗搧鍒楄〃</text></view>
+			</view>
+		</view>
+		<view class="square-none"  v-show="matList.length === 0">
+			<view class="v-show">鏆傛棤鏇村鏁版嵁...</view>
+		</view>
+		<checkbox-group>
+			<view v-for="(item,index) in matList" :key="index" class="data-list bg-false" :class="'bg-'+item.checked" >
+				<view class="data-list-left">
+					<view class="matnr">No:{{listLen-index}}</view>
+					<view class="matnr">{{item}}</view>
+				</view>
+				<view class="data-list-right">
+					<uni-icons type="trash" size="20" color="#a5a5a5" @click="remove(item,index)"></uni-icons>
+				</view>
+			</view>
+		</checkbox-group>
+	<!-- 鎻愮ず淇℃伅寮圭獥 -->
+		<view>
+			<uni-popup ref="message" type="message">
+				<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
+			</uni-popup>
+		</view>
+		
+	<!-- 搴曢儴鎸夐挳 -->
 		<view class="footer flex justify-around">
 			<view>
-				<button class="cu-btn lg" @click="">閲嶇疆</button>
+				<button class="cu-btn lg" @click="reset">閲嶇疆</button>
 			</view>
 			<view>
-				<button class="cu-btn lg pakin-btn bg-blue" @click="">纭</button>
+				<button class="cu-btn lg pakin-btn bg-blue" @click="confirm()">纭</button>
 			</view>
 		</view>
 	</view>
@@ -27,16 +57,173 @@
 	export default {
 		data() {
 			return {
-				
+				commonUrl:null,
+				barcode:null,
+				matnr:null,
+				matList:[],
+				listLen:0, // 鍟嗗搧鍒楄〃闀垮害 榛樿0
+				barcodeFocus:true,
+				msgType:null,
+				messageText:null
 			}
 		},
+		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()
+		},
+		onLoad() {
+			// #ifdef APP
+			setInterval(()=>{
+				uni.hideKeyboard()
+			},20)
+			// #endif
+		},
 		methods: {
-			name() {
-				
-			}
+			// 鑾峰彇url
+			getUrl() {
+				this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePORT + "/" +this.baseUrl
+			},
+			// 鎵爜閲嶇疆
+			barcodeFocuss() {
+				let that = this;
+				that.barcodeFocus = false;
+				setTimeout(()=>{
+					that.barcode = '';
+					that.barcodeFocus = true;
+				}, 100);
+			},
+			// 娣诲姞鍟嗗搧鍒楄〃
+			addMat() {
+				let item = null
+				item = this.barcode
+				if(this.matList.length > 0) {
+					//	閬嶅巻matList
+					for (var i = 0;i < this.matList.length; i++) {
+						if (this.matList[i] == item) {
+							this.msgType = "warn"
+							this.messageText = this.barcode + ",宸叉坊鍔狅紒"
+							this.$refs.message.open()
+							this.resetAdd()
+							return;
+						} else {
+							this.matList.unshift(item)
+							this.resetAdd()
+							return;
+						}
+					}
+				} else {
+					this.matList.push(item)
+					this.resetAdd()
+				}
+			},
+			// 鍟嗗搧娣诲姞閲嶇疆
+			resetAdd() {
+				this.listLen = this.matList.length
+				this.barcodeFocuss()
+			},
+			// 娓呯┖鎼滅储妗�
+			clearInput(type) {
+				switch (type) {
+					case 'barcode':
+						this.barcodeFocuss()
+						break;
+				}
+			},
+			// 閲嶇疆
+			reset() {
+				this.barcodeFocuss()
+				this.matList = []
+			},
+			// 纭鍒楄〃
+			confirm() {
+				let that = this
+				console.log(that.commonUrl + '/mobile/matnr/danger/report/auth')
+				// return
+				uni.request({
+					url: that.commonUrl + '/mobile/matnr/danger/report/auth',
+					data:JSON.stringify(that.matList),
+					header: {
+						// 'token':uni.getStorageSync('token'),
+					},
+					method:"POST",
+					success(result) {
+						var res = result.data
+						console.log(res)
+						if (res.code === 200) {
+							that.msgType = "success"
+							that.messageText = '涓婃姤鎴愬姛锛�'
+							that.$refs.message.open()
+							that.reset()
+						} else if(res.code === 403) {
+							uni.showToast({title: res.msg, icon: "none", position: 'top'})
+							that.returnIndex();
+						} else {
+							uni.showToast({title: res.msg, icon: "none",position: 'top'})
+						}
+					}
+				})
+			},
+			remove(item,index) {
+				this.matnr = ''
+				this.matList.splice(index,1)
+				this.listLen = this.matList.length
+			},
+			// 403璺宠浆鐧诲綍椤�
+			returnIndex() {
+				setTimeout(() => {
+					uni.reLaunch({
+						url: '../login/login'
+					});
+				}, 1000);
+			},
+			
 		},
 	}
 </script>
 
 <style>
+	.data-list {
+		border-bottom: 1px solid #d8d8d8;
+		height: 130rpx;
+		margin: 15rpx;
+		border-radius: 20rpx;
+	}
+	.data-list:first-child {
+		margin-top: 20rpx;
+	}
+	.data-list:last-child {
+		margin-bottom: 200rpx;
+	}
+	.bg-false {
+		background-color: #FFFFFF;
+	}
+	.bg-true {
+		background-color: #ebebeb;
+	}
+	.data-list-left {
+		display: inline-block;
+		float: left;
+		margin-left: 6%;
+		height: 130rpx;
+		/* line-height: 100rpx; */
+		color: #676767;
+	}
+	.matnr {
+		font-size: 14px;
+		font-weight: 700;
+		/* padding-top: 15rpx; */
+		padding-top: 15rpx;
+	}
+	.data-list-right {
+		display: inline-block;
+		float: right;
+		height: 130rpx;
+		line-height: 130rpx;
+		margin-right: 10%;
+	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1