From 6e4a02ffbc9a013d9429794936267e25634d6869 Mon Sep 17 00:00:00 2001
From: lijuncheng <juncheng.li@ccwin-in.com>
Date: Tue, 18 Mar 2025 09:13:12 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=98=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/pages/count/coms/comCountDetailcards.vue |   2 +-
 src/pages/count/coms/comCountRecordCard.vue  |   6 +-
 src/pages/count/job/countLightDetail.vue     | 305 ++++++++++++++++++-
 3 files changed, 294 insertions(+), 19 deletions(-)

diff --git a/src/pages/count/coms/comCountDetailcards.vue b/src/pages/count/coms/comCountDetailcards.vue
index cc68b220..c03afdb1 100644
--- a/src/pages/count/coms/comCountDetailcards.vue
+++ b/src/pages/count/coms/comCountDetailcards.vue
@@ -126,7 +126,7 @@
 				this.$emit('summCount', this.dataContent.countAllRecordList)
 			},
 			currentCount(){
-				this.$emit('currentCount', this.dataContent.recordList)
+				this.$emit('currentCount', this.dataContent,this.dataContent.recordList)
 			}
 
 		},
diff --git a/src/pages/count/coms/comCountRecordCard.vue b/src/pages/count/coms/comCountRecordCard.vue
index 3c07a497..079da660 100644
--- a/src/pages/count/coms/comCountRecordCard.vue
+++ b/src/pages/count/coms/comCountRecordCard.vue
@@ -7,7 +7,7 @@
 		<view class="" style="margin-left: 20rpx;">
 			<view class="" v-for="(item,index) in recordList">
 				<uni-swipe-action ref="swipeAction">
-					<uni-swipe-action-item @click="swipeClick($event,item)" :right-options="scanOptions">
+					<uni-swipe-action-item @click="swipeClick($event,item,index)" :right-options="scanOptions">
 						<recommend-count :detail="item" :isShowFromLocation="false"
 							style='margin:1px 0px;color: #000; font-weight: bold;' :isShowRecommendQty="false">
 						</recommend-count>
@@ -105,11 +105,11 @@
 		},
 
 		methods: {
-			swipeClick(e, item) {
+			swipeClick(e, item,index) {
 				if (e.content.text == "编辑") {
 					this.edit(item)
 				} else if (e.content.text == "移除") {
-					this.remove(item)
+					this.remove(item,index)
 				}
 			},
 
diff --git a/src/pages/count/job/countLightDetail.vue b/src/pages/count/job/countLightDetail.vue
index 240f5c2c..83689102 100644
--- a/src/pages/count/job/countLightDetail.vue
+++ b/src/pages/count/job/countLightDetail.vue
@@ -169,6 +169,27 @@
 
 		computed() {},
 		methods: {
+			filterList(originalList) {
+				var resultList = []
+				for (var i = 0; i < originalList.length; i++) {
+					let flag = -1
+					for (var j = 0; j < resultList.length; j++) {
+
+						if (resultList[j].find(item => item.inventoryStatus == originalList[i]['inventoryStatus'])) {
+							flag = j
+							break
+						}
+					}
+					if (flag == -1) {
+						resultList.push([originalList[i]])
+					} else {
+						resultList[j].push(originalList[i])
+					}
+
+				}
+				return resultList;
+
+			},
 			getManageMode(value) {
 				var manageMode = ""
 				if (value == 'BY_BATCH') {
@@ -209,6 +230,220 @@
 			},
 
 			refreshData(returnData) {
+				if (returnData.recordList.length == 0) {
+					if (this.manageMode == "BY_BATCH") {
+						var mainItem = this.dataList.find(r =>
+							r.itemCode == returnData.itemCode &&
+							r.batch == returnData.batch &&
+							r.inventoryStatus == returnData.inventoryStatus)
+						if (mainItem) {
+							mainItem.recordList = []
+						} else if (this.manageMode == "BY_QUANTITY") {
+							var mainItem = this.dataList.find(r =>
+								r.itemCode == returnData.itemCode &&
+								r.inventoryStatus == returnData.inventoryStatus)
+
+							if (mainItem) {
+								mainItem.recordList = []
+							}
+						}
+					}
+				} else {
+					var filterList = this.filterList(returnData.recordList)
+					var addList = []
+					filterList.forEach(main => {
+						main.forEach(subItem => {
+							if (this.manageMode == "BY_BATCH") {
+								var mainItem = this.dataList.find(r =>
+									r.itemCode == subItem.itemCode &&
+									r.batch == subItem.batch &&
+									r.inventoryStatus == subItem.inventoryStatus)
+								subItem.toPackingNumber = ""
+								if (mainItem) {
+									mainItem.scaned = true;
+									//如果是编辑的,返回后清除record
+									if (this.currentEditItem.itemCode == mainItem.itemCode &&
+										this.currentEditItem.batch == mainItem.batch &&
+										this.currentEditItem.inventoryStatus == mainItem.inventoryStatus) {
+										mainItem.recordList = []
+										mainItem.recordList = main
+									} else {
+										//不是编辑进入的,
+										var tempRecord = mainItem.recordList.find(r =>
+											r.itemCode == subItem.itemCode &&
+											r.batch == subItem.batch &&
+											r.packingNumber == subItem.packingNumber &&
+											r.inventoryStatus == subItem.inventoryStatus)
+										if (tempRecord) {
+											tempRecord.handleQty = subItem.handleQty
+										} else {
+											mainItem.recordList.push(subItem)
+										}
+									}
+
+								} else {
+									var detail = this.createBackAddDetailInfo(subItem)
+
+									if (!detail.recordList) {
+										detail.recordList = []
+									}
+
+									var recordItem = {
+										scaned: true,
+										isNewJobDetail: "true",
+										itemCode: subItem.itemCode,
+										itemName: subItem.itemName,
+										itemDesc1: subItem.itemDesc1,
+										itemDesc2: subItem.itemDesc2,
+										packingNumber: subItem.packingNumber,
+										toPackingNumber: subItem.toPackingNumber,
+										toBatch: subItem.toBatch,
+										batch: subItem.batch,
+										inventoryStatus: subItem.inventoryStatus,
+										qty: subItem.qty,
+										handleQty: subItem.handleQty,
+										uom: subItem.uom,
+										packUnit: subItem.packUnit,
+										packQty: subItem.packQty,
+										balanceQty: subItem.balanceQty,
+										locationCode: subItem.locationCode
+									}
+									detail.recordList.push(recordItem)
+									var mainItem = addList.find(r =>
+										r.itemCode == subItem.itemCode &&
+										r.batch == subItem.batch &&
+										r.inventoryStatus == subItem.inventoryStatus)
+
+									if (mainItem) {
+										if (this.currentEditItem.itemCode == mainItem.itemCode &&
+											this.currentEditItem.batch == mainItem.batch &&
+											this.currentEditItem.inventoryStatus == mainItem
+											.inventoryStatus) {
+											mainItem.recordList = []
+											mainItem.recordList = main
+										} else {
+											var tempRecord = mainItem.recordList.find(r =>
+												r.itemCode == subItem.itemCode &&
+												r.batch == subItem.batch &&
+												r.packingNumber == subItem.packingNumber &&
+												r.inventoryStatus == subItem.inventoryStatus)
+											if (tempRecord) {
+												tempRecord.handleQty = subItem.handleQty
+											} else {
+												mainItem.recordList.push(subItem)
+											}
+										}
+
+
+									} else {
+										//不存在添加
+										addList.push(detail)
+									}
+
+
+								}
+
+							} else if (this.manageMode == "BY_QUANTITY") {
+								var mainItem = this.dataList.find(r =>
+									r.itemCode == subItem.itemCode &&
+									r.inventoryStatus == subItem.inventoryStatus)
+								subItem.toPackingNumber = ""
+								subItem.toBatch = ""
+
+								//主列表存在数据
+								if (mainItem) {
+									mainItem.scaned = true;
+									//如果是编辑的,返回后清除record
+									if (this.currentEditItem.itemCode == mainItem.itemCode &&
+										this.currentEditItem.inventoryStatus == mainItem.inventoryStatus) {
+										mainItem.recordList = []
+										mainItem.recordList = main
+									} else {
+										var tempRecord = mainItem.recordList.find(r =>
+											r.itemCode == subItem.itemCode &&
+											r.batch == subItem.batch &&
+											r.packingNumber == subItem.packingNumber &&
+											r.inventoryStatus == subItem.inventoryStatus)
+										if (tempRecord) {
+											tempRecord.handleQty = subItem.handleQty
+										} else {
+											mainItem.recordList.push(subItem)
+										}
+									}
+
+								} else {
+									//主列表不存在数据,添加到主列表
+									var detail = this.createBackAddDetailInfo(subItem)
+									detail.batch=""
+									if (!detail.recordList) {
+										
+										detail.recordList = []
+									}
+
+									var recordItem = {
+										scaned: true,
+										isNewJobDetail: "true",
+										itemCode: subItem.itemCode,
+										itemName: subItem.itemName,
+										itemDesc1: subItem.itemDesc1,
+										itemDesc2: subItem.itemDesc2,
+										packingNumber: subItem.packingNumber,
+										toPackingNumber: subItem.toPackingNumber,
+										toBatch: subItem.toBatch,
+										batch: subItem.batch,
+										inventoryStatus: subItem.inventoryStatus,
+										qty: subItem.qty,
+										handleQty: subItem.handleQty,
+										uom: subItem.uom,
+										packUnit: subItem.packUnit,
+										packQty: subItem.packQty,
+										balanceQty: subItem.balanceQty,
+										locationCode: subItem.locationCode
+									}
+									detail.recordList.push(recordItem)
+									var mainItem = addList.find(r =>
+										r.itemCode == subItem.itemCode &&
+										r.inventoryStatus == subItem.inventoryStatus)
+									//判断主列表是否有数据
+									if (mainItem) {
+										//主列表有,如果是编辑进入的,清除,然后赋值
+										if (this.currentEditItem.itemCode == mainItem.itemCode &&
+											this.currentEditItem.inventoryStatus == mainItem
+											.inventoryStatus) {
+											mainItem.recordList = []
+											mainItem.recordList = main
+										} else {
+											var tempRecord = mainItem.recordList.find(r =>
+												r.itemCode == subItem.itemCode &&
+												r.batch == subItem.batch &&
+												r.packingNumber == subItem.packingNumber &&
+												r.inventoryStatus == subItem.inventoryStatus)
+											if (tempRecord) {
+												tempRecord.handleQty = subItem.handleQty
+											} else {
+												mainItem.recordList.push(subItem)
+											}
+										}
+
+									} else {
+										//不存在添加
+										addList.push(detail)
+									}
+
+								}
+							}
+						})
+
+					})
+					if (addList.length > 0) {
+						this.dataList = this.dataList.concat(addList)
+					}
+				}
+				this.updateList(false);
+			},
+
+
+			refreshData2222(returnData) {
 				//记录的数据刷新列表
 				//列表中删除了已经扫描的数据
 				if (returnData.recordList.length == 0) {
@@ -238,12 +473,25 @@
 								r.itemCode == subItem.itemCode &&
 								r.batch == subItem.batch &&
 								r.inventoryStatus == subItem.inventoryStatus)
-								subItem.toPackingNumber=""
+							subItem.toPackingNumber = ""
 							//主列表存在数据
 							if (mainItem) {
-								mainItem.scaned = true;
-								mainItem.recordList = []
-								mainItem.recordList.push(subItem)
+								if (mainItem.recordList && mainItem.recordList.length > 0) {
+									mainItem.scaned = true;
+									var tempRecord = mainItem.recordList.find(r =>
+										r.itemCode == subItem.itemCode &&
+										r.batch == subItem.batch &&
+										r.inventoryStatus == subItem.inventoryStatus)
+									if (tempRecord) {
+										tempRecord.handleQty = subItem.handleQty
+									} else {
+										mainItem.recordList.push(subItem)
+									}
+								} else {
+									mainItem.recordList = []
+									mainItem.recordList.push(subItem)
+								}
+
 							} else {
 								//主列表不存在数据,添加到主列表
 								var detail = this.createBackAddDetailInfo(subItem)
@@ -278,13 +526,25 @@
 							var mainItem = this.dataList.find(r =>
 								r.itemCode == subItem.itemCode &&
 								r.inventoryStatus == subItem.inventoryStatus)
-								subItem.toPackingNumber=""
-								subItem.toBatch=""
+							subItem.toPackingNumber = ""
+							subItem.toBatch = ""
 							//主列表存在数据
 							if (mainItem) {
-								mainItem.scaned = true;
-								mainItem.recordList = []
-								mainItem.recordList.push(subItem)
+								if (mainItem.recordList && mainItem.recordList.length > 0) {
+									mainItem.scaned = true;
+									var tempRecord = mainItem.recordList.find(r =>
+										r.itemCode == subItem.itemCode &&
+										r.batch == subItem.batch &&
+										r.inventoryStatus == subItem.inventoryStatus)
+									if (tempRecord) {
+										tempRecord.handleQty = subItem.handleQty
+									} else {
+										mainItem.recordList.push(subItem)
+									}
+								} else {
+									mainItem.recordList = []
+									mainItem.recordList.push(subItem)
+								}
 							} else {
 								//主列表不存在数据,添加到主列表
 								var detail = this.createBackAddDetailInfo(subItem)
@@ -344,7 +604,21 @@
 				}
 			},
 
-			currentCount(recordList) {
+			currentCount(currentItem, recordList) {
+				if (!recordList) {
+					this.showMessage("请先扫描箱码")
+					return
+				}
+
+				if (this.manageMode == 'BY_BATCH') {
+					this.currentEditItem = this.dataList.find(r => r.itemCode == currentItem.itemCode &&
+						r.batch == currentItem.batch &&
+						r.inventoryStatus == currentItem.inventoryStatus)
+				} else {
+					this.currentEditItem = this.dataList.find(r => r.itemCode == currentItem.itemCode &&
+						r.inventoryStatus == currentItem.inventoryStatus)
+				}
+
 				if (recordList) {
 					uni.navigateTo({
 						url: `/pages/count/job/countRecord?data=${encodeURIComponent(JSON.stringify(recordList))}`
@@ -431,8 +705,8 @@
 							r.locationCode == scanItem.locationCode &&
 							r.batch == scanItem.batch &&
 							r.inventoryStatus == scanItem.inventoryStatus)
-							//批次管理,包装赋值为空
-							scanItem.toPackingNumber = ""
+						//批次管理,包装赋值为空
+						scanItem.toPackingNumber = ""
 						//在任务列表中,添加到对应的recordList
 						if (mainItem) {
 							if (!mainItem.recordList) {
@@ -446,7 +720,7 @@
 								res.batch == scanItem.batch &&
 								res.inventoryStatus == scanItem.inventoryStatus
 							)
-						
+
 
 							//已经存在,数量累加
 							if (subItem) {
@@ -487,8 +761,8 @@
 							r.itemCode == scanItem.itemCode &&
 							r.locationCode == scanItem.locationCode &&
 							r.inventoryStatus == scanItem.inventoryStatus)
-							scanItem.toBatch = ""
-							scanItem.toPackingNumber = ""
+						scanItem.toBatch = ""
+						scanItem.toPackingNumber = ""
 						//在任务列表中,添加到对应的recordList
 						if (item) {
 							if (!item.recordList) {
@@ -513,6 +787,7 @@
 						} else {
 							//不在任务列表中,添加到列表中
 							var detail = this.createAddDetailInfo(scanItem)
+							detail.batch=""
 
 							if (!detail.recordList) {
 								detail.recordList = []