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

---
 pages/product/tailHandle/index.vue |  412 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 412 insertions(+), 0 deletions(-)

diff --git a/pages/product/tailHandle/index.vue b/pages/product/tailHandle/index.vue
new file mode 100644
index 0000000..f52a313
--- /dev/null
+++ b/pages/product/tailHandle/index.vue
@@ -0,0 +1,412 @@
+<template>
+	<view class="wrap">
+		<view class="list" :border="false">
+			<view class="content" style="background: #fff;">		
+				<view class="row-list">
+					<view style="font-size: 28rpx;color: #909399;margin-right: 10rpx;">
+						宸ヤ綔绔�:
+					</view>
+					<view class="_content" style="text-align: left;">
+						{{ tailHandle.workstationName }}
+					</view>
+					<view style="margin-right: 30rpx;">
+						<u-icon name="scan" class="scan" @click="goScan"></u-icon>
+					</view>
+					<view >
+						<u-button type="primary" style="width:150rpx;" @click="toWorkstation">閫夋嫨</u-button>
+					</view>
+				</view>
+			</view>
+		</view> 
+		<view class="title">
+			<view>
+				<u-icon class="grid-icon" name="column-line" :size="40" :style="{ color: '#0081ff' }"></u-icon>
+			</view>
+			<view class="text-black text-bold basis-xl">鏈哄彴鐗╂枡</view>
+		</view>
+		<scroll-view class="scroll-list mid" scroll-y="true">	
+				<div class="tip" v-if="list.length==0">-鏆傛棤鐗╂枡-</div>
+				<view :class="['content',item.isSelected?'select-class':'']" v-for="(item, index) in list" :key="item.id" :index="index" @click="selectRow(item)">
+					<view class="row-list" style="padding-top: 8px;">
+						<view class="_label">
+							闆朵欢鍙�:
+						</view>
+						<view class="_content">
+							{{ item.partNo }}
+						</view>
+					</view>
+					<view class="row-list">
+						<view class="_label">
+							闆朵欢鍚嶇О:
+						</view>
+						<view class="_content">
+							{{ item.partName }}
+						</view>
+					</view>
+					<view class="row-list">
+						<view class="_label">
+							SN鍙�:
+						</view>
+						<view class="_content">
+							{{ item.partBatchNo }}
+						</view>
+					</view>
+					<view class="row-list">
+						<view class="_label">
+							ifs鎵规鍙�:
+						</view>
+						<view class="_content">
+							{{ item.ifsBatchNo }}
+						</view>
+					</view>		
+					<view class="row-list">
+						<view class="_label">
+							鍙敤鏁伴噺:
+						</view>
+						<view class="_content">
+							{{ item.availableStockQuantity+'('+item.unit+')' }}
+						</view>
+					</view>
+				</view>
+			</scroll-view>
+			
+		<view class="view-fixed-two bottom">
+			<u-button class="r" size="medium" type="primary" @click="goSubmit">灏炬枡鍙戞斁</u-button>
+		</view>
+		<scan></scan>	
+		<u-modal v-model="showConfirm" content="鏄惁纭灏嗗熬鏂欐墸闄わ紝姝ゆ搷浣滀笉鍙�嗭紒"  @confirm="confirm" :show-cancel-button="true"/>
+	</view>
+</template>
+<script>
+	import scan from "@/components/scan/scan.vue";
+	export default {
+		components: {
+			scan
+		},
+		data() {
+			return {
+				tailHandle:{
+					workstationId: null,
+					workstationNo: null,
+					workstationName: null
+				},	
+				list:[],
+				showConfirm:false
+			};
+		},
+		onLoad() {
+		
+		},
+		onShow() {
+			let that = this		
+			uni.$off('scan') // 姣忔杩涙潵鍏� 绉婚櫎鍏ㄥ眬鑷畾涔変簨浠剁洃鍚櫒
+			uni.$on('scan', function(data) {
+				//鎵爜鎴愬姛鍚庣殑鍥炶皟锛屼綘鍙互鍐欒嚜宸辩殑閫昏緫浠g爜鍦ㄨ繖閲�
+				console.log('鎵爜缁撴灉锛�', data.code);
+				// console.log(data.code.replace(/\n/g,'').replace(/\s*/g,''))
+				// console.log('鎵爜缁撴灉1锛�', JSON.parse(data.code.replace(/\n/g,"").replace(/\s*/g,'')));
+								
+				that.loadList(data.code);
+				that.$forceUpdate();
+			})
+		},
+		onNavigationBarButtonTap(e) {
+			this.goScan()
+		},
+		methods: {
+			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))
+				
+				uni.scanCode({
+					scanType: ['qrCode'],
+					success: res => {
+						try {
+							console.log('鎵爜缁撴灉锛�', res);
+							this.scanHandle(res.result)
+						} catch (e) {}
+					}
+				});
+			},
+			//鏍规嵁鏈哄彴鍙凤紝鏌ヨ鏈哄彴淇℃伅锛屽啀鏌ヨ鐗╂枡淇℃伅
+			scanHandle(workstationNo){
+				if(workstationNo!=''){
+					this.$u.api.pigxFeed.fetchWorkstationList({workstationNo:workstationNo}).then(resp => {
+						
+						if (!resp.data.records || resp.data.records.length == 0) {
+							this.$u.toast('銆�'+workstationNo+'銆�,鏈煡璇㈠埌鏈哄彴淇℃伅')
+						}else{
+							let workstationList=resp.data.records
+							let scanWorkstationInfo=workstationList[0]
+							this.tailHandle.workstationId = scanWorkstationInfo.id
+							this.tailHandle.workstationNo = scanWorkstationInfo.workstationNo
+							this.tailHandle.workstationName = scanWorkstationInfo.name
+							this.list=[]
+							this.$u.api.pigxTailHandle.getFeedingStock({workstationId:scanWorkstationInfo.id}).then(res => {
+												   let reList = []					   
+												   reList = res.data;	
+												   if(reList.length!=0)
+													{
+														// 鎸夊彲鐢ㄦ暟閲忔帓涓簭
+														reList.sort(this.compare('availableStockQuantity'))
+														reList.forEach((item)=>{
+															this.list.push({
+																locationId:item.locationId,
+																locNo:item.locNo,
+																partBatchNo:item.partBatchNo,
+																partId:item.partId,
+																partNo:item.partNo,
+																partName:item.partName,
+																availableStockQuantity:item.availableStockQuantity,
+																unit:item.unit,
+																ifsBatchNo:item.ifsBatchNo,
+																id:item.id,
+																isSelected:false
+															})
+														})
+													}
+							})
+						}								
+					})
+				}else{
+					this.$u.toast('鏈壂鎻忓埌鏈哄彴鍙�')
+				}
+			},
+			selectRow(stock){
+				stock.isSelected=!stock.isSelected	
+				/*this.list.forEach((item,index)=>{
+					if(item.id ==stock.id){
+						this.list.splice(index,1)
+						return;
+					}
+				})*/
+				//if(stock.isSelected){
+					//灞曠ず鍦ㄥ垪琛ㄦ渶涓婃柟
+				//	this.list.unshift(stock)
+				//}else{
+					//灞曠ず鍦ㄥ垪琛ㄦ渶涓嬫柟
+				//	this.list.push(stock)
+				//}
+				
+			},
+			setWorkstation(workstation) {
+				this.list=[]
+				this.tailHandle.workstationId = workstation.id
+				this.tailHandle.workstationNo = workstation.workstationNo
+				this.tailHandle.workstationName = workstation.name
+				this.$u.api.pigxTailHandle.getFeedingStock({workstationId:workstation.id}).then(res => {
+									   let reList = []					   
+									   reList = res.data;	
+									   if(reList.length!=0)
+										{
+											// 鎸夊彲鐢ㄦ暟閲忔帓涓簭
+											reList.sort(this.compare('availableStockQuantity'))
+											reList.forEach((item)=>{
+												this.list.push({
+													locationId:item.locationId,
+													locNo:item.locNo,
+													partBatchNo:item.partBatchNo,
+													partId:item.partId,
+													partNo:item.partNo,
+													partName:item.partName,
+													availableStockQuantity:item.availableStockQuantity,
+													unit:item.unit,
+													ifsBatchNo:item.ifsBatchNo,
+													id:item.id,
+													isSelected:false
+												})
+											})
+										}
+				});
+			},
+			toWorkstation() {
+				uni.navigateTo({
+					url: '/pages/product/tailHandle/workstationList'
+				})
+			},
+			loadList(sanCode) {
+				let that = this
+				if(sanCode!="")
+				{
+					//鏍规嵁鎵叆鐨勫瓧绗︿覆淇℃伅锛屽垽鏂壂鐨勬槸鏉″舰鐮侊紝杩樻槸浜岀淮鐮�
+					let snNo
+					if (sanCode.indexOf('sn_no') != -1) {
+					    // 浜岀淮鐮�
+					    const scanContentJson = JSON.parse(
+					        sanCode.replace(/\n/g, '').replace(/\s*/g, '')
+					    )
+						snNo=scanContentJson.sn_no
+					    
+					} else {
+					    // 鏉″舰鐮�
+					    snNo = sanCode										    
+					}				   
+				    //鏍规嵁sn鍙烽�変腑鐗╂枡
+					let exsitMaterial=this.list.find((item)=>{
+						return item.partBatchNo==snNo
+					})
+					if(exsitMaterial){
+						exsitMaterial.isSelected=true
+						/*this.list.forEach((item,index)=>{
+							if(item.id ==exsitMaterial.id){
+								this.list.splice(index,1)
+								return;
+							}
+						})*/
+						//灞曠ず鍦ㄥ垪琛ㄦ渶涓婃柟
+						//this.list.unshift(exsitMaterial)
+						
+					}
+				}			
+			},
+			goSubmit(){
+				this.showConfirm=true
+			},
+			confirm(){
+				let stockIds = []
+				this.list.forEach((item) => {
+					if(item.isSelected){
+						stockIds.push(item.id)
+					}
+				})
+				if(stockIds.length>0){
+					this.$u.api.pigxTailHandle.tailStockIssue(stockIds).then(res => {
+						let reData = res.data;
+						this.$u.toast('灏炬枡鍙戞斁鎴愬姛!')
+						this.getWorkstationMaterial(this.tailHandle.workstationId)
+					})	
+				}else{
+					this.$u.toast('璇烽�夋嫨闇�鍙戞斁鐨勭墿鏂�!')
+				}
+			},
+			getWorkstationMaterial(workstationId){
+				this.list=[]
+				this.$u.api.pigxTailHandle.getFeedingStock({workstationId:workstationId}).then(res => {
+									   let reList = []					   
+									   reList = res.data;	
+									   if(reList.length!=0)
+										{
+											// 鎸夊彲鐢ㄦ暟閲忔帓涓簭
+											reList.sort(this.compare('availableStockQuantity'))
+											reList.forEach((item)=>{
+												this.list.push({
+													locationId:item.locationId,
+													locNo:item.locNo,
+													partBatchNo:item.partBatchNo,
+													partId:item.partId,
+													partNo:item.partNo,
+													partName:item.partName,
+													availableStockQuantity:item.availableStockQuantity,
+													unit:item.unit,
+													ifsBatchNo:item.ifsBatchNo,
+													id:item.id,
+													isSelected:false
+												})
+											})
+										}
+				});
+			},
+			compare(pro){
+				return function(obj1, obj2) {
+				    const val1 = obj1[pro]
+				    const val2 = obj2[pro]
+				    if (val2 < val1) {
+				      // 姝e簭
+				      return 1
+				    } else if (val2 > val1) {
+				      return -1
+				    } else {
+				      return 0
+				    }
+				  }
+			}
+		}
+	};
+</script>
+<style lang="scss" scoped>	
+	.mid {
+		height: calc(100vh - var(--window-top) - var(--window-bottom) - 286rpx);
+		padding: 30rpx 30rpx 0;
+		box-sizing: border-box;
+		.tip{
+			text-align: center;
+			padding-top: 50rpx;
+			font-size: 30rpx;
+		}
+		.u-card{
+			margin: 0 0 30rpx!important;
+			position: relative;
+			box-shadow: 0px 3px 6px 1px rgba(127, 127, 127, 0.2)!important;
+			&+.u-card{
+				// margin-top: 30rpx!important;
+			}
+			.u-form-item{
+				padding: 2px 0;
+			}
+		}
+		.index{
+			text-align: center;
+			padding-top: 20rpx;
+		}
+	}
+	
+	
+	 .content {
+		font-size: 12px;
+		background-color: #efefef;
+		box-sizing: border-box;
+		border-radius: 14rpx;
+		margin: 8px;
+		padding: 5px 10px;
+		box-shadow: none;
+		position: relative;
+	}
+	
+	.title {
+		display: flex;
+		flex-direction: row;
+	}
+	
+	.row-list {
+		display: flex;
+		flex-direction: row;
+		align-items: center;
+	}
+	
+	.row-list ._label {
+		flex: 0.8;
+		color: #909399;
+	}
+	
+	.row-list ._content {
+		flex: 1.5;
+		text-align: right;
+	}
+	.bottom {
+		width: 750rpx;
+		height: 90rpx;
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		margin-bottom:5rpx ;
+		.u-btn{
+			margin: initial;
+			height: 100%;
+			border-radius: 14rpx;
+			width: 90%;
+			background:#3281FF;
+		}
+		.l{
+			
+		}
+	}
+	.scan{
+		width: 60rpx;
+		height: 60rpx;
+		font-size: 60rpx;
+		color: #3281ff;
+	}
+	.select-class{
+		background-color: #9FFF5F;
+	}
+</style>

--
Gitblit v1.9.3