ezhizao_zx 8 tháng trước cách đây
mục cha
commit
b189382bdb

+ 17 - 1
api/business/processInspection.js

@@ -290,6 +290,22 @@ export function getInspectionChamber(data) {
 	return req.request({
 		url: '/business/inspectionChamber/list',
 		method: 'get',
-		data:data
+		data: data
+	})
+}
+// 关联批次扫码
+export function getRelateInspectionByCarrier(data) {
+	return req.request({
+		url: '/business/inspecion/getRelateInspectionByCarrier',
+		method: 'post',
+		data: data
 	})
 }
+
+export function saveOutsourceInspectionWithRelate(data) {
+	return req.request({
+		url: '/business/inspecion/saveOutsourceInspectionWithRelate',
+		method: 'post',
+		data: data
+	})
+}

+ 6 - 0
pages.json

@@ -153,6 +153,12 @@
 				"navigationBarTitleText": "外协检查"
 			}
 		},
+		{
+			"path": "pages/outsourcedInspection/relate",
+			"style": {
+				"navigationBarTitleText": "外协检查-关联批次"
+			}
+		},
 		{
 			"path": "pages/outsourcedInspection/form",
 			"style": {

+ 1 - 2
pages/auxiliaryDaywork/form.vue

@@ -58,7 +58,7 @@
 				<view style="position: absolute; top: 10rpx; right: 10rpx;">
 					<view class="add-btn" v-if="editable()"
 						style="background-color: #256bda; color: #fff; padding: 6rpx 10rpx; border-radius: 4rpx; "
-						@click="() => addReject(item, index)">添加</view>
+						@click="() => addReject(item, index)">废品信息</view>
 				</view>
 				<view class="resu uni-row">
 					<view class="label">报工人</view>
@@ -405,7 +405,6 @@
 		rejectNumberChange()
 		// console.log(currentItem.value)
 	}
-
 </script>
 
 <style lang="scss">

+ 104 - 5
pages/outsourcedInspection/form.vue

@@ -148,7 +148,20 @@
 				</view> -->
 			</view>
 		</view>
-
+		<view class="title">快速关联</view>
+		<view class="consultation-container ">
+			<view class="title unfit-title uni-row">
+				<view class="add-btn" style="background-color: #409eff;"  @click="handleAddLot">关联批次</view>
+			</view>
+				<view >
+					<zb-table
+					    :columns="relateColumn"
+					    :stripe="true"
+						:fit="true"
+						@dele="dele"
+					    :data="processInspecion.relateList"></zb-table>
+						</view>
+		</view>
 		<!-- 报工部分 -->
 		<view class="daywork-container">
 			<!--  此处后续要加上条件限制,当状态为合格或不合格的时候不能修改状态,需要有权限的人来进行修改 -->
@@ -160,8 +173,7 @@
 			</view> -->
 			<view class="result resu uni-row" style="margin-top: 20rpx;">
 				<view class="label" style="width: 170rpx;">外协检状态</view>
-				<uni-data-checkbox v-if="editable()" v-model="processInspecion.status" :localdata="range"
-					@change="change"></uni-data-checkbox>
+				<uni-data-checkbox v-if="editable()" v-model="processInspecion.status" :localdata="range"></uni-data-checkbox>
 				<view v-else class="value">{{ processInspecion.status == 1 ? '合格' : '不合格' }}
 				</view>
 			</view>
@@ -218,7 +230,8 @@
 	import {
 		saveOutsourcedInspecion,
 		getInstrumentRoomInspection,
-		selectOutsourcedInspecion
+		selectOutsourcedInspecion,
+		saveOutsourceInspectionWithRelate
 	} from '@/api/business/processInspection.js'
 	import {getURL} from '@/api/sys/user.js'
 	const lot = ref({})
@@ -246,7 +259,30 @@
 				width:60,
 				height:60
 			}
+	const relateColumn = [
+	    { name: 'lotCode', label: '批号',align:'center', width: 200},
+	    { name: 'carrierCode', label: '箱号',align:'center', width: 200 },
+		{ name: 'operation', type:'operation',label: '关联',align:'center',renders:[
+              {
+                name:'删除',
+                type:'warn',
+                func:"dele",
+				class:"buttonOp"
+              },
+            ]},
+	]
 	const initStatus = ref(0)
+	
+	function dele(ite,index) {
+		if(ite.isMaster == 1){
+			uni.showToast({
+				icon: 'none',
+				title: '主检查单,不可删除'
+			})
+		}else{
+	  	processInspecion.value.relateList.splice(index, 1);
+	  }
+	}
 	const editable = () => {
 		if (processInspecion.value.auditStatus == 1) {
 			return false
@@ -575,7 +611,7 @@ function upLoadImageHandler(arg) {
 			selectInspectionChamber.value.open()
 			console.log(processInspecion.value)
 		} else {
-			saveOutsourcedInspecion(processInspecion.value).then(res => {
+			saveOutsourceInspectionWithRelate(processInspecion.value).then(res => {
 				if (res.code == 200) {
 					let index = 0;
 
@@ -718,6 +754,29 @@ function upLoadImageHandler(arg) {
 		})
 	}
 
+	const addRelate = (relates) => {
+		processInspecion.value.relateList = relates
+	}
+
+	const handleAddLot = () => {
+		console.log('添加关联')
+		uni.$once('relateEvent', (data) => {
+			if (!isEventTriggered.value) {
+				// 如果事件尚未触发,则执行事件触发逻辑
+				addRelate(data)
+			}
+			uni.$off('relateEvent')
+		})
+		uni.navigateTo({
+			url: "/pages/outsourcedInspection/relate",
+			success: (res) => {
+				res.eventChannel.emit("outsourcedInspectionRelation", 
+					processInspecion.value
+				)
+			}
+		})
+	}
+
 	// 咨询
 	const handleAddConsultation = () => {
 		isEventTriggered.value = false;
@@ -727,6 +786,7 @@ function upLoadImageHandler(arg) {
 				// 如果事件尚未触发,则执行事件触发逻辑
 				addConsultation(data)
 			}
+			uni.$off('wasteConsultationEvent')
 		})
 
 		uni.navigateTo({
@@ -1026,4 +1086,43 @@ function upLoadImageHandler(arg) {
 			
 		}
 	}
+	
+	.consultation-container {
+		margin: 0 16rpx;
+		padding: 24rpx;
+		background-color: #ffffff;
+		border-radius: 8rpx;
+
+		.consultation-item-container {
+			margin-bottom: 24rpx;
+			border-bottom: 2px solid #888888;
+			padding-bottom: 24rpx;
+		}
+
+		.consultation-item-container:last-child {
+			margin-bottom: 0;
+			border-bottom: 0;
+			padding-bottom: 0;
+		}
+
+		.question,
+		.answer {
+			.label {
+				justify-content: space-between;
+				margin-bottom: 16rpx;
+				font-weight: 700;
+			}
+
+			.content {
+				line-height: 40rpx;
+			}
+		}
+
+		.answer {
+			margin-top: 24rpx;
+		}
+	}
+	.zb-table .item-tr {
+                flex-direction: row;
+        }
 </style>

+ 446 - 0
pages/outsourcedInspection/relate.vue

@@ -0,0 +1,446 @@
+<template>
+	<view class="uni-column" style="padding: 24rpx">
+		<view class="consultation-container ">
+			<view>
+				<zb-table :columns="relateColumn" :stripe="true" :fit="true" @dele="dele" :data="relateList"></zb-table>
+			</view>
+		</view>
+		<view class='btn uni-row'>
+			<button class='bottom-btn right-btn' type="primary" @click="handleContinue">继续扫码</button>
+			<button class='bottom-btn right-btn' type="primary" @click="handleConfirm">确认关联</button>
+		</view>
+
+	</view>
+	<view
+		style="background-color: #99999999; z-index: 5; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"
+		v-if="loading">
+	</view>
+</template>
+
+<script setup>
+	import {
+		ref,
+		onMounted,
+		getCurrentInstance
+	} from 'vue'
+	import {
+		store
+	} from '@/store/index.js'
+	import {
+		onShow
+	} from '@dcloudio/uni-app'
+	import {
+		getRelateInspectionByCarrier
+	} from '@/api/business/processInspection.js'
+
+
+	const lotReporting = ref(null)
+	const workshopId = ref(null);
+	const searchRef = ref(null);
+	const keyword = ref('')
+	const loading = ref(false)
+	const relateList = ref([])
+	const processInspection = ref(null)
+
+	const form = ref([]); //表单数据true
+	const checkAll = ref(false); //是否全选
+
+	// 创建一个引用来存储最后一次请求的时间戳
+	const lastRequestTimestamp = ref(0);
+	const listData = ref([]);
+	const allData = ref([])
+	const selection = ref([]); //选中数据
+	const workshopList = ref([]); //车间数据
+	const relateColumn = [{
+			name: 'lotCode',
+			label: '批号',
+			align: 'center',
+			width: 800
+		},
+		{
+			name: 'carrierCode',
+			label: '箱号',
+			align: 'center',
+			width: 800
+		},
+		{
+			name: 'operation',
+			type: 'operation',
+			label: '关联',
+			align: 'center',
+			renders: [{
+				name: '删除',
+				type: 'warn',
+				func: "dele",
+				class: "buttonOp"
+			}, ]
+		},
+	]
+	onShow(() => {
+		init()
+	})
+	onMounted(() => {
+		const instance = getCurrentInstance().proxy
+		const eventChannel = instance.getOpenerEventChannel();
+		eventChannel.on('outsourcedInspectionRelation', function(data) {
+			console.log('show')
+			// console.log(lot.value)
+			console.log('outsourcedInspectionRelation', data)
+			// 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
+			relateList.value = data.relateList.map(v => ({
+				...v
+			}))
+			processInspection.value = data
+		})
+	})
+	//初始化
+	function init() {
+		// console.log(store.curDeptDetails)
+		// uni.showLoading({
+		// 	title: '加载中'
+		// });
+		checkAll.value = false
+
+	}
+
+	// 搜索按钮操作
+	function handleSearch() {
+		searchRef.value.open();
+	}
+
+	function refreshSearch(input) {
+		// console.log(input)
+		keyword.value = input
+		handleChangeWorkshop(workshopId.value)
+	}
+
+	function handleAdd() {
+		const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
+		if (mpaasScanModule) {
+			// 调用插件的 mpaasScan 方法
+			mpaasScanModule.mpaasScan({
+					// 扫码识别类型,参数可多选,qrCode、barCode,
+					// 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
+					scanType: ["qrCode", "barCode"],
+					// 是否隐藏相册,默认false不隐藏
+					hideAlbum: false,
+				},
+				(ret) => {
+					let vehicleObj = {
+						carrierCode: ret.resp_result
+					};
+					if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
+						uni.showToast({
+							icon: "none",
+							title: "请扫载具码",
+							duration: 1000
+						})
+						return;
+					}
+					getRelateInspectionByCarrier({
+						carrierCode: vehicleObj.carrierCode,
+						...processInspection.value
+					}).then(res => {
+						console.log(res)
+						if (res.code == 200) {
+							if (res.data.length > 0 && res.data.filter(e => !relateList.value.some(t => t
+									.id === e.id)).length > 0) {
+								uni.showToast({
+									title: '载具绑定批次已质检或已绑定',
+									icon: 'none'
+								})
+							} else {
+								relateList.value.push(...res.data.filter(e => !relateList.value.some(t => t
+									.id === e.id)))
+							}
+						} else {
+							uni.showToast({
+								icon: 'none',
+								title: res.msg,
+								duration: 2000
+							})
+						}
+					}).catch(err => {
+						console.log(err)
+					})
+				}
+			);
+		} else {
+			// 测试时用
+			getRelateInspectionByCarrier({
+				carrierCode: '006522',
+				...processInspection.value
+			}).then(res => {
+				console.log(res)
+				if (res.code == 200) {
+					console.log(relateList.value)
+					console.log(res.data.filter(e => !relateList.value
+						.some(t => t.lotId === e.lotId)).length)
+					if (res.data.length > 0 && res.data.filter(e => !relateList.value
+							.some(t => t.lotId === e.lotId)).length > 0) {
+						relateList.value.push(...res.data.filter(e => !relateList.value.some(t => t.lotId === e
+							.lotId)))
+					} else {
+						uni.showToast({
+							title: '载具绑定批次已质检或已绑定',
+							icon: 'none'
+						})
+					}
+				} else {
+					uni.showToast({
+						icon: 'none',
+						title: res.msg,
+						duration: 2000
+					})
+				}
+			}).catch(err => {
+				console.log(err)
+			})
+		}
+		// lotReporting.value.open(data);
+	}
+
+	function handleContinue() {
+		// lotReporting.value.open('test')
+		handleAdd()
+	}
+
+	// 全选按钮操作
+	function handleAll() {
+		//清空选中数据
+		selection.value.length = 0;
+		if (checkAll.value) {
+			//变更选中状态
+			checkAll.value = false;
+		} else {
+			checkAll.value = true;
+			listData.value.findIndex(item => handleSelection(item))
+		}
+	}
+
+	function handleChangeWorkshop(arg) {
+		const workshop = workshopList.value.find(v => v.value === arg)
+		listData.value = allData.value.filter(v => workshop.depts.some(e => e.deptId === v.quickInfo.deptId) && (v.lotCode
+			.includes(keyword.value) || v.productDescription.includes(keyword.value) || v.carrierName.includes(
+				keyword.value)))
+		selection.value = []
+	}
+
+
+	function isSelected(item) {
+		return selection.value.includes(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); // 选中
+		}
+		if (selection.value.length == listData.value.length) {
+			checkAll.value = true;
+		} else {
+			checkAll.value = false;
+		}
+	}
+
+	function dele(ite, index) {
+		if (ite.isMaster == 1) {
+			uni.showToast({
+				icon: 'none',
+				title: '主检查单,不可删除'
+			})
+		} else {
+			relateList.value.splice(index, 1);
+		}
+	}
+
+  function handleConfirm() {
+    
+		uni.$emit('relateEvent', relateList.value)
+		uni.navigateBack()
+  }
+</script>
+
+<style lang="scss">
+	$nav-height: 60rpx;
+
+	.bottom-btn-container {
+		position: fixed;
+		top: 80%;
+		right: 20rpx;
+		left: 20rpx;
+
+		.start-batch-btn {
+			margin-bottom: 24rpx;
+			border-radius: 8rpx;
+			background-color: #00e2a6;
+			width: 80%;
+		}
+	}
+
+	.active {
+		flex: 1;
+		height: 40rpx;
+		background-color: #5e6eff;
+		border: 1px solid #5e6eff;
+		color: #000000;
+	}
+
+	.select {
+		flex: 1;
+		height: 40rpx;
+		// font-size: 20rpx;
+		background-color: #5e6eff;
+		border: 1px solid #5e6eff;
+		color: #ffffff;
+
+	}
+
+
+	.btn {
+		position: fixed;
+		right: 0;
+		bottom: 0;
+		left: 0;
+		height: 100rpx;
+		padding: 16rpx 24rpx;
+		align-items: center;
+		background-color: #FFFFFF;
+		justify-content: space-between;
+
+		.bottom-btn {
+			flex: 1;
+			font-size: 28rpx;
+			color: #FFFFFF;
+
+			&.left-btn {
+				// background-color: #a4adb3;
+			}
+
+			&.right-btn {
+				background-color: #1684fc;
+				margin-left: 24rpx;
+
+			}
+		}
+	}
+
+	.box-bg {
+		width: 100%;
+		background-color: #F5F5F5;
+		padding: 5rpx 0;
+		justify-content: space-around;
+		align-items: center;
+
+		.input-view {
+			width: 100%;
+			flex: 4;
+			background-color: #f8f8f8;
+			height: $nav-height;
+			border: 1rpx solid #999;
+			border-radius: 15rpx;
+			padding: 0 15rpx;
+			flex-wrap: nowrap;
+			margin: 0 10rpx 20rpx;
+			line-height: $nav-height;
+
+			.input-uni-icon {
+				line-height: $nav-height;
+			}
+
+			.nav-bar-input {
+				width: 80%;
+				height: $nav-height;
+				line-height: $nav-height;
+				padding: 0 5rpx;
+				background-color: #f8f8f8;
+			}
+		}
+
+		.search {
+			width: 20%;
+			text-align: center;
+			color: #808080;
+			margin-top: -20rpx;
+		}
+	}
+
+	.list-item {
+		background-color: #fff;
+		position: relative;
+		padding: 16rpx;
+		padding-bottom: 24rpx;
+		border-radius: 24rpx;
+		margin-bottom: 24rpx;
+
+		.title-container {
+			justify-content: space-between;
+			margin-top: 8rpx;
+			margin-bottom: 16rpx;
+
+			.title {
+				height: 48rpx;
+				align-items: center;
+
+				.label {
+					font-size: 32rpx;
+					font-weight: bold;
+
+					&.code {
+						margin-left: 8rpx;
+					}
+				}
+			}
+
+			.tag {
+				border: 1px solid #1ce5b0;
+				background-color: #f6fffd;
+				padding: 8rpx;
+				border-radius: 8rpx;
+
+				.label {
+					color: #1ce5b0;
+					font-size: 24rpx;
+				}
+
+				&.not-start {
+					border: 1px solid #bbbbbb;
+					background-color: #f5f5f5;
+
+					.label {
+						color: #bbbbbb;
+					}
+				}
+			}
+		}
+
+
+		.item-info {
+			margin-bottom: 8rpx;
+
+			.label {
+				font-size: 28rpx;
+				width: 150rpx;
+				color: #808080;
+
+				&.right {
+					flex: 1;
+					color: #000000;
+				}
+			}
+		}
+	}
+
+	.selected {
+		border: 1rpx solid #c0c4fc;
+		background-color: #c0c4fc;
+		/* 选中之后样式 */
+	}
+
+	.zb-table .item-tr {
+		flex-direction: row;
+	}
+</style>

+ 2 - 2
pages/outsourcedInspection/scan.vue

@@ -198,8 +198,8 @@
 									};
 									lot.value.carrierCode = result.carrierCode
 									carrierCode.value = result.carrierCode;
-									lot.value.inspectionCarrierId = '1803605009546395650'
-									lot.value.inspectionCarrierCode = "300039"
+									lot.value.inspectionCarrierId = '1803605009546395652'
+									lot.value.inspectionCarrierCode = "300041"
 									// console.log("res", res);
 									uni.hideLoading();
 									// 判断是否批次号和检查箱码都扫完