2 Commits 3fc2864089 ... f7006068b9

Author SHA1 Message Date
  695593266@qq.com f7006068b9 修改冲突 4 days ago
  695593266@qq.com aa8bd650df 修改bug 4 days ago

+ 3 - 1
manifest.json

@@ -13,7 +13,9 @@
                     // "target" : "http://123.249.79.125/api/",
                     // "target" : "http://114.116.248.196:86/api/",
                     // "target": "http://116.63.185.248:80/api",
-                    "target" : "http://192.168.1.251:18086/",
+                    // "target" : "http://192.168.1.251:18086/",sss
+					  "target" : "http://192.168.1.125:18086/",
+                    // "target" : "http://192.168.1.251:18086/",
                     // "target" : "http://192.168.1.102:18086/",
                     // "target" : "http://aiot.zoomwin.com.cn:51001/api",
                     "changeOrigin" : true,

+ 29 - 23
pages/pda/feeding/components/deviceBom.vue

@@ -179,6 +179,9 @@
 							</u-list>
 
 						</view>
+						<view class="feeding-total">
+							投料合计:<text>{{ getFeedingSum(idItem.positionList) }}</text>
+						</view>
 
 
 					</view>
@@ -263,10 +266,6 @@
 			</template>
 
 			<template v-slot:operate>
-				<view style="margin-bottom: 10px;">
-					和:{{ feedingSumNum }}
-				</view>
-
 				<view class="operate_box rx-bc">
 					<u-button size="small" class="u-reset-button" @click="handleClose" v-if="ishuoWei">
 						清空/取消
@@ -348,7 +347,6 @@ export default {
 			}],
 
 			unloadTurnover: [],
-			feedingSumNum: 0,
 
 
 			tabAct: 0
@@ -358,11 +356,20 @@ export default {
 
 		}
 	},
-	created() {
+	methods: {
+		getFeedingSum(positionList) {
+			if (!Array.isArray(positionList)) {
+				return 0
+			}
 
+			return positionList.reduce((total, position) => {
+				const isCurrentProduct = position.workOrderCode === this.wordItem.code &&
+					position.categoryCode === this.wordItem.productCode
+				const feedNum = Number(position.feedNum)
 
-	},
-	methods: {
+				return isCurrentProduct && Number.isFinite(feedNum) ? total + feedNum : total
+			}, 0)
+		},
 		handleScan(id) {
 			this.$emit('scanIt', id,)
 		},
@@ -373,7 +380,6 @@ export default {
 
 		handleStorage(idx) {
 			this.listIndex = idx || 0
-			this.feedingSumNum = 0;
 			if (Object.prototype.hasOwnProperty.call(this.list[0].extInfo, 'turnoverList')) {
 				this.unloadTurnover = this.turnover
 
@@ -382,19 +388,6 @@ export default {
 
 			console.log(this.turnoverList, 'this.turnoverList');
 
-			this.turnoverList.forEach(v => {
-				v.positionList.forEach(d => {
-					if (d.feedNum) {
-						this.feedingSumNum += Number(d.feedNum)
-					}
-				})
-
-			})
-
-
-
-
-
 			this.popupShow = true
 
 
@@ -783,6 +776,19 @@ export default {
 
 }
 
+.feeding-total {
+	margin-bottom: 10px;
+	padding-right: 12rpx;
+	text-align: right;
+	font-size: 28rpx;
+	color: #404446;
+
+	text {
+		color: $theme-color;
+		font-weight: 600;
+	}
+}
+
 
 .tab_box {
 	margin-top: 14rpx;
@@ -811,4 +817,4 @@ export default {
 		font-size: 34rpx;
 	}
 }
-</style>
+</style>

+ 1 - 1
pages/pda/feeding/components/turnoverBom.vue

@@ -423,4 +423,4 @@
 	.z_list {
 		max-height: 500rpx;
 	}
-</style>
+</style>

+ 90 - 21
pages/pda/jobBooking/components/turnoverBom.vue

@@ -4,12 +4,12 @@
 			<view class="name">周转车</view>
 		</view>
 
-		<view v-for="(item, index) in newList" :key='index'>
+		<view class="turnover-item" v-for="(item, index) in newList" :key="item.id || item.instanceId || item.code || index">
 			<view class="title_box rx-bc" v-if='!isDetails'>
 				<view class="left rx-ss" >
 					<uni-icons @click="getDelete(index)" custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
 					
-					<view class="des" @click="handContract()">{{ isContract ? '收缩'  :  '展开'}}</view>
+					<view class="des" @click="handContract(index)">{{ isExpanded(index) ? '收缩'  :  '展开'}}</view>
 				</view>
 			
 				
@@ -62,24 +62,24 @@
 				</view>
 
 				<view class="table">
-					<u-list @scrolltolower="scrolltolower" class="z_list">
+					<view class="z_list">
 				      <view  v-for="(it, idx) in item.extInfo.positionList" :key='idx'>
-						  <view class="tr row rx-sc"  v-if=" isContract || ( it.workOrderCode != '' &&  it.workOrderCode != null)">
+						  <view class="tr row rx-sc" v-if="shouldShowPosition(item, it, idx, index)">
 						  	<view class="item ww10">{{it.code}}</view>
-						  	<view class="item ww35" :class="{'color157': it.workOrderCode === wordItem.code}">
-						  		{{ it.workOrderCode }}
+							<view class="item ww35" :class="{'color157': getWorkOrderCode(item, it, idx) === wordItem.code}">
+								{{ getWorkOrderCode(item, it, idx) }}
 						  	</view>
-						  	<view class="item ww35" :class="{'color157': it.categoryCode === wordItem.productCode}">
-						  		{{it.categoryCode}}
+							<view class="item ww35" :class="{'color157': getCategoryCode(item, it, idx) === wordItem.productCode}">
+								{{ getCategoryCode(item, it, idx) }}
 						  	</view>
 						  
 						  	<view class="item ww20  " :class="{'content_num' : (pattern == 'job') }" v-if='!isDetails'>
 								<!-- // it.workOrderCode!==itemValue.code 就是工单编号和 周转车编号相同就可以修改  it.isOccupy===0 是-->
 							
-						  		<input class="uni-input" v-if='it.isFull == 0' @input="quantInt(index, idx, it)" 
-								  :class="{'content_num_box': it.categoryCode !== wordItem.productCode}"
+								<input class="uni-input" v-if="canEditQuantity(item, it, idx)" @input="quantInt(index, idx, it)"
+								  :class="{'content_num_box': getCategoryCode(item, it, idx) !== wordItem.productCode}"
 						  			v-model="it.quantity" type="digit"
-						  			:disabled="(!Object.prototype.hasOwnProperty.call(it, 'isOccupy') && it.isOccupy) || pattern != 'job' || isDisabled(it)"></input>
+									:disabled="pattern != 'job' || isDisabled(it)"></input>
 						  		<text v-else>{{it.quantity}}</text>
 
 						  	</view>
@@ -90,7 +90,7 @@
 						  	</view>
 						  </view>
 					  </view>
-					</u-list>
+					</view>
 
 				</view>
 
@@ -152,20 +152,61 @@
 
 				totalCount: 0,
 				
-				isContract: false
+				expandedIndexes: []
 
 
 			}
 		},
 
 		methods: {
+			isExpanded(index) {
+				return this.expandedIndexes.includes(index)
+			},
+
+			isAvailablePosition(it) {
+				return !it.workOrderCode && Number(it.isOccupy || 0) === 0 && Number(it.isFull || 0) !== 1
+			},
+
+			getDefaultPositionIndex(item) {
+				const positionList = item && item.extInfo && Array.isArray(item.extInfo.positionList)
+					? item.extInfo.positionList
+					: []
+				return positionList.findIndex(it => this.isAvailablePosition(it))
+			},
+
+			hasCurrentWorkOrder(item) {
+				const positionList = item && item.extInfo && Array.isArray(item.extInfo.positionList)
+					? item.extInfo.positionList
+					: []
+				return positionList.some(it => it.workOrderCode === this.wordItem.code)
+			},
+
+			isDefaultPosition(item, it, idx) {
+				return !this.hasCurrentWorkOrder(item) && this.isAvailablePosition(it) && this.getDefaultPositionIndex(item) === idx
+			},
+
+			shouldShowPosition(item, it, idx, turnoverIndex) {
+				return this.isExpanded(turnoverIndex) || !!it.workOrderCode || this.isDefaultPosition(item, it, idx)
+			},
+
+			getWorkOrderCode(item, it, idx) {
+				return it.workOrderCode || (this.isDefaultPosition(item, it, idx) ? this.wordItem.code : '')
+			},
+
+			getCategoryCode(item, it, idx) {
+				return it.categoryCode || (this.isDefaultPosition(item, it, idx) ? this.wordItem.productCode : '')
+			},
+
+			canEditQuantity(item, it, idx) {
+				return it.isFull == 0 || it.workOrderCode === this.wordItem.code || this.isDefaultPosition(item, it, idx)
+			},
 
 			//条件判断
 			isDisabled(it) {
 				if(it.workOrderCode === this.itemValue.code){
 					return false
 				}else{
-					if(it.isOccupy){
+					if(Number(it.isOccupy || 0) !== 0){
 						return true
 					}else{
 						return false
@@ -179,8 +220,14 @@
 				if (it.quantity >= 1) {
 					this.$set(this.newList[index].extInfo.positionList[idx], 'workOrderCode', this.wordItem.code)
 					this.$set(this.newList[index].extInfo.positionList[idx], 'categoryCode', this.wordItem.productCode)
-					if(it.quantity > this.itemValue.product[0].feedQuantity) {
+					const maxQuantity = Number(this.itemValue.product && this.itemValue.product[0]
+						? this.itemValue.product[0].feedQuantity
+						: 0)
+					const currentTotal = this.getCurrentTotal(index, idx)
+					if(maxQuantity > 0 && currentTotal > maxQuantity) {
 						this.$set(this.newList[index].extInfo.positionList[idx], 'quantity', 0)
+						this.$set(this.newList[index].extInfo.positionList[idx], 'workOrderCode', '')
+						this.$set(this.newList[index].extInfo.positionList[idx], 'categoryCode', '')
 						return uni.showToast({
 							icon: 'none',
 							title: `超出投料数量`
@@ -218,6 +265,22 @@
 
 
 
+			},
+
+			getCurrentTotal(excludeTurnoverIndex, excludePositionIndex) {
+				return this.newList.reduce((total, turnover, turnoverIndex) => {
+					const positionList = turnover && turnover.extInfo && Array.isArray(turnover.extInfo.positionList)
+						? turnover.extInfo.positionList
+						: []
+					return positionList.reduce((positionTotal, position, positionIndex) => {
+						if (turnoverIndex === excludeTurnoverIndex && positionIndex === excludePositionIndex) {
+							return positionTotal + Number(position.quantity || 0)
+						}
+						return position.workOrderCode === this.wordItem.code
+							? positionTotal + Number(position.quantity || 0)
+							: positionTotal
+					}, total)
+				}, 0)
 			},
 
 			handleScan(index) {
@@ -226,13 +289,19 @@
 
 			getDelete(index) {
 				this.list.splice(index, 1)
-
-
+				this.expandedIndexes = this.expandedIndexes
+					.filter(itemIndex => itemIndex !== index)
+					.map(itemIndex => itemIndex > index ? itemIndex - 1 : itemIndex)
 			},
 			scrolltolower() {},
 			
-			handContract() {
-				this.isContract = !this.isContract
+			handContract(index) {
+				const expandedIndex = this.expandedIndexes.indexOf(index)
+				if (expandedIndex === -1) {
+					this.expandedIndexes.push(index)
+				} else {
+					this.expandedIndexes.splice(expandedIndex, 1)
+				}
 			}
 		}
 	}
@@ -450,6 +519,6 @@
 		}
 	}
 	.z_list {
-		max-height: 500rpx;
+		height: auto;
 	}
-</style>
+</style>