mao 1 year ago
parent
commit
f76b2a3340

+ 40 - 15
components/dialog-selectEquipment/dialog-selectEquipment.vue

@@ -24,7 +24,7 @@
 		getUserInfo
 		getUserInfo
 	} from '@/api/login/index.js'
 	} from '@/api/login/index.js'
 	import {
 	import {
-		saveDayWorkItem
+		saveDayWorkItem,getDayWorkItemList
 	} from '@/api/business/dayWorkItem.js'
 	} from '@/api/business/dayWorkItem.js'
 	import {
 	import {
 		store
 		store
@@ -35,7 +35,7 @@
 
 
 	const baseDialog = ref(null)
 	const baseDialog = ref(null)
 	const selection = ref([])
 	const selection = ref([])
-	const equiments = ref([])
+	const equiments = ref([])    // 接收设备列表信息
 	const emit = defineEmits(['handleAddDayWorkItem'])
 	const emit = defineEmits(['handleAddDayWorkItem'])
 	const userId = ref(null)
 	const userId = ref(null)
 	const firstItem = ref(null);
 	const firstItem = ref(null);
@@ -43,24 +43,39 @@
 
 
 	onLoad(() => {
 	onLoad(() => {
 		userId.value = store.userInfo.userId || "";
 		userId.value = store.userInfo.userId || "";
-		init();
 	})
 	})
 
 
 	function init() {
 	function init() {
 		let reqParam = {
 		let reqParam = {
 			userId: userId.value,
 			userId: userId.value,
-			processId: store.dayworkInfo.currentProcess.id
+			processId: store.dayworkInfo.currentProcess.id,
 		}
 		}
 		getUserequipmentList(reqParam).then(res => {
 		getUserequipmentList(reqParam).then(res => {
-			console.log(res)
-			equiments.value = res.rows
+			if(res.code == 200){
+				equiments.value = res.rows
+				getDayWorkItemList({
+					userId: store.userInfo.userId,
+					dayworkId: store.dayworkInfo.id,
+					status: 1
+				}).then(response => {
+					// 过滤人员可选择的设备列表(选择之后不予展示)
+					for (let i = 0; i < response.rows.length; i++) {
+						for (let j = 0; j < equiments.value.length; j++) {
+							if(response.rows[i].equipmentDetailId == equiments.value[j].equipmentDetailId){
+								equiments.value.splice(j,1);
+							}
+						}
+					}
+					console.log(equiments.value)
+					baseDialog.value.open()	
+				})
+			}
 		})
 		})
 	}
 	}
 
 
 	function open(data) {
 	function open(data) {
 		firstItem.value = data;
 		firstItem.value = data;
-		console.log(firstItem.value)
-		baseDialog.value.open()
+		init();
 	}
 	}
 
 
 	function close() {
 	function close() {
@@ -76,16 +91,24 @@
 	}
 	}
 
 
 	function handleSelection(item) {
 	function handleSelection(item) {
-		const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
-		if (buttonIndex > -1) {
-			selection.value.splice(buttonIndex, 1); // 取消选中
-		} else {
-			selection.value.push(item); // 选中
-		}
+		// const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
+		// if (buttonIndex > -1) {
+		// 	selection.value.splice(buttonIndex, 1); // 取消选中
+		// } else {
+		// 	selection.value.push(item); // 选中
+		// }
+		selection.value[0] = item;
 	}
 	}
 
 
 	function handleStart() {
 	function handleStart() {
-		console.log(selection.value)
+		if(selection.value.length == 0){
+			uni.showToast({
+				icon: "error",
+				title: "未选择设备"
+			})
+			close();
+			return;
+		}
 		close();
 		close();
 		if (firstItem.value) {
 		if (firstItem.value) {
 			for (var i = 0; i < selection.value.length; i++) {
 			for (var i = 0; i < selection.value.length; i++) {
@@ -100,9 +123,11 @@
 			}
 			}
 			emit('handleAddDayWorkItem', sendReqParam.value);
 			emit('handleAddDayWorkItem', sendReqParam.value);
 			selection.value = [];
 			selection.value = [];
+			equiments.value = [];
 		}else{
 		}else{
 			console.log(selection.value);
 			console.log(selection.value);
 			emit('handleAddDayWorkItem', selection.value);
 			emit('handleAddDayWorkItem', selection.value);
+			equiments.value = [];
 			selection.value = [];
 			selection.value = [];
 		}
 		}
 	}
 	}

+ 13 - 12
pages/reportingForWork/index.vue

@@ -172,18 +172,19 @@
 	}
 	}
 
 
 	function handleStartProcessing(item) {
 	function handleStartProcessing(item) {
-		if(item){
-			selectEquipment.value.open(item);
-		}else{
-			if (flag.value) {
-				uni.showToast({
-					icon: "none",
-					title: "报工未结束或工序已完成"
-				})
-			} else {
-				selectEquipment.value.open(item);
-			}
-		}
+		// if(item){
+		// 	selectEquipment.value.open(item);
+		// }else{
+		// 	if (flag.value) {
+		// 		uni.showToast({
+		// 			icon: "none",
+		// 			title: "报工未结束或工序已完成"
+		// 		})
+		// 	} else {
+		// 		selectEquipment.value.open(item);
+		// 	}
+		// }
+		selectEquipment.value.open(item);
 	}
 	}
 
 
 	/**
 	/**