Explorar o código

修改咨询数据重复

wangxin hai 1 ano
pai
achega
810c736b72

+ 4 - 2
pages.json

@@ -119,7 +119,8 @@
 		{
 			"path": "pages/processInspection/consultation",
 			"style": {
-				"navigationBarTitleText": "序检"
+				"navigationBarTitleText": "序检",
+				"cache": false
 			}
 		},
 		{
@@ -167,7 +168,8 @@
 		{
 			"path": "pages/outsourcedInspection/consultation",
 			"style": {
-				"navigationBarTitleText": "外协检查"
+				"navigationBarTitleText": "外协检查",
+				"cache": false
 			}
 		}
 	],

+ 17 - 5
pages/outsourcedInspection/consultation.vue

@@ -45,11 +45,8 @@
 	} from '@/api/business/processInspection.js'
 
 	const lot = ref({});
-	const daywork = ref({
-		lot_code: 'D35400554012',
-		product_description: '电机-254.364.14552',
-		question: ''
-	})
+	// 创建一个引用来存储最后一次请求的时间戳
+	const lastRequestTimestamp = ref(0);
 
 	// 页面生命周期函数
 
@@ -84,10 +81,25 @@
 			})
 			return
 		}
+
+		const currentTime = Date.now();
+
+		// 检查是否已经过去了 2 秒
+		if (currentTime - lastRequestTimestamp.value < 2000) {
+			// 如果在 2 秒 内已经点击,那么不执行
+			uni.showToast({
+				icon: 'none',
+				title: `请勿重复点击`,
+				duration: 2000
+			})
+			return;
+		}
+
 		store.processInspection = null;
 		uni.$emit('wasteConsultationEvent', {
 			question: lot.value.question
 		})
+		lot.value = {};
 		uni.navigateBack()
 	}
 </script>

+ 7 - 2
pages/outsourcedInspection/form.vue

@@ -135,6 +135,7 @@
 	} from '@/api/business/processInspection.js'
 	const lot = ref({})
 	const unfitInfos = ref([]) //废品信息
+	const isEventTriggered = ref(false); // 创建一个标志位
 	// 创建一个引用来存储最后一次请求的时间戳
 	const lastRequestTimestamp = ref(0);
 	const consultations = ref([]) //咨询信息
@@ -353,6 +354,7 @@
 			status: 0
 		}
 		consultations.value.push(info)
+		isEventTriggered.value = true; // 更新标志位状态
 	}
 
 	/***************************** 定义了一些事件 *****************************/
@@ -386,10 +388,13 @@
 
 	// 咨询
 	const handleAddConsultation = () => {
+		isEventTriggered.value = false;
 		// 监听事件
 		uni.$once('wasteConsultationEvent', (data) => {
-			console.log("咨询事件监听");
-			addConsultation(data)
+			if (!isEventTriggered.value) {
+				// 如果事件尚未触发,则执行事件触发逻辑
+				addConsultation(data)
+			}
 		})
 
 		uni.navigateTo({

+ 7 - 8
pages/processInspection/consultation.vue

@@ -29,12 +29,13 @@
 	import {
 		ref,
 		onMounted,
+		onBeforeUnmount,
+		onUnload,
 		getCurrentInstance
 	} from 'vue'
 	import {
 		onLoad,
 		onReady,
-		onUnload,
 		onShow
 	} from '@dcloudio/uni-app'
 	import {
@@ -47,11 +48,6 @@
 	const lot = ref({});
 	// 创建一个引用来存储最后一次请求的时间戳
 	const lastRequestTimestamp = ref(0);
-	const daywork = ref({
-		lot_code: 'D35400554012',
-		product_description: '电机-254.364.14552',
-		question: ''
-	})
 
 	// 页面生命周期函数
 
@@ -69,6 +65,7 @@
 					if (res.code == 200) {
 						lot.value = data.data
 						lot.value.product = res.data
+						lot.value.question = "";
 					}
 				})
 
@@ -79,6 +76,7 @@
 
 	})
 
+
 	const handleSubmit = () => {
 		if (lot.value.question == null || lot.value.question == '') {
 			uni.showToast({
@@ -100,12 +98,13 @@
 			})
 			return;
 		}
-
 		store.processInspection = null;
 		uni.$emit('addWasteConsultationEvent', {
 			question: lot.value.question
 		})
-		uni.navigateBack()
+		lot.value = {};
+
+		uni.navigateBack();
 	}
 </script>
 

+ 9 - 2
pages/processInspection/form.vue

@@ -135,6 +135,7 @@
 		selectInspecion
 	} from '@/api/business/processInspection.js'
 	const lot = ref({})
+	const isEventTriggered = ref(false); // 创建一个标志位
 	const unfitInfos = ref([]) //废品信息
 	const consultations = ref([]) //咨询信息
 	// 创建一个引用来存储最后一次请求的时间戳
@@ -354,7 +355,8 @@
 			content: data.question,
 			status: 0
 		}
-		consultations.value.push(info)
+		consultations.value.push(info);
+		isEventTriggered.value = true; // 更新标志位状态
 	}
 
 	/***************************** 定义了一些事件 *****************************/
@@ -388,9 +390,14 @@
 
 	// 咨询
 	const handleAddConsultation = () => {
+		isEventTriggered.value = false;
 		// 监听事件
 		uni.$once('addWasteConsultationEvent', (data) => {
-			addConsultation(data)
+			if (!isEventTriggered.value) {
+				// 如果事件尚未触发,则执行事件触发逻辑
+				addConsultation(data)
+
+			}
 		})
 
 		uni.navigateTo({

+ 1 - 0
pages/sorting/consultation.vue

@@ -61,6 +61,7 @@
 		})
 	})
 
+
 	// 页面生命周期函数
 	onLoad(() => {
 

+ 8 - 1
pages/sorting/form.vue

@@ -111,6 +111,7 @@
 		store
 	} from '@/store/index.js'
 
+	const isEventTriggered = ref(false); // 创建一个标志位
 	const unfitInfos = ref([])
 	const consultations = ref([])
 	const dayworkInfo = ref({})
@@ -207,6 +208,7 @@
 				})
 			}
 		})
+		isEventTriggered.value = true; // 更新标志位状态
 		// consultations.value.push(info)
 	}
 
@@ -245,9 +247,14 @@
 
 	// 添加不合格信息
 	const handleAddConsultation = () => {
+		isEventTriggered.value = false; // 更新标志位状态
 		// 监听事件
 		uni.$once('addConsulttationEvent', (data) => {
-			addConsultation(data)
+			if (!isEventTriggered.value) {
+				// 如果事件尚未触发,则执行事件触发逻辑
+				addConsultation(data)
+			}
+
 		})
 		uni.navigateTo({
 			url: "/pages/sorting/consultation",