ezhizao_zx 10 months ago
parent
commit
4d68337d9b
2 changed files with 65 additions and 71 deletions
  1. 17 0
      api/business/auxiliaryDaywork.js
  2. 48 71
      pages/auxiliaryDaywork/form.vue

+ 17 - 0
api/business/auxiliaryDaywork.js

@@ -45,4 +45,21 @@ export function getAuxiliaryDayworkItemById(data) {
 		method: 'post',
 		data: data
 	})
+}
+
+export function finishedDaywork(data) {
+	return req.request({
+		url: '/business/auxiliaryDaywork/finished',
+		method: 'post',
+		data: data
+	})
+}
+
+export function pauseDaywork(data) {
+	return req.request({
+		url: '/business/auxiliaryDaywork/pause',
+		method: 'post',
+		data: data
+	})
+
 }

+ 48 - 71
pages/auxiliaryDaywork/form.vue

@@ -278,49 +278,7 @@
 	function endWork() {
 		let unf = unfitInfos.value;
 		for (var i = 0; i < unfitInfos.value.length; i++) {
-			console.log("废品信息");
-			// if (!unf[i].checkStandard && !unf[i].checkResult && !unf[i].rejectNum) {
-			// 	uni.showToast({
-			// 		icon: 'none',
-			// 		title: "废品信息不能为空",
-			// 		duration: 2000
-			// 	})
-			// 	return;
-			// }
-			if (unf[i].checkStandard == '' || unf[i].checkStandard == null) {
-				uni.showToast({
-					icon: 'none',
-					title: "检查标准不能为空",
-					duration: 2000
-				})
-				return;
-			}
-			// if (unf[i].checkResult == '' || unf[i].checkResult == null) {
-			// 	uni.showToast({
-			// 		icon: 'none',
-			// 		title: "检查结果不能为空",
-			// 		duration: 2000
-			// 	})
-			// 	return;
-
-			// }
-			if (unf[i].rejectNum == null) {
-				uni.showToast({
-					icon: 'none',
-					title: "废品量不能为空",
-					duration: 2000
-				})
-				return;
-			}
-			if (unf[i].rejectNum < 0 || unf[i].examiningNum < 0 || unf[i].disqualificationNum < 0) {
-				uni.showToast({
-					icon: 'none',
-					title: '检查量,不良品量,废品量不能小于0',
-					duration: 2000
-				})
-				return
-			}
-			if (unf[i].examiningNum > auxiliaryDayworkItem.value.lot.pudName) {
+			if (unf[i].rejectNum > unf[i].prodNum) {
 				uni.showToast({
 					icon: 'none',
 					title: '检查量不能大于投产量'
@@ -333,36 +291,61 @@
 		unfitInfos.value.forEach(v => {
 			sumReject += Number(v.rejectNum)
 		})
-		if (auxiliaryDayworkItem.value.rejectNum != sumReject) {
+		auxiliaryDayworkItem.value.rejectNum = sumReject
+		endSave();
+
+
+	}
+
+	// 暂停报工按钮
+	function pauseWork() {
+		pauseSave()
+	}
+
+	function endSave() {
+		const currentTime = Date.now();
+
+		// 检查是否已经过去了 2 秒
+		if (currentTime - lastRequestTimestamp.value < 2000) {
+			// 如果在 2 秒 内已经点击,那么不执行
 			uni.showToast({
 				icon: 'none',
-				title: "废品量与废品信息不一致",
+				title: `请勿重复点击`,
 				duration: 2000
 			})
 			return;
 		}
-		if (auxiliaryDayworkItem.value.rejectNum > auxiliaryDayworkItem.value.lot.pudName) {
-			uni.showToast({
-				icon: 'none',
-				title: '废品量不能大于投产量'
-			})
-			return
-		}
-		if (auxiliaryDayworkItem.value.disqualificationNum > auxiliaryDayworkItem.value.lot.pudName) {
-			uni.showToast({
-				icon: 'none',
-				title: '不良品量不能大于投产量'
-			})
-			return
-		}
 
-		save();
+		let pages = getCurrentPages();
+		auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
+		auxiliaryDayworkItem.value.user = store.userInfo;
+
+		finishedDaywork(auxiliaryDayworkItem.value).then(res => {
+			if (res.code == 200) {
+				let index = 0;
 
+				for (let i = 0; i < pages.length; i++) {
 
-	}
+					if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
 
+						index = pages.length - i - 1;
+					}
+				}
+				console.log("index", index);
+				uni.navigateBack({
+					delta: index
+				});
+			} else {
+				uni.showToast({
+					icon: 'none',
+					title: res.msg,
+					duration: 2000
+				})
+			}
+		});
+	}
 
-	function save() {
+	function pauseSave() {
 		const currentTime = Date.now();
 
 		// 检查是否已经过去了 2 秒
@@ -375,19 +358,17 @@
 			})
 			return;
 		}
-
 		let pages = getCurrentPages();
-		auxiliaryDayworkItem.value.dayworkItemConsults = consultations.value;
-		auxiliaryDayworkItem.value.dayworkItemRejects = unfitInfos.value;
+		auxiliaryDayworkItem.value.rejectList = unfitInfos.value;
 		auxiliaryDayworkItem.value.user = store.userInfo;
 
-		saveOutsourcedInspecion(auxiliaryDayworkItem.value).then(res => {
+		pauseDaywork(auxiliaryDayworkItem.value).then(res => {
 			if (res.code == 200) {
 				let index = 0;
 
 				for (let i = 0; i < pages.length; i++) {
 
-					if (pages[i].$page.fullPath == "/pages/outsourcedInspection/index") {
+					if (pages[i].$page.fullPath == "/pages/auxiliaryDaywork/index") {
 
 						index = pages.length - i - 1;
 					}
@@ -405,10 +386,6 @@
 			}
 		});
 	}
-
-
-
-
 	//咨询样式
 	function selectType(item) {
 		for (var i = 0; i < consul.length; i++) {