guoyujia 2 月之前
父节点
当前提交
ca5bc1b967
共有 1 个文件被更改,包括 106 次插入72 次删除
  1. 106 72
      pages/reportHistory/index.vue

+ 106 - 72
pages/reportHistory/index.vue

@@ -179,7 +179,8 @@
 		onShow
 	} from '@dcloudio/uni-app'
 	import {
-		getDayWorkItemHistory
+		getDayWorkItemHistory,
+		getDayWorkItemFinishHistory
 	} from "@/api/business/dayWorkItem.js"
 	import {
 		store
@@ -189,7 +190,7 @@
 	} from '@/utils/common.js'
 
 	const listDaywork = ref([])
-	const listData = ref([]) // 回显 	
+	const listData = ref([]) // 回显
 	const listDataItem = ref([])
 	const lotInfo = ref(null) // 详情弹窗
 	const selectDate = ref('')
@@ -278,72 +279,98 @@
 					listDataItem.value[i].taskTime = toHHmmss(timeStamp);
 				}
 				// 转为二维数组
-				console.log(listDataItem.value)
-				const groupedData = listDataItem.value.reduce((accumulator, currentItem) => {
-					// 获取当前对象的日期字符串
-					const dateString = currentItem.startTime.split(' ')[0];
-					// 如果有这个日期,则 push 到对应的数组中,否则创建一个新的数组
-					if (accumulator[dateString]) {
-						accumulator[dateString].push(currentItem);
-					} else {
-						accumulator[dateString] = [currentItem];
-					}
-					return accumulator;
-				}, {});
-
-				var hasEndTime = false
-				// 0718
-				for (var i = 0; i < listData.value.length; i++) {
-					var current = listData.value[i];
-					var found = false;
-					var endTimeStatus = "";
-					for (var j = 0; j < listDaywork.value.length; j++) {
-						if (listDaywork.value[j].dayworkId === current.dayworkId && listDaywork.value[j]
-							.processStepNumber === current.processStepNumber) {
-							listDaywork.value[j].qualifiedNum += current.qualifiedNum;
-							listDaywork.value[j].rejectSum += current.rejectSum;
-							if (listDaywork.value[j].equipmentDetailCode != null && listDaywork.value[j]
-								.equipmentDetailCode != undefined && listDaywork.value[j].equipmentDetailCode !=
-								listDaywork.value[j].equipmentDetailCode) {
-								listDaywork.value[j].equipmentDetailCode = listDaywork.value[j]
-									.equipmentDetailCode + "," + current.equipmentDetailCode
-							}
-							found = true;
-							break;
-						}
-					}
-
-					if (current.status == 3) {
-						console.log("999")
-						hasEndTime = true
-						endTimeStatus = current.endTime;
-						console.log(endTimeStatus)
-					}
-					if (!hasEndTime && current.status != 3) {
-						console.log("777")
-						endTimeStatus = null;
-					}
-					if (!found && current.status == 3) {
-						console.log()
-						listDaywork.value.push({
-							processAlias: current.process.processAlias,
-							equipmentDetailCode: current.equipmentDetailCode,
-							lotCode: current.lotCode,
-							productDescription: current.productDescription,
-							daywork: current.daywork,
-							dayworkId: current.dayworkId,
-							processId: current.processId,
-							qualifiedNum: current.qualifiedNum,
-							rejectSum: current.rejectSum,
-							endTime: endTimeStatus,
-							adoptStatus: current.adoptStatus == null ? null : current.adoptStatus
-
-						});
-					}
-				}
-
-				console.log(listData.value);
-				console.log(listDaywork.value);
+				// console.log(listDataItem.value)
+				// const groupedData = listDataItem.value.reduce((accumulator, currentItem) => {
+				// 	// 获取当前对象的日期字符串
+				// 	const dateString = currentItem.startTime.split(' ')[0];
+				// 	// 如果有这个日期,则 push 到对应的数组中,否则创建一个新的数组
+				// 	if (accumulator[dateString]) {
+				// 		accumulator[dateString].push(currentItem);
+				// 	} else {
+				// 		accumulator[dateString] = [currentItem];
+				// 	}
+				// 	return accumulator;
+				// }, {});
+
+				// var hasEndTime = false
+				// // 0718
+				// for (var i = 0; i < listData.value.length; i++) {
+				// 	var current = listData.value[i];
+				// 	var found = false;
+				// 	var endTimeStatus = "";
+				// 	console.log(current, i)
+				// 	console.log(listDaywork.value, i)
+				// 	console.log(listDaywork.value.length > 0)
+				// 	for (var j = 0; j < listDaywork.value.length; j++) {
+				// 		console.log(listDaywork.value[j])
+				// 		if (listDaywork.value[j].dayworkId === current.dayworkId && listDaywork.value[j]
+				// 			.processStepNumber === current.processStepNumber) {
+				// 			listDaywork.value[j].qualifiedNum = listData.value.filter(v => v.dayworkId == current
+				// 				.dayworkId && v.processStepNumber == current.processStepNumber).reduce((acc,
+				// 				item) => acc + item.qualifiedNum, 0);
+				// 			console.log("666", listData.value.filter(v => v.dayworkId == current
+				// 				.dayworkId && v.processStepNumber == current.processStepNumber))
+				// 			listDaywork.value[j].rejectNum = listData.value.filter(v => v.dayworkId == current
+				// 				.dayworkId && v.processStepNumber == current.processStepNumber).reduce((acc,
+				// 				item) => acc + item.rejectNum, 0);
+				// 			// listDaywork.value[j].qualifiedNum += current.qualifiedNum;
+				// 			// listDaywork.value[j].rejectSum += current.rejectSum;
+				// 			if (listDaywork.value[j].equipmentDetailCode != null && listDaywork.value[j]
+				// 				.equipmentDetailCode != undefined && listDaywork.value[j].equipmentDetailCode !=
+				// 				listDaywork.value[j].equipmentDetailCode) {
+				// 				listDaywork.value[j].equipmentDetailCode = listDaywork.value[j]
+				// 					.equipmentDetailCode + "," + current.equipmentDetailCode
+				// 			}
+				// 			found = true;
+				// 			break;
+				// 		}
+				// 	}
+
+				// 	if (current.status == 3) {
+				// 		console.log("999")
+				// 		hasEndTime = true
+				// 		endTimeStatus = current.endTime;
+				// 		console.log(endTimeStatus)
+				// 	}
+				// 	if (!hasEndTime && current.status != 3) {
+				// 		console.log("777")
+				// 		endTimeStatus = null;
+				// 	}
+				// 	if (!found && current.status == 3) {
+				// 		console.log()
+				// 		listDaywork.value.push({
+				// 			processAlias: current.process.processAlias,
+				// 			equipmentDetailCode: current.equipmentDetailCode,
+				// 			lotCode: current.lotCode,
+				// 			productDescription: current.productDescription,
+				// 			daywork: current.daywork,
+				// 			dayworkId: current.dayworkId,
+				// 			processId: current.processId,
+				// 			qualifiedNum: current.qualifiedNum,
+				// 			rejectSum: current.rejectSum,
+				// 			endTime: endTimeStatus,
+				// 			adoptStatus: current.adoptStatus == null ? null : current.adoptStatus,
+				// 			processStepNumber: current.processStepNumber
+				// 		});
+				// 	}
+				// }
+
+				// console.log(listData.value);
+				// console.log(listDaywork.value);
+
+				// 时间下拉
+				// for (let i = 0; i < Object.keys(groupedData).length; i++) {
+				// 	dateList.value[i] = {
+				// 		text: Object.keys(groupedData)[i],
+				// 		value: Object.keys(groupedData)[i]
+				// 	}
+				// }
+				// listData.value = groupedData;
+				// if(dateList.value.length > 0){
+				// 	listDataItem.value = listData.value[dateList.value[0].value]
+				// 	selectDate.value = dateList.value[0].value;
+				// }
+				// console.log(groupedData)
 				uni.hideLoading();
 			} else {
 				uni.showToast({
@@ -357,16 +384,23 @@
 	}
 
 	function handleCheckTab() {
-		editStatus.value = true
+		uni.showLoading({
+			title: '加载中'
+		});
+		getDayWorkItemFinishHistory(startTime.value, endTime.value).then(res => {
+			listDaywork.value = res.data
+			editStatus.value = true
+			uni.hideLoading()
+		})
 	}
 
 	function handleCheckTabHis() {
 		editStatus.value = false
 	}
 
-	function change() {
-		listDataItem.value = listData.value[selectDate.value]
-	}
+	// function change() {
+	// 	listDataItem.value = listData.value[selectDate.value]
+	// }
 
 	// function handleOpenLonInfo() {
 	// 	lotInfo.value.open();