From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 28 五月 2025 16:48:52 +0800
Subject: [PATCH] 初始化项目

---
 pages/wareHouse/inventory/detail.vue |  640 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 640 insertions(+), 0 deletions(-)

diff --git a/pages/wareHouse/inventory/detail.vue b/pages/wareHouse/inventory/detail.vue
new file mode 100644
index 0000000..55d9bec
--- /dev/null
+++ b/pages/wareHouse/inventory/detail.vue
@@ -0,0 +1,640 @@
+<template>
+	<view class="page">
+	  <view class="inventory-detail-bg"/>
+	  <view class="inventory-detail-carmera">
+		  <view class="inventory-detail-carmera-icon" @click="goScan">
+		  </view>
+		  <view class="inventory-detail-carmera-tip">
+			  <text>鎵竴鎵�</text>
+		  </view>
+	  </view>
+	  <u-navbar title="鎵爜鐩樼偣" :background="background" :border-bottom="false" :title-bold="true" title-color="#000" back-icon-color="#000"/>
+	  <view class="inventory-detail-param">
+		  <view class="inventory-detail-param-view">
+			  <view class="inventory-detail-param-item param-extra">
+			  	<view class="inventory-detail-param-item-left">
+			  	  <text class="item-one">鐩樼偣缂栧彿</text>
+			  	</view>
+			  	<view class="inventory-detail-param-item-right">
+			  	   <text class="item-one">{{inyInfo.inyNo}}</text>
+			  	   <u-icon name="arrow-right" color="#687792" size="28"></u-icon>
+			  	</view>
+			  </view>
+			  <view class="inventory-detail-param-item param-extra">
+			  	<view class="inventory-detail-param-item-left">
+			  	  <text class="item-one">鐩樼偣搴撲綅</text>
+			  	</view>
+			  	<view class="inventory-detail-param-item-right" @click="goLoc()">
+			  	   <text v-if="inyInfo.locNo" class="item-one">{{inyInfo.locNo}}</text>
+			  	   <text v-if="!inyInfo.locNo" class="item-one item-two">璇烽�夋嫨</text>
+			  	   <u-icon name="arrow-right" color="#687792" size="28"></u-icon>
+			  	</view>
+			  </view>
+			  <view class="inventory-detail-param-item">
+			  	<view class="inventory-detail-param-item-left">
+			  	  <text class="item-one">鑷姩鎻愪氦</text>
+			  	</view>
+			  	<view class="inventory-detail-param-item-right">
+			  	   <!--<text class="item-one">{{isAuto?'鏄�':'鍚�'}}</text>-->
+				   <picker class="item-one" style="width: 100%;" @change="autoNumBindChange($event,isAutoList)" :value="autoNumIndex" :range="isAutoList"
+				   	range-key="label">
+				   	<view>
+				   		<text>{{isAutoList[autoNumIndex].label}}</text>
+				   	</view>
+				   </picker>
+			  	   <u-icon name="arrow-right" color="#687792" size="28"></u-icon>
+			  	</view>
+			  </view>
+		  </view>
+	  </view>
+	  <view class="wrap">
+		<scroll-view class="inventory-detail-scroll-list" scroll-y="true">
+			<u-cell-group class="inventory-detail-scroll-list-group" :border="false">
+				<view class="tip" v-if="list.length==0">-璇锋柊澧炴垨鎵爜-</view>
+				<view class="content" v-for="(x, index) in list" :key="index" :index="index">
+					<u-form :model="x" ref="uForm" labelWidth="6em" >
+						<u-form-item label="闆朵欢鍙�" prop="partNo" required>
+							<u-input v-model="x.partNo" disabled @click="x.isScan?null:goPart(index)"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+						<u-form-item label="闆朵欢鍚嶇О" prop="partName">
+							<u-input v-model="x.partName" disabled @click="x.isScan?null:goPart(index)"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+						<u-form-item label="SN鍙�" prop="sn" required>
+							<u-input v-model="x.sn" :disabled="x.isScan"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+						<u-form-item label="IFS鎵规鍙�" prop="ifsBatchNo" required>
+							<u-input v-model="x.ifsBatchNo" :disabled="x.isScan"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+						<u-form-item label="鐩樼偣鏁伴噺" prop="inyQty" required>
+							<u-input v-model="x.inyQty" type="number"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+						<u-form-item label="鍗曚綅" prop="unit">
+							<u-input v-model="x.unit" :disabled="x.isScan"/>
+							<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
+						</u-form-item>
+					</u-form>
+					<view class="content-btn">
+						<u-button size="mini" :custom-style="customStyle" @click="goMinus(index)">
+							<u-icon name="trash" color="#fff" size="28"></u-icon>
+							<text style="margin-left:4rpx;">鍒犻櫎</text>
+						</u-button>
+					</view>
+				</view>
+			</u-cell-group>
+		</scroll-view>
+		<view class="inventory-footer">
+			<u-button class="btn-left" size="medium" type="primary" @click="goAdd">鏂板</u-button>
+			<u-button class="btn-right" size="medium" type="primary" @click="goSubmit">鎻愪氦</u-button>
+		</view>
+		<scan></scan>
+		<u-modal v-model="showConfirm" content="璇ラ浂浠舵壒娆″凡鎵弿杩�,鏄惁缁х画鎵弿"  @confirm="confirm" :show-cancel-button="true"/>
+		<u-modal v-model="showScanConfirm" content="璇ラ浂浠舵壒娆″凡鎵弿杩�,鏄惁缁х画鎵弿"  @confirm="confirmGoOn" :show-cancel-button="true"/>
+	</view>
+    </view>
+</template>
+<script>
+	import scan from "@/components/scan/scan.vue";
+	import content_bg from '@/static/custom/inventory/locNoBg.png'
+	export default {
+		components: { scan },
+		data() {
+			const rr=(type)=>{
+				return [
+						{ 
+							required: true, 
+							message: `${type}涓哄繀濉」`, 
+							trigger: ['change'],
+						}
+					]
+			}
+			return {
+				background:{
+					backgroundImage: `url(${content_bg})`,
+					backgroundAttachment: 'fixed',
+					backgroundSize: '100% auto',
+					backgroundRepeat: 'no-repeat',
+				},
+				customStyle:{
+					color:'#fff',
+					background:'#ED837B'
+				},
+				labelStyle:{
+					fontSize:'32rpx',
+					whiteSpace:'nowrap'
+				},
+				bodyStyle:{
+					padding: '0 40rpx 10rpx'
+				},
+				inyInfo:{
+					inyid:'',
+					inyNo:'',
+					locNo:''
+				},
+				isAuto:false,
+				list:[
+				],
+				hasScanSnList:[],
+				currentIndex:-1,
+				rules:{
+					partNo:rr('闆朵欢鍙�'),
+					sn:rr('SN鍙�'),
+					ifsBatchNo:rr('IFS鎵规鍙�'),
+					inyQty:rr('鐩樼偣鏁伴噺')
+				},
+				showConfirm:false,
+				currResult:null,
+				currScanresult:null,
+				isBarcode:true,
+				showScanConfirm:false,
+				isAutoList:[
+					{value:false,label:'鍚�'},
+					{value:true,label:'鏄�'}
+				],
+				autoNumIndex:0
+			};
+		},
+		onLoad(option) {
+			this.inyInfo.inyid=option.id
+			this.inyInfo.inyNo=option.no
+		},
+		onShow() {
+		
+			let that = this
+		
+			uni.$off('scan') // 姣忔杩涙潵鍏� 绉婚櫎鍏ㄥ眬鑷畾涔変簨浠剁洃鍚櫒
+			uni.$on('scan', function(data) {
+				console.log('onscan');
+				//鎵爜鎴愬姛鍚庣殑鍥炶皟锛屼綘鍙互鍐欒嚜宸辩殑閫昏緫浠g爜鍦ㄨ繖閲�
+				console.log('鎵爜缁撴灉锛�', data.code);
+				that.scanHandle(data.code)
+				that.$forceUpdate();
+		
+			})
+		},
+		onNavigationBarButtonTap(){
+			this.goScan()
+		},
+		methods: {
+			autoNumBindChange(e,storage){
+				if (storage.length <= 0) {
+					this.autoNumIndex = null
+					return
+				}
+				this.autoNumIndex = e.target.value
+				this.isAuto = storage[this.autoNumIndex].value
+			},
+			goScan(){
+				 //let scanresult={"part_no":"88.118.1/A0044193","package_code":"TP092022101200001","unit_meas":"璺�","wdr":"*","lot_batch_no":"*","qty_arrived":12}
+				 //this.scanHandle(JSON.stringify(scanresult))
+				// return
+				if(!this.inyInfo.locNo){
+					this.$u.toast('璇峰厛閫夋嫨鐩樼偣搴撲綅')
+					return
+				}
+				uni.scanCode({
+					scanType: ['qrCode'],
+					success: res => {
+						try {
+							console.log('鎵爜缁撴灉锛�', res);
+							this.scanHandle(res.result)
+						} catch (e) {}
+					}
+				});
+			},
+			confirmGoOn(){
+				if(this.isBarcode){
+					this.hasScanSnList.push(this.currScanresult)
+					//涓嶈嚜鍔紝濉啓鐩樼偣鏁伴噺
+					this.$u.api.inventory.getStockByLocNoAndSn({
+						locationNo:this.inyInfo.locNo,
+						sn:this.currScanresult
+					}).then(res=>{
+						let resultArr=[]
+						if(res.data.data!=null && res.data.data.length>0){
+							 let resDataArr=res.data.data
+							resultArr =resDataArr.map(e=>{
+								return {
+									partNo: e.partNo,
+									partName: e.partName,
+									sn: this.currScanresult,
+									ifsBatchNo: e.ifsBatchNo,
+									inyQty: e.inyQty,
+									unit: e.unit,
+									isScan: true
+								}
+							})
+						}
+						if(resultArr.length==0){
+							this.$u.toast('鏃犳暟鎹�')
+							let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
+							this.hasScanSnList.splice(hasScanSnIndex,1)
+						}else{
+							this.$u.api.inventory.goCheck({
+								...resultArr[0],
+								inventoryMainId:this.inyInfo.inyid,
+								locNo:this.inyInfo.locNo
+							}).then(res2=>{
+								if (!res2.data.data.success) {
+									this.showConfirm=true
+									this.confirmData=resultArr
+								} else {
+									this.scanSave(resultArr)
+								}
+								let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
+								this.hasScanSnList.splice(hasScanSnIndex,1)
+							}).catch((e) => {
+								let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
+								this.hasScanSnList.splice(hasScanSnIndex,1)
+							    console.log(e)
+							})
+						}
+					}).catch((e) => {
+						  let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
+						  this.hasScanSnList.splice(hasScanSnIndex,1)
+						  console.log(e)
+						})
+				}else{
+					this.hasScanSnList.push(this.currResult.wdr+' '+this.currResult.lot_batch_no)
+					this.$u.api.inventory.getPartNo({
+						partNo:this.currResult.part_no,
+					}).then(res=>{
+						const obj=[{
+							partNo: this.currResult.part_no,
+							partName: res.data.partName,
+							sn: this.currResult.wdr,
+							ifsBatchNo: this.currResult.lot_batch_no,
+							inyQty: this.currResult.qty_arrived,
+							unit: this.currResult.unit_meas,
+							isScan: true
+						}]
+						this.$u.api.inventory.goCheck({
+							...obj[0],
+							inventoryMainId:this.inyInfo.inyid,
+							locNo:this.inyInfo.locNo
+						}).then(res2=>{
+							if (!res2.data.data.success) {
+								this.showConfirm=true
+								this.confirmData=obj
+							} else {
+								
+								this.scanSave(obj)
+							}
+							let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
+							this.hasScanSnList.splice(hasScanSnIndex,1)
+						}).catch((e) => {
+						  let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
+						  this.hasScanSnList.splice(hasScanSnIndex,1)
+						  console.log(e)
+						})
+					}).catch((e) => {
+						  let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
+						  this.hasScanSnList.splice(hasScanSnIndex,1)
+						  console.log(e)
+						})
+				}
+			},
+			scanHandle(scanresult){
+				if(!this.inyInfo.locNo){
+					this.$u.toast('璇峰厛閫夋嫨鐩樼偣搴撲綅')
+					return
+				}
+				scanresult = scanresult.replace(/[\r\n]/g, "")
+				console.log(scanresult)
+				// const reg = /^{[\w\W]*}$/
+				// console.log(reg.test(scanresult))
+				if (scanresult.indexOf('{')>-1) {
+					//浜岀淮鐮�
+					const result = JSON.parse(scanresult)
+					this.isBarcode=false
+					this.currResult=result
+					let flag=true
+					if(this.list.length>0){
+						let exist=this.list.find((item)=>{return (item.sn+' '+item.ifsBatchNo)==(result.wdr+' '+result.lot_batch_no)})
+						if(exist){
+							flag=false
+						}
+					}
+					//澧炲姞SN鏍¢獙
+					let snFlag=true
+					console.log('this.hasScanSnList',this.hasScanSnList.length)
+					if(this.hasScanSnList.length>0){
+						let hasScanSnIndex=this.hasScanSnList.indexOf(result.wdr+' '+result.lot_batch_no)
+						if(hasScanSnIndex>-1){
+							snFlag=false
+						}
+					}
+					if(flag && snFlag){
+					    this.confirmGoOn()
+					}else{
+						this.showScanConfirm=true
+					}
+					
+				} else {
+					//鏉″舰鐮�
+					if(this.isAuto){
+						//鑷姩鎻愪氦
+						this.$u.toast('鏉″舰鐮佷笉鏀寔鑷姩鎻愪氦')
+						// this.$u.api.inventory.getInventoryDetailByLocNoAndSn({
+						// 	id:this.inyInfo.inyid,
+						// 	locationNo:this.inyInfo.locNo,
+						// 	sn:scanresult
+						// }).then(res=>{
+						// 	this.$u.toast('鎻愪氦鎴愬姛')
+						// })
+					}else{
+						this.isBarcode=true
+						this.currScanresult=scanresult
+						let flag=true
+						if(this.list.length>0){
+							let exist=this.list.find((item)=>{return item.sn==scanresult})
+							if(exist){
+								flag=false
+							}
+						}
+						//澧炲姞SN鏍¢獙
+						let snFlag=true
+						if(this.hasScanSnList.length>0){
+							let hasScanSnIndex=this.hasScanSnList.indexOf(scanresult)
+							if(hasScanSnIndex>-1){
+								snFlag=false
+							}
+						}
+						if(flag && snFlag){
+							this.confirmGoOn()
+						}else{
+							this.showScanConfirm=true
+						}
+					}
+				}
+				
+			},
+			confirm(){
+				this.scanSave(this.confirmData)
+			},
+			scanSave(resultArr){
+				if(this.isAuto){
+					this.save(resultArr)
+				}else{
+					//寰�鏁扮粍鍓嶆帓娣诲姞鍏冪礌
+					resultArr.forEach((item)=>{
+						this.list.unshift(item)
+					})
+					//this.list=this.list.concat(resultArr)
+				}
+			},
+			goAdd() {
+				if(!this.inyInfo.locNo){
+					this.$u.toast('璇峰厛閫夋嫨鐩樼偣搴撲綅')
+					return
+				}
+				this.list.unshift({
+					partNo: '',
+					partName: '',
+					sn: '',
+					ifsBatchNo: '',
+					inyQty: '',
+					unit: '',
+					isScan: false
+				})
+				this.$nextTick(()=>{
+					this.$refs.uForm[this.list.length-1].setRules(this.rules);
+				})
+			},
+			goMinus(i){
+				this.list.splice(i, 1)
+			},
+			goPart(index){
+				this.currentIndex=index;
+				uni.navigateTo({
+					url: `/pages/wareHouse/inventory/partchoose`
+				})
+			},
+			setPart(item){
+				this.list[this.currentIndex].partNo=item.partNo
+				this.list[this.currentIndex].partName=item.partName
+			},
+			goLoc(){
+				uni.navigateTo({
+					url: '/pages/wareHouse/inventory/locNoList'
+				})
+			},
+			setNo(no) {
+				this.inyInfo.locNo=no
+			},
+			goSubmit() {
+				if(this.list.length==0){
+					this.$u.toast('鏃犲緟鎻愪氦鐨勭洏鐐规槑缁�')
+					return
+				}
+				let pass=true
+				this.list.forEach((e,i)=>{
+					this.$refs.uForm[i].validate(valid => {
+						if(!valid){
+							pass=false
+						}
+					})
+				})
+				if(pass){
+					this.save(this.list,true)
+				}
+			},
+			save(list,clear){
+				uni.showLoading({
+					title: '姝e湪鎻愪氦...',
+					mask: true
+				});	
+				let p=[]
+				list.forEach((e,i)=>{
+					const param={
+						...e,
+						inventoryMainId:this.inyInfo.inyid,
+						locNo:this.inyInfo.locNo
+					}
+					p.push(this.$u.api.inventory.addDetail(param))
+				})
+				Promise.all(p).then(()=>{
+					this.$u.toast('鎻愪氦鎴愬姛')
+					if(clear){
+						this.list=[]
+						this.hasScanSnList=[]
+					}
+					uni.hideLoading();
+				})
+			}
+		}
+	};
+</script>
+<style lang="scss" scoped>
+	.page{
+		position: relative;
+	}
+	.inventory-detail-bg{
+		background-color: #F6F9FF;
+		background-image: url('~@/static/custom/inventory/locNoBg.png');
+		// background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
+		padding: 0 20rpx;
+		background-attachment: fixed;
+		background-size: 100% auto;
+		background-repeat: no-repeat;
+		position: fixed;
+		top: 0;
+		bottom: 0;
+		width: 100%;
+		z-index: -1;
+	}
+	
+	.inventory-detail-carmera{
+		position: absolute;
+		top:10rpx;
+		right: 30rpx;
+		height: 82rpx;
+		width: 82rpx;
+		z-index: 1000;
+		.inventory-detail-carmera-icon{
+			background-image: url('~@/static/custom/inventory/carmera.png');
+			background-size: 100% auto;
+			background-repeat: no-repeat;
+			width: 82rpx;
+			height: 82rpx;
+		}
+		.inventory-detail-carmera-tip{
+			text{
+				font-size: 20rpx;
+				color:#3D8BFF;
+			}
+		}
+	}
+	
+	.inventory-detail-param{
+		padding: 50rpx 30rpx 0rpx 30rpx;
+		.inventory-detail-param-view{
+			height: 300rpx;
+			background: rgba(255,255,255,0.61);
+			box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.09);
+			border-radius: 10rpx;
+			padding:0rpx 23rpx;
+			margin-bottom: 30rpx;
+			.inventory-detail-param-item{
+				height: 100rpx;
+				border: 1px solid #ADC8E4;
+				line-height: 100rpx;
+				display:flex;
+				justify-content: space-between;
+				border: none;
+				.inventory-detail-param-item-left{
+					.item-one{
+						font-size: 30rpx;
+						color: #4F4F4F;
+					}
+				}
+				.inventory-detail-param-item-right{
+					display: flex;
+					.item-one{
+						font-size: 30rpx;
+						color: #333333;
+						margin-right: 6rpx;
+					}
+					.item-two{
+						font-size: 30rpx;
+						color: #A6B4CC;
+						margin-right: 6rpx;
+					}
+					.item-three{
+						font-size: 30rpx;
+						color: #214DED;
+						margin-right: 6rpx;
+					}
+				}
+			}
+			.param-extra{
+				border-bottom: 1px solid #E8EBEE;
+			}
+		}
+	}
+	
+	.wrap .inventory-detail-scroll-list{
+		height:calc(100vh - var(--window-top) - var(--window-bottom) - 596rpx);
+	    width:100%;
+	}
+	.inventory-detail-scroll-list-group{
+		::v-deep .u-cell-item-box {
+			background-color:rgba(255,255,255,0) !important;
+			margin:0rpx 30rpx;
+			padding:0rpx 0rpx 0rpx 0rpx;
+		}
+		.tip{
+			text-align: center;
+		}
+		.content {
+			background-color: #fff;
+			border-radius: 10rpx;
+			margin-bottom: 20rpx;
+			box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.09);
+			::v-deep .u-form{
+				.u-form-item{
+					padding: 10rpx 22rpx 10rpx 10rpx !important;
+					 .u-form-item--left__content{
+						 justify-content: flex-end !important;
+						 .u-form-item--left__content--required{
+							 position:relative !important;
+						 }
+						 .u-form-item--left__content__label{
+							flex: none !important;
+							color: #666666;
+						 }
+					}
+					.u-form-item--right__content{
+						.u-input{
+							text-align: right !important;
+							.u-input__input{
+								color: #B1B5BB !important;
+							}
+						}
+					}
+				}
+			}
+			.content-btn{
+				padding: 10rpx 0rpx;
+				text-align: right;
+				margin-right: 22rpx;
+			}
+			
+		}
+	}
+
+	.inventory-footer{
+		padding: 0rpx 30rpx 0rpx 30rpx;
+		margin-bottom: 20rpx;
+		display: flex;
+		justify-content: space-between;
+		.btn-left{
+			width: 310rpx;
+			height: 90rpx;
+			background: #30AFFF;
+			border: 1px solid #BFCFE4 !important;
+			box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.3);
+			border-radius: 16rpx;	
+			font-size: 40rpx;
+			font-weight: bold;
+			color: #FEFEFE;
+		}
+		.btn-left:after{
+				border:none !important;
+		}
+		.btn-right{
+			width: 310rpx;
+			height: 90rpx;
+			background: #214DED;
+			box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(4,49,212,0.3);
+			border-radius: 16rpx;
+			font-size: 40rpx;
+			font-weight: bold;
+			color: #FEFEFE;
+		}
+	}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3