ezhizao_zx 1 yıl önce
ebeveyn
işleme
dd67839c98

+ 35 - 17
pages/sortBatchReporting/index.vue

@@ -10,9 +10,9 @@
 			</view>
 		</view>
 		<view class="list-title uni-row">
-			<text class="label">是否正常批次</text><text>是</text>
-			<switch class="switch" @change="switchChange" color="rgba(255,85,85,1)" />
-			<text>否</text>
+			<text class="label">是否正常批次</text>
+			<text>{{ normalStatus ? '是' : '否' }}</text>
+			<switch class="switch" :checked="normalStatus" @change="switchChange" color="rgba(255,85,85,1)" />
 		</view>
 		<view class="scroll-container">
 			<view v-if="listData.length == 0" style="color: #999;margin: 50% auto;">
@@ -205,6 +205,7 @@
 	})
 
 	function reflush() {
+		normalStatus.value = true;
 		init(store.planDetails.id);
 	}
 
@@ -274,6 +275,7 @@
 	}
 
 	function handleToreportingForWork(item) {
+		uni.$once("formBack", () => handleSearch())
 		uni.navigateTo({
 			url: "/pages/sorting/form",
 			success: function(res) {
@@ -312,21 +314,21 @@
 		selectProduction.value.open(normalStatus.value);
 	}
 
-	function switchChange(event) {
-		//异常批
-		if (event.detail.value) {
-			listData.value = tempList.value.filter(item => {
-				return item.isWasteRecycling == 1 || item.isAmend == 1;
-			});
-			normalStatus.value = 1
-		} else {
-			listData.value = tempList.value.filter(item => {
-				return item.isWasteRecycling == 0 && item.isAmend == 0;
-			});
-			normalStatus.value = 0
-		}
+	// function switchChange(event) {
+	// 	//异常批
+	// 	if (event.detail.value) {
+	// 		listData.value = tempList.value.filter(item => {
+	// 			return item.isWasteRecycling == 1 || item.isAmend == 1;
+	// 		});
+	// 		normalStatus.value = 1
+	// 	} else {
+	// 		listData.value = tempList.value.filter(item => {
+	// 			return item.isWasteRecycling == 0 && item.isAmend == 0;
+	// 		});
+	// 		normalStatus.value = 0
+	// 	}
 
-	}
+	// }
 
 	function handleScanCode() {
 		// 引入原生插件
@@ -447,6 +449,22 @@
 		reflush();
 	}
 
+	function switchChange(event) {
+		console.log(event)
+		//异常批
+		if (normalStatus.value) {
+			listData.value = tempList.value.filter(item => {
+				return item.isWasteRecycling == 1 || item.isAmend == 1;
+			});
+			normalStatus.value = false
+		} else {
+			listData.value = tempList.value.filter(item => {
+				return item.isWasteRecycling == 0 && item.isAmend == 0;
+			});
+			normalStatus.value = true
+		}
+	}
+	
 	function handleCancelTurnover(data) {
 		turnoverDelete(data).then(res => {
 			if (res.code == 200) {

+ 32 - 21
pages/sorting/form.vue

@@ -16,13 +16,14 @@
 		<!-- 不合格信息 -->
 		<view class="title unfit-title uni-row">
 			<text>不合格信息</text>
-			<view class="add-btn" @click="handleAddUnfit">添加</view>
+			<view v-if="Number(dayworkItem.status) < 3" class="add-btn" @click="handleAddUnfit">添加</view>
 		</view>
 		<view class="unfit-container">
 			<view class="unfit-item-container uni-column" v-for="(item, index) in unfitInfos" :key="index">
 				<view class="title uni-row">
 					<text>检查标准-{{ item.checkStandard }}</text>
-					<uni-icons v-if="Number(dayworkItem.status) < 3" type="trash" size="24" color="#fc6565" @click="handleDelUnfit(index)" />
+					<uni-icons v-if="Number(dayworkItem.status) < 3" type="trash" size="24" color="#fc6565"
+						@click="handleDelUnfit(index)" />
 				</view>
 				<!-- <view class="standard">检查标准:{{ item.checkStandard }}</view> -->
 				<view class="result uni-row">
@@ -60,10 +61,12 @@
 		<view class="daywork-container">
 			<view class="result uni-row">
 				<view class="label">合格量</view>
-				<input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入合格量" v-model="dayworkItem.qualifiedNum" />
+				<input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入合格量"
+					v-model="dayworkItem.qualifiedNum" />
 				<span v-else>{{ dayworkItem.qualifiedNum }}</span>
 				<view class="label" style="text-align: right; padding-right: 24rpx">废品量</view>
-				<input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入废品量" v-model="dayworkItem.rejectNum" />
+				<input v-if="Number(dayworkItem.status) < 3" type="number" placeholder="请输入废品量"
+					v-model="dayworkItem.rejectNum" />
 				<span v-else>{{ dayworkItem.rejectNum }}</span>
 			</view>
 			<view class="remark uni-row">
@@ -144,7 +147,10 @@
 			console.log(res)
 			if (res.code === 200) {
 				dayworkItem.value = res.data
-				dayworkItem.value.qualifiedNum = res.data.prodNum
+				console.log(dayworkItem.value)
+				if (dayworkItem.value.qualifiedNum === 0 && dayworkItem.value.rejectNum === 0) {
+					dayworkItem.value.qualifiedNum = res.data.prodNum
+				}
 				consultations.value = res.data.consults
 				unfitInfos.value = res.data.rejectList
 			} else {
@@ -156,16 +162,18 @@
 		})
 	}
 	const addUnfitInfo = (data) => {
-		const info = {
-			inspectionInstructionId: data.id,
-			title: data.title,
-			standard: data.standard,
-			checkStandard: data.standard,
-			type: data.type,
-			reason: '',
-			number: 1
+		console.log(data)
+		if (data.index > unfitInfos.value.length) {
+			const info = {
+				inspectionInstructionId: data.id,
+				title: data.title,
+				standard: data.standard,
+				checkStandard: data.standard,
+				type: data.type,
+				reason: ''
+			}
+			unfitInfos.value.push(info)
 		}
-		unfitInfos.value.push(info)
 	}
 	const addConsultation = (data) => {
 		const info = {
@@ -212,7 +220,8 @@
 			success: (res) => {
 				// 通过eventChannel向被打开页面传送数据
 				res.eventChannel.emit('acceptDataFromOpenerPage', {
-					data: dayworkItem.value
+					data: dayworkItem.value,
+					index: unfitInfos.value.length
 				})
 			}
 		})
@@ -285,15 +294,15 @@
 	const rejectNumberChange = () => {
 		let sumReject = 0
 		unfitInfos.value.forEach(v => {
-			sumReject += Number(v.rejectNum)
+			sumReject += v.rejectNum == null ? 0 : Number(v.rejectNum)
 		})
 		dayworkItem.value.rejectNum = sumReject
-		dayworkItem.value.qualifiedNum = dayworkItem.value.prodNum - dayworkItem.value.rejectNum
+		dayworkItem.value.qualifiedNum = dayworkItem.value.prodNum - sumReject
 		console.log(dayworkItem.value)
 	}
-	
+
 	const validHandle = () => {
-		for(let i = 0; i < unfitInfos.value.length; i++) {
+		for (let i = 0; i < unfitInfos.value.length; i++) {
 			const e = unfitInfos.value[i]
 			if (e.rejectNum == null || e.rejectNum == 0) {
 				uni.showToast({
@@ -303,7 +312,7 @@
 				return false
 			}
 		}
-		
+
 		if (!dayworkItem.value.qualifiedNum) {
 			uni.showToast({
 				icon: 'none',
@@ -322,7 +331,7 @@
 		if (!validHandle()) {
 			return
 		}
-		
+
 		const saveData = {
 			rejectList: unfitInfos.value,
 			consult: consultations.value,
@@ -332,6 +341,7 @@
 			qualifiedNum: dayworkItem.value.qualifiedNum,
 			remark: dayworkItem.value.remark
 		}
+		console.log(saveData)
 		finish(saveData).then(res => {
 			if (res.code === 200) {
 				uni.navigateBack()
@@ -358,6 +368,7 @@
 		}
 		update(saveData).then(res => {
 			if (res.code === 200) {
+				uni.$emit("formBack")
 				uni.navigateBack()
 			} else {
 				uni.showToast({

+ 4 - 1
pages/sorting/options.vue

@@ -60,6 +60,7 @@
 	// 分选标准
 	const optionList2 = ref([])
 	const dayworkItem = ref({})
+	const index = ref(0)
 	onMounted(() => {
 		const instance = getCurrentInstance().proxy
 		const eventChannel = instance.getOpenerEventChannel();
@@ -69,6 +70,7 @@
 			// 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
 			if (data && data.data) {
 				dayworkItem.value = data.data
+				index.value = data.index
 				loadInspection({
 					technologicalProcessId: dayworkItem.value.technologicalProcessId,
 					processId: dayworkItem.value.processId
@@ -139,7 +141,8 @@
 			id: data.id,
 			title: data.title,
 			standard: data.standard,
-			type: data.type
+			type: data.type,
+			index: index.value + 1
 		})
 		uni.navigateBack()
 	}