From f0ffe3a07738ff34824e2a2eec0bf831d707470b Mon Sep 17 00:00:00 2001 From: whycq <whycq> Date: 星期六, 12 二月 2022 17:06:14 +0800 Subject: [PATCH] # --- pages/basics/comb.vue | 116 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 85 insertions(+), 31 deletions(-) diff --git a/pages/basics/comb.vue b/pages/basics/comb.vue index 3c32ef4..5134fac 100644 --- a/pages/basics/comb.vue +++ b/pages/basics/comb.vue @@ -3,7 +3,7 @@ <form> <view class="cu-form-group margin-top"> <view class="title">鎵樼洏鐮�</view> - <input v-model="code" placeholder="鎵爜 / 杈撳叆" name="input" @input="findCode" focus> + <input v-model="code" placeholder="鎵爜 / 杈撳叆" name="input" @input="findCode()" focus> <button v-model="matBtn" class="cu-btn bg-yellow" @click="toggle('right')"><text>+鎻愬彇</text></button> </view> @@ -11,20 +11,20 @@ <view class="margin-top"> <uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁"> <uni-tr> - <uni-th>鏁伴噺</uni-th> - <uni-th>浜у搧浠e彿</uni-th> - <uni-th>浜у搧鍚嶇О</uni-th> + <uni-th width="50">鏁伴噺</uni-th> + <uni-th width="100">浜у搧浠e彿</uni-th> + <uni-th width="100">浜у搧鍚嶇О</uni-th> </uni-tr> - <uni-tr> - <uni-td>1121</uni-td> - <uni-td>1121</uni-td> - <uni-td>1121</uni-td> + <uni-tr v-for="(item, index) in matData" :key="index" @input="tabRender()"> + <uni-td>{{item.count}}</uni-td> + <uni-td>{{item.matNo}}</uni-td> + <uni-td>{{item.matName}}</uni-td> </uni-tr> </uni-table> </view> <view> - <button class="cu-btn bg-yellow pda-btn">缁勬墭</button> + <button class="cu-btn bg-yellow pda-btn" @click="comb()">缁勬墭</button> <button class="cu-btn bg-grey pda-btn" @click="reset">閲嶇疆</button> </view> <view> @@ -36,7 +36,7 @@ </view> <view class="cu-form-group margin-top"> <text class="title">浜у搧ID</text> - <input type="text" v-model="matNo" placeholder="鎵爜 / 杈撳叆" name="input" autocomplete="off" focus @input="find"> + <input type="text" v-model="matNo" placeholder="鎵爜 / 杈撳叆" name="input" autocomplete="off" focus @input="find()"> </view> <view class="cu-form-group margin-top"> <text class="title">浜у搧鍚嶇О</text> @@ -55,13 +55,14 @@ <uni-number-box @change="countDom" v-model="count" /> </view> <button class="cu-btn bg-yellow pda-btn2" @click="confirm">鎻愬彇</button> - <view> - <!-- 鎻愮ず淇℃伅寮圭獥 --> - <uni-popup ref="message" type="message"> - <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message> - </uni-popup> - </view> + </view> + </uni-popup> + </view> + <view> + <!-- 鎻愮ず淇℃伅寮圭獥 --> + <uni-popup ref="message" type="message"> + <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message> </uni-popup> </view> </view> @@ -89,12 +90,11 @@ } }, methods: { - reset:function() { + reset() { let that =this; that.code = ''; - }, - idid(){ - alert(1) + that.matData=[]; + }, toggle(type) { this.type = type @@ -104,7 +104,7 @@ countDom(value) { }, - findCode(){ // 鎵樼洏鐮� 瓒呰繃8浣� + findCode(){ // 鏌ヨ鎵樼洏鐮� 瓒呰繃8浣� let that = this; if(that.code.length === 8){ that.toggle('right') @@ -113,11 +113,10 @@ // 鏍规嵁浜у搧浠e彿鏌ヨ浜у搧璇︽儏 find(){ let that = this - // if(isEmpty(that.matNo)){ - // return; - // } isEmpty 鏈畾涔� + console.log(that.matNo) let thatId = that.matNo if(that.matNo.length===0){ + console.log(1) return; } uni.request({ @@ -131,7 +130,9 @@ }, method:'POST', success:function(res){ + console.log(res) let data = res.data.data + if(res.data.code === 200){ if(data != null){ that.matName = data.matName @@ -155,20 +156,21 @@ matName:that.matName, count:that.count } - that.addTbaleData(data) }, + // 娣诲姞琛ㄦ牸鏁版嵁 addTbaleData(data){ + console.log(data.matName) if(data.matName===''){ + this.messageToggle('error') return } this.$refs.popup.close() - for(var i=0;i<this.matData.length;i++){ - console.log(data) - console.log(this.data) + console.log(this.matData.length) + for(var i=0;i<this.matData.length;i++){ if(data.matNo === this.matData[i].matNo){ this.matData[i].count = Number(this.matData[i].count) + Number(data.count); this.toPush = false; @@ -178,15 +180,67 @@ this.matData.push(data) } this.messageToggle('success') - + this.messageText = '鎻愬彇鎴愬姛' + this.matName='' + this.matNo='' + this.specs='' + this.count='0' + this.tabRender() }, messageToggle(type) { this.msgType = type - this.messageText = `鎻愬彇澶辫触` + this.messageText = '鎻愬彇澶辫触' this.$refs.message.open() }, - + // 琛ㄦ牸娓叉煋 + tabRender(){ + + }, + // 缁勬墭 + comb(){ + let that = this + let barcode = that.code + if(barcode.length === 0){ + console.log(1) + that.messageToggle('error') + that.messageText = '鎵樼洏鏉$爜涓虹┖' + return; + } + if(barcode.length !== 8){ + that.messageToggle('error') + that.messageText = '鏉$爜蹇呴』涓�8浣�' + return; + } + if (that.matData.length === 0) { + that.messageToggle('error') + that.messageText = '璇锋彁鍙栦骇鍝�' + return; + } + uni.request({ + + url:that.baseUrl+"/mobile/comb/auth", + header:{'token':localStorage.getItem('token')}, + data:{ + barcode:barcode, + combMats:that.matData + }, + method:'POST', + success:function(res){ + console.log(res) + if(res.data.code===200){ + that.reset() + that.messageToggle('success') + that.messageText = '缁勬墭鎴愬姛' + }else if(res.data.data===403){ + + }else { + + } + } + }) + + } } } </script> -- Gitblit v1.9.1