| <template> | 
|     <view> | 
|         <view class="itemstyle"> | 
|             <uni-forms label-width="180"> | 
|                 <uni-forms-item label="外箱码:"> | 
|                     <uni-easyinput type="text" placeholder="请扫描外箱码" ref='midInput'  v-model="barcode" :focus="!focus" | 
|                          class="search_box" :disabled="isDisable" @confirm="handleKeyPress"/> | 
|                 </uni-forms-item> | 
|             </uni-forms> | 
|         </view> | 
|         <view style="padding: 0 0rpx 0rpx;"> | 
|             <!-- 当前出库外包号 --> | 
|             <view class="item_boxItem"> | 
|                 <uni-list> | 
|                     <uni-list-item direction="column" v-for="(item,index) in listShow" :key="index"> | 
|                         <template v-slot:body> | 
|                             <view class="uni-list-box"> | 
|                                 <uni-icons type="trash" size="22" style="position: absolute;right: 5%;" | 
|                                     @click="deleteList(index)"> | 
|                                 </uni-icons> | 
|                                 <view class="uni-content"> | 
|                                     <view class="uni-title-sub uni-ellipsis-2">外包:{{item.code}}    数量:{{item.qty}}</view> | 
|                                 </view> | 
|                             </view> | 
|                         </template> | 
|                     </uni-list-item> | 
|                 </uni-list> | 
|             </view> | 
|         </view> | 
|         <view style="padding: 0 14rpx 200rpx;"> | 
|             <!-- 明细 --> | 
|             <view v-for="i in list" :key="i.id" class="item_box"> | 
|                 <view style="line-height: 17px;color: #596671;font-size: 14px;text-align: left;font-weight: bold;">订单明细行号:{{i.rowId}} | 
|                 </view> | 
|                 <view style="margin-top: 22rpx;height: 140rpx;display: flex;flex-direction: column;justify-content: space-around;"> | 
|                     <view style="color: #00070F;font-size: 12px;">客户代号:{{i.customer}}</view> | 
|                     <view style="color: #00070F;font-size: 12px;">产品编号:{{i.pCode}}</view> | 
|                     <view style="color: #00070F;font-size: 12px;">销售订单:{{i.saleOrder}}</view> | 
|                     <view style="color: #f56c6c;font-size: 12px;">订单数量:{{i.qtyPcs}}</view> | 
|                     <view style="color: #67c23a;font-size: 12px;">已出数量:{{i.overQtyPcs}}</view> | 
|                 </view> | 
|                 <view style="width: 100%;height: 1rpx;background-color: #00070F;margin-top: 28rpx;"> | 
|                 </view> | 
|             </view> | 
|         </view> | 
|         <view style="padding:20rpx;position: fixed;bottom: 0;left: 0;background-color:lightgray;width: 100%;z-index: 999;display: flex;justify-content: space-between;"> | 
|             <view style="margin-bottom: 22rpx;padding-left: 16rpx;line-height: 80rpx;"> | 
|                 <view style="font-size: 24rpx;font-weight: bold;color: #f56c6c;">订单总数量:<text>{{orderQty}}</text></view> | 
|                 <view style="font-size: 24rpx;font-weight: bold;color: #67c23a;">已扫总数量:<text>{{total}}</text></view> | 
|             </view> | 
|             <view style="display: flex;height: 110rpx;margin-top: 40rpx;"> | 
|                 <button @click="reset" type="default" size="default" style="margin-top: 2%;width: 160rpx;border: 1rpx solid #007aff;color: #007aff;margin-right: 30rpx;">重置</button> | 
|                 <button @click="InEmpty" type="primary" size="default" style="margin-top: 2%;width: 160rpx;">出货</button> | 
|             </view> | 
|         </view> | 
|         <u-toast ref="uToast" /> | 
|     </view> | 
| </template> | 
|   | 
| <script> | 
|     const innerAudioContext = uni.createInnerAudioContext(); | 
|     export default { | 
|         data() { | 
|             return { | 
|                 focus: false, | 
|                 barcode: "", | 
|                 proOutNo: "", | 
|                 id: null, | 
|                 list:[], | 
|                 listOutBags:[], | 
|                 listShow:[], | 
|                 total:0, | 
|                 orderQty:0, | 
|                 isDisable:false | 
|             } | 
|         }, | 
|         onShow() {}, | 
|         onLoad(res) { | 
|             this.proOutNo=res.proOutNo; | 
|             this.GetDetail(res.id); | 
|             this.id=res.id; | 
|             uni.hideKeyboard(); //隐藏软键盘 | 
|         }, | 
|         methods: { | 
|             handleKeyPress(e) { | 
|                 console.log(e); | 
|                   // 回车符(ASCII 13)表示扫码结束 | 
|                   this.isDisable=true; | 
|                   this.focus=true; | 
|                   this.$nextTick(function(x) { | 
|                       var values= this.barcode.split(','); | 
|                       if(values.length==5){ | 
|                           // if (values.length != 5) { | 
|                           //     this.$refs.uToast.show({ | 
|                           //         title: "扫描格式错误"+value, | 
|                           //         type: 'error' | 
|                           //     }) | 
|                           //     this.barcode=""; | 
|                           //     this.$refs.midInput.focus(); | 
|                           //     return; | 
|                           // } | 
|                           this.$u.post('/api/ProOutOrder/CheckCode?code='+this.barcode,{}).then( | 
|                               res => { | 
|                                   if (res.status) { | 
|                                       //判断是否重复 | 
|                                       if (this.listShow.some(item => item.code === values[0])) { | 
|                                           this.barcode=""; | 
|                                           setTimeout(() => { | 
|                                               this.isDisable=false; | 
|                                               this.focus=false; | 
|                                           },200); | 
|                                           this.$refs.uToast.show({ | 
|                                               title: "重复扫描"+values[0]+"已存在", | 
|                                               type: 'error' | 
|                                           }) | 
|                                           return; | 
|                                       } | 
|                                       if (this.list.some(item => item.pCode === values[1])) { | 
|                                           var outCode=values[0]; | 
|                                           var outQty=parseInt(values[4]); | 
|                                           //判断outQty为数字 | 
|                                           if (isNaN(outQty)) { | 
|                                                   this.barcode=""; | 
|                                                   setTimeout(() => { | 
|                                                       this.isDisable=false; | 
|                                                       this.focus=false; | 
|                                                   },200); | 
|                                                   this.$refs.uToast.show({ | 
|                                                       title: "扫描格式错误"+values[4], | 
|                                                       type: 'error' | 
|                                                   }) | 
|                                                   return; | 
|                                               } | 
|                                           //判断outQty是否大于0 | 
|                                           if (outQty<=0) { | 
|                                               this.barcode=""; | 
|                                               setTimeout(() => { | 
|                                                   this.isDisable=false; | 
|                                                   this.focus=false; | 
|                                               },200); | 
|                                               this.$refs.uToast.show({ | 
|                                                   title: "标签数必须大于0", | 
|                                                   type: 'error' | 
|                                               }) | 
|                                               return; | 
|                                           } | 
|                                           this.total+=outQty; | 
|                                           if(this.orderQty<this.total){ | 
|                                               this.barcode=""; | 
|                                               setTimeout(() => { | 
|                                                   this.isDisable=false; | 
|                                                   this.focus=false; | 
|                                               },200); | 
|                                               this.$refs.uToast.show({ | 
|                                                   title: "订单数超出", | 
|                                                   type: 'error' | 
|                                               }) | 
|                                               return; | 
|                                           } | 
|                                           this.listShow.unshift({code:outCode,qty:outQty}); | 
|                                           console.log(this.listShow); | 
|                                           //去除this.barcode的空格 | 
|                                           this.listOutBags.push(this.barcode.replace(/\s*/g, "")); | 
|                                           this.barcode=""; | 
|                                           setTimeout(() => { | 
|                                               this.isDisable=false; | 
|                                               this.focus=false; | 
|                                           },200); | 
|                                            | 
|                                       }else{ | 
|                                           this.barcode=""; | 
|                                           setTimeout(() => { | 
|                                               this.isDisable=false; | 
|                                               this.focus=false; | 
|                                           },200); | 
|                                           this.$refs.uToast.show({ | 
|                                               title: "扫描"+values[1]+"批号不在订单中", | 
|                                               type: 'error' | 
|                                           }) | 
|                                           return; | 
|                                       } | 
|                                   } | 
|                               }) | 
|                       } | 
|                   }) | 
|                 }, | 
|             GetDetail(value) { | 
|                 this.$u.post('/api/ProOutOrder/GetOrderDetails?keyId='+value).then( | 
|                     res => { | 
|                         if (res.status) { | 
|                             this.list=res.data.proOutOrderDetails; | 
|                             this.orderQty=this.list.map(x=>{ | 
|                                 return x.qtyPcs | 
|                             }).reduce((a,b)=>{ | 
|                                 return a+b | 
|                             }); | 
|                         } else { | 
|                             this.$refs.uToast.show({ | 
|                                 title: res.message, | 
|                                 type: "error" | 
|                             }) | 
|                         } | 
|                     }) | 
|             }, | 
|             // voiceSpeech(src) { | 
|             //     innerAudioContext.src = src; // '../../static/success.mp3'; | 
|             //     innerAudioContext.play(); | 
|             // }, | 
|             // barcodeInput(value) { | 
|             //     this.isDisable=true; | 
|             //     this.focus=true; | 
|             //     setTimeout(x=>{ | 
|             //         this.$nextTick(function(x) { | 
|             //             var values= this.barcode.split(','); | 
|             //             if(values.length==5){ | 
|             //                 // if (values.length != 5) { | 
|             //                 //     this.$refs.uToast.show({ | 
|             //                 //         title: "扫描格式错误"+value, | 
|             //                 //         type: 'error' | 
|             //                 //     }) | 
|             //                 //     this.barcode=""; | 
|             //                 //     this.$refs.midInput.focus(); | 
|             //                 //     return; | 
|             //                 // } | 
|             //                 this.$u.post('/api/ProOutOrder/CheckCode?code='+this.barcode,{}).then( | 
|             //                     res => { | 
|             //                         if (res.status) { | 
|             //                             //判断是否重复 | 
|             //                             if (this.listShow.some(item => item.code === values[0])) { | 
|             //                                 this.barcode=""; | 
|             //                                 setTimeout(() => { | 
|             //                                     this.isDisable=false; | 
|             //                                     this.focus=false; | 
|             //                                 },200); | 
|             //                                 this.$refs.uToast.show({ | 
|             //                                     title: "重复扫描"+values[0]+"已存在", | 
|             //                                     type: 'error' | 
|             //                                 }) | 
|             //                                 return; | 
|             //                             } | 
|             //                             if (this.list.some(item => item.pCode === values[1])) { | 
|             //                                 var outCode=values[0]; | 
|             //                                 var outQty=parseInt(values[4]); | 
|             //                                 //判断outQty为数字 | 
|             //                                 if (isNaN(outQty)) { | 
|             //                                         this.barcode=""; | 
|             //                                         setTimeout(() => { | 
|             //                                             this.isDisable=false; | 
|             //                                             this.focus=false; | 
|             //                                         },200); | 
|             //                                         this.$refs.uToast.show({ | 
|             //                                             title: "扫描格式错误"+values[4], | 
|             //                                             type: 'error' | 
|             //                                         }) | 
|             //                                         return; | 
|             //                                     } | 
|             //                                 //判断outQty是否大于0 | 
|             //                                 if (outQty<=0) { | 
|             //                                     this.barcode=""; | 
|             //                                     setTimeout(() => { | 
|             //                                         this.isDisable=false; | 
|             //                                         this.focus=false; | 
|             //                                     },200); | 
|             //                                     this.$refs.uToast.show({ | 
|             //                                         title: "标签数必须大于0", | 
|             //                                         type: 'error' | 
|             //                                     }) | 
|             //                                     return; | 
|             //                                 } | 
|             //                                 this.total+=outQty; | 
|             //                                 if(this.orderQty<this.total){ | 
|             //                                     this.barcode=""; | 
|             //                                     setTimeout(() => { | 
|             //                                         this.isDisable=false; | 
|             //                                         this.focus=false; | 
|             //                                     },200); | 
|             //                                     this.$refs.uToast.show({ | 
|             //                                         title: "订单数超出", | 
|             //                                         type: 'error' | 
|             //                                     }) | 
|             //                                     return; | 
|             //                                 } | 
|             //                                 this.listShow.unshift({code:outCode,qty:outQty}); | 
|             //                                 console.log(this.listShow); | 
|             //                                 //去除this.barcode的空格 | 
|             //                                 this.listOutBags.push(this.barcode.replace(/\s*/g, "")); | 
|             //                                 this.barcode=""; | 
|             //                                 setTimeout(() => { | 
|             //                                     this.isDisable=false; | 
|             //                                     this.focus=false; | 
|             //                                 },200); | 
|                                              | 
|             //                             }else{ | 
|             //                                 this.barcode=""; | 
|             //                                 setTimeout(() => { | 
|             //                                     this.isDisable=false; | 
|             //                                     this.focus=false; | 
|             //                                 },200); | 
|             //                                 this.$refs.uToast.show({ | 
|             //                                     title: "扫描"+values[1]+"批号不在订单中", | 
|             //                                     type: 'error' | 
|             //                                 }) | 
|             //                                 return; | 
|             //                             } | 
|             //                         } | 
|             //                     }) | 
|             //             } | 
|             //         }) | 
|             //     },200) | 
|             // }, | 
|             deleteList(res) { | 
|                 let indexExist =-1; | 
|                 //查询this.listOutBags中是否有this.listShow[res].code | 
|                 this.listOutBags.forEach((item,index) => { | 
|                     //item是否包含 this.listShow[res].code | 
|                     if (item.includes(this.listShow[res].code)) { | 
|                         indexExist=index; | 
|                     } | 
|                 }); | 
|                 console.log(indexExist); | 
|                 if (indexExist !=-1) { // 如果找到了索引,则执行删除操作 | 
|                     this.total-=this.listShow[res].qty; | 
|                     this.listOutBags.splice(indexExist, 1); // 从索引位置开始删除一个元素 | 
|                     this.listShow.splice(res, 1); | 
|                 } | 
|                 setTimeout(() => { | 
|                     this.isDisable=false; | 
|                 },200); | 
|                 this.barcode=""; | 
|             }, | 
|             reset(){ | 
|                 this.listShow=[]; | 
|                 this.total=0; | 
|                 this.listOutBags=[]; | 
|                 this.focus=true; | 
|                 this.barcode=""; | 
|                 setTimeout(() => { | 
|                     this.barcode=""; | 
|                     this.isDisable=false; | 
|                     this.focus=false; | 
|                 }, 200); | 
|             }, | 
|             InEmpty() { | 
|                 // if (this.barcode == "") { | 
|                 //     this.$refs.uToast.show({ | 
|                 //         title: "请扫描外箱码", | 
|                 //         type: 'error' | 
|                 //     }) | 
|                 //     return; | 
|                 // } | 
|                 if(this.orderQty!==this.total){ | 
|                         this.$refs.uToast.show({ | 
|                             title: "请扫描"+this.orderQty+"数量", | 
|                             type: 'error' | 
|                         }) | 
|                         return; | 
|                 } | 
|                 var postData = { | 
|                     MainData: { | 
|                         "outProOrderNo":this.proOutNo | 
|                     }, | 
|                     DelKeys:this.listOutBags | 
|                 } | 
|                 this.$u.post('/api/ProOutOrder/OutProScanCodeSync',postData).then( | 
|                     res => { | 
|                         if (res.status) { | 
|                             this.$refs.uToast.show({ | 
|                                 title: "成功", | 
|                                 type: "success" | 
|                             }) | 
|                             this.reset(); | 
|                             this.GetDetail(this.id); | 
|                         } else { | 
|                             this.$refs.uToast.show({ | 
|                                 title: res.message, | 
|                                 type: "error" | 
|                             }) | 
|                         } | 
|                     }) | 
|             } | 
|         } | 
|     } | 
| </script> | 
|   | 
| <style lang="scss"> | 
|     @import '@/common/uni-ui.scss'; | 
|   | 
|     .content { | 
|         display: flex; | 
|         height: 150px; | 
|     } | 
|   | 
|     .content-text { | 
|         font-size: 14px; | 
|         color: #666; | 
|     } | 
|   | 
|     .itemstyle { | 
|         margin-top: 30px; | 
|         margin-left: 5%; | 
|     } | 
|     .item_box { | 
|         background-color: white; | 
|         // height: 344rpx; | 
|         border-radius: 12rpx; | 
|         padding: 40rpx 38rpx 28rpx 34rpx; | 
|         font-size: 24rpx; | 
|         line-height: 34rpx; | 
|         margin-top: 20rpx; | 
|     } | 
|     .item_boxItem { | 
|         background-color: white; | 
|         padding: 40rpx 38rpx 28rpx 34rpx; | 
|         // height: 344rpx; | 
|         border-radius: 12rpx; | 
|         font-size: 24rpx; | 
|         line-height: 17rpx; | 
|     } | 
|     .headerstyle { | 
|         width: 90%; | 
|     } | 
|     .search_box { | 
|         padding: 10rpx 20rpx 20rpx; | 
|         background-color: white; | 
|     } | 
| </style> |