Kaynağa Gözat

feat(质检工单): 完善质检报工页面,添加状态显示、工单剩余样品数及输入校验逻辑

yusheng 5 ay önce
ebeveyn
işleme
afd495908f

+ 9 - 0
api/inspectionWork/index.js

@@ -37,3 +37,12 @@ export async function update(data) {
 	return Promise.reject(new Error(res.message));
 }
 
+//单个质检项保存
+export async function exeReportWorkBySingleTemplate(data) {
+	const res = await postJ(Vue.prototype.apiUrl + `/qms/quality_work_order/exeReportWorkBySingleTemplate`, data);
+	if (res.code == 0) {
+		return res.message;
+	}
+	return Promise.reject(new Error(res.message));
+}
+

+ 44 - 24
pages/maintenance/check/components/CheckCard.vue

@@ -26,14 +26,25 @@
 			</view>
 			<view class="cell-content" v-else>无</view>
 		</view> -->
+		<view class="card-cell">
+			<text class="label">状态</text>
+			<text class="cell-content">
+
+				<view v-if="type == 'view'">
+					<div v-if="item.status == -1" style="color: red">异常</div>
+					<div v-else style="color: green">正常</div>
+				</view>
+				<view v-else>
+					<uni-data-picker @change="statusChange" style="width:100%" v-model="item.status" placeholder="请选择"
+						:localdata="statusList" :clear-icon="false">
+					</uni-data-picker>
+				</view>
+			</text>
+		</view>
 		<view class="card-cell">
 			<text class="label">结果</text>
 			<view class="cell-content">
-				<view class="content-status" v-if="type == 'view'">
-					<!-- {{ item.isNormal?'正常':'异常' }} -->
-					<div v-if="item.status == 0" style="color: green">正常</div>
-					<div v-else-if="item.status == -1" style="color: red">异常</div>
-				</view>
+
 				<textarea v-if="type !== 'view'" placeholder="请输入" v-model="item.result"
 					@input="inputChange($event, item)" />
 				<view class="result-text" v-else>{{ item.result }}</view>
@@ -84,7 +95,7 @@
 				</view>
 				<view class="photo_list">
 					<PreviewPhoto :type="type" @imagedelete="imagedelete" :imageList="photoList" />
-				<!-- 	<u-album :urls="photoList" :rowCount="3" @delete="handleDelete" :maxCount="9" :singleSize="180"
+					<!-- 	<u-album :urls="photoList" :rowCount="3" @delete="handleDelete" :maxCount="9" :singleSize="180"
 						:multipleSize="180"></u-album> -->
 				</view>
 			</view>
@@ -96,7 +107,9 @@
 <script>
 	import PreviewPhoto from './PreviewPhoto.vue'
 	export default {
-		components:{ PreviewPhoto },
+		components: {
+			PreviewPhoto
+		},
 		props: {
 			item: {
 				type: Object,
@@ -111,12 +124,12 @@
 		data() {
 			return {
 				statusList: [{
-						label: '正常',
-						status: 0
+						text: '正常',
+						value: 1
 					},
 					{
-						label: '异常',
-						status: -1
+						text: '异常',
+						value: -1
 					}
 				]
 			}
@@ -130,13 +143,20 @@
 		},
 		methods: {
 			inputChange(obj, item) {
-				console.log(item, 'item --')
-				if (obj.target.value.length > 0) {
+				if (obj.target.value.length > 0 && obj.target.value != '正常') {
 					item.status = -1
 				} else {
-					item.status = 0
+					item.status = 1
 				}
 			},
+			statusChange() {
+				if (this.item.status == 1) {
+					this.item.result = '正常'
+				} else {
+					this.item.result = '异常'
+				}
+
+			},
 			changeStatus(item, it) {
 				item.status = it.status
 			},
@@ -145,16 +165,16 @@
 			// 	console.log(e, 'eeeee');
 			// 	console.log(i, 'iiiiiiiiiiii')
 			// },
-			
+
 			// 图片删除
-			imagedelete(index){
-				this.item.photoList.splice(index,1);
+			imagedelete(index) {
+				this.item.photoList.splice(index, 1);
 			},
 
 			// *** 新增拍照功能
 			chooseImage() {
 				const _this = this
-				if(_this.photoList.length >= 9){
+				if (_this.photoList.length >= 9) {
 					_this.$refs.uToast.show({
 						type: "warning",
 						message: "最多上传9张照片",
@@ -183,7 +203,7 @@
 									_this.$set(_this.item, 'photoList', [url])
 								} else {
 									// 不能存储超过 9 张
-									if(_this.item.photoList.length < 9){
+									if (_this.item.photoList.length < 9) {
 										_this.item.photoList.push(url);
 									}
 								}
@@ -236,8 +256,8 @@
 			text-align: center;
 			border-right: 1px solid $border-color;
 			justify-content: center;
-			
-			.mark{
+
+			.mark {
 				width: 80rpx;
 				height: 4rpx;
 				display: inline-block;
@@ -315,8 +335,8 @@
 			padding: 6px 12rpx;
 			// display: flex;
 			// align-items: center;
-			
-			.btn_box{
+
+			.btn_box {
 				width: 100%;
 			}
 
@@ -335,7 +355,7 @@
 				display: inline-block;
 			}
 		}
-		
+
 		/deep/.u-album__row__wrapper {
 			uni-image {
 				width: 180rpx !important;

+ 4 - 1
pages/maintenance/check/index.vue

@@ -138,6 +138,7 @@
 				let params = {
 					id: this.equipList[0].id,
 					executeStatus: isAllPass ? 1 : 2,
+					isAbnormal: isAllPass ? 1 : 0,
 					workItems: this.equipList.map(item => {
 						return {
 							content: item.content,
@@ -146,7 +147,7 @@
 							operationGuide: item.operationGuide,
 							result: item.result,
 							serialNum: item.serialNum,
-							status: item.status,
+							status: item.status == -1 ? -1 : 1,
 							// 新增 拍照数据
 							photoList: item.photoList || []
 						}
@@ -271,6 +272,8 @@
 						return {
 							...item,
 							id: data.id,
+							status: 1,
+							result: '正常',
 							executeStatus: 1
 						}
 					})

+ 1 - 0
pages/maintenance/detail/detail.vue

@@ -803,6 +803,7 @@
 	.kd-baseInfo {
 		padding: 0 32rpx;
 		font-size: 28rpx;
+		overflow: auto;
 	}
 
 	.kd-equipment {

+ 2 - 2
pages/maintenanceWorkorder/components/pickCard.vue

@@ -42,7 +42,7 @@
 							<view class="item_one perce100 rx-sc">
 								<view class="lable">设备编码:</view>
 								<view>
-									{{item.deviceList.filter((val) => val.deviceCode).map((val) => val.deviceCode).toString()}}
+									{{item.deviceList.filter((val) => val.code).map((val) => val.code).toString()}}
 								</view>
 							</view>
 						</view>
@@ -73,7 +73,7 @@
 							</view>
 							<view class="item_one perce50 rx-sc">
 								<view class="lable">状态:</view>
-								<view>{{statusOpt[item.status]}}</view>
+								<view>{{statusOpt[item.approvalStatus]}}</view>
 							</view>
 						</view>
 					</view>

+ 1 - 1
pages/qms/inspectionWork/index.vue

@@ -79,7 +79,7 @@
 		onShow() {
 			this.isEnd = false
 			this.page = 1
-			// this.getList()
+			this.getList()
 		},
 		methods: {
 			doSearch() {

+ 133 - 27
pages/qms/inspectionWork/inspectionProjectReport.vue

@@ -7,7 +7,7 @@
 			<view class="herder_item">
 				<view class="herder_text"></view>
 				<view class="herder_view" style="font-size: 32rpx;">
-					检验信息
+					检验信息({{form.status==1?'已检':form.status==2?'已派单':form.status==3?'已请托':'待检'}})
 
 				</view>
 			</view>
@@ -35,14 +35,27 @@
 			<view class="marginTop20 defValue">
 				{{form.defaultValue}}
 			</view>
+			<view class="herder_item marginTop20">
+				<view class="herder_text"></view>
+				<view class="herder_view">
+					工单剩余样品数
+				</view>
+			</view>
+			<view class="marginTop20 ">
+				<u-input disabled class="marginTop20" placeholder=" " border="surround"
+					v-model="workData.remainingSampleCount">
+					<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}
+					</template>
+				</u-input>
+			</view>
 			<view class="herder_item marginTop20">
 				<view class="herder_text"></view>
 				<view class="herder_view">
 					质检内容
 				</view>
 			</view>
-			<u-input @input="handleInput(form, form.qualityResultContent)" class="marginTop20" placeholder="请输入内容"
-				border="surround" v-model="form.qualityResultContent">
+			<u-input :disabled='form.status==1' @change="handleInput(form, form.qualityResultContent)"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.qualityResultContent">
 				<template slot="suffix" v-if="form.unitName">{{form.unitName}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -51,8 +64,8 @@
 					样品数
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.sampleQuantity">
+			<u-input :disabled='form.status==1' @change="inputValue('sampleQuantity')" type="number" class="marginTop20"
+				placeholder="请输入内容" border="surround" v-model="form.sampleQuantity">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -61,8 +74,8 @@
 					合格数
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.qualifiedQuantity">
+			<u-input :disabled='form.status==1' type="number" @change="inputValue('qualifiedQuantity')"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.qualifiedQuantity">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -71,8 +84,8 @@
 					不合格数
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.noQualifiedQuantity">
+			<u-input :disabled='form.status==1' type="number" @change="inputValue('noQualifiedQuantity')"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.noQualifiedQuantity">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -81,7 +94,8 @@
 					损耗数(合格品)
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.lossNumber">
+			<u-input :disabled='form.status==1' @change="inputValue('lossNumber')" type="number" class="marginTop20"
+				placeholder="请输入内容" border="surround" v-model="form.lossNumber">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -90,8 +104,8 @@
 					损耗数(不合格品)
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.lossNumberUnqualified">
+			<u-input :disabled='form.status==1' @change="inputValue('lossNumberUnqualified')" type="number"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.lossNumberUnqualified">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -100,8 +114,8 @@
 					留样数(合格品)
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.retainedSampleQuantity">
+			<u-input :disabled='form.status==1' @change="inputValue('retainedSampleQuantity')" type="number"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleQuantity">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -110,8 +124,8 @@
 					留样数(不合格品)
 				</view>
 			</view>
-			<u-input type="number" class="marginTop20" placeholder="请输入内容" border="surround"
-				v-model="form.retainedSampleUnqualified">
+			<u-input :disabled='form.status==1' type="number" @change="inputValue('retainedSampleUnqualified')"
+				class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleUnqualified">
 				<template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
 			</u-input>
 			<view class="herder_item marginTop20">
@@ -120,18 +134,21 @@
 					质检结果
 				</view>
 			</view>
-			<uni-data-picker class="marginTop20" v-model="form.qualityResults" placeholder="请选择"
+			<uni-data-picker v-if='form.status!=1' class="marginTop20" v-model="form.qualityResults" placeholder="请选择"
 				:localdata="acceptUnpackList">
 			</uni-data-picker>
+			<u-input disabled v-else class="marginTop20" placeholder="请输入内容" border="surround"
+				:value="acceptUnpackList.find(item=>item.value==form.qualityResults).text">
+			</u-input>
 
 		</view>
 
 		<view class="footerButton">
 			<u-button type="default" text="返回" @click="back"></u-button>
-			<u-button type="primary" @click="save" text="保存"></u-button>
+			<u-button v-if="form.status!=1" type="primary" @click="exeReportWorkBySingleTemplate" text="保存"></u-button>
 		</view>
 		<view style="width:100%;height: 100rpx;"></view>
-
+		<u-toast ref="uToast"></u-toast>
 
 	</view>
 </template>
@@ -140,7 +157,7 @@
 	import dictMixns from '@/mixins/dictMixins'
 	import {
 		getById,
-		update
+		exeReportWorkBySingleTemplate
 	} from '@/api/inspectionWork/index.js'
 	import {
 		handleInput
@@ -195,19 +212,108 @@
 		},
 		methods: {
 
-			update() {
-				let params = JSON.parse(JSON.stringify(this.workData))
-				let index= params.templateList.findIndex(item=>item.id==this.form.id)
-				params.templateList[index]=this.form
-				params.
-				update(params)
+			exeReportWorkBySingleTemplate() {
+				// let params = JSON.parse(JSON.stringify(this.workData))
+				// let index = params.templateList.findIndex(item => item.id == this.form.id)
+				// params.templateList[index] = this.form
+				// params.
+				if (!this.form.qualityResultContent) {
+					this.$refs.uToast.show({
+						type: "error",
+						icon: false,
+						message: "请填写质检内容!",
+					}, )
+					return
+				}
+				if (!this.form.sampleQuantity) {
+					this.$refs.uToast.show({
+						type: "error",
+						icon: false,
+						message: "请填写样品数!",
+					}, )
+					return
+				}
+				this.form.status = 1
+				exeReportWorkBySingleTemplate({
+						id: this.workData.id,
+						planTemplateList: [this.form]
+					})
 					.then((msg) => {
-						 
+						this.back()
 					})
 					.catch((e) => {
+						this.back()
 					});
 			},
+			valueInit(data) {
+				['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified'].forEach(
+					key => {
+						data[key] = 0
+					})
+			},
 
+			inputValue(type) {
+				console.log(type, 'type')
+				let data = JSON.parse(JSON.stringify((this.form)))
+				if (data[type] < 0) {
+					data[type] = 0;
+				}
+				//样品数
+				if (type == 'sampleQuantity') {
+					if (+data[type] > this.workData.remainingSampleCount) {
+						data[type] = 0
+						this.$refs.uToast.show({
+							type: "error",
+							icon: false,
+							message: "样品数不能大于工单剩余样品数",
+						}, )
+					}
+					data.qualifiedQuantity = data[type]
+					data.noQualifiedQuantity = 0
+					this.valueInit(data)
+				}
+				//样品合格数、不合格数
+				if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
+					if (+data[type] > data.sampleQuantity) {
+						data[type] = 0
+						this.$refs.uToast.show({
+							type: "error",
+							icon: false,
+							message: (type == 'qualifiedQuantity' ? '合格' : '不合格') + "数不能大于样品数",
+						}, )
+					}
+					let key = type == 'qualifiedQuantity' ? 'noQualifiedQuantity' : 'qualifiedQuantity'
+					data[key] = data.sampleQuantity - data[type]
+					this.valueInit(data)
+				}
+				//损耗数 留样数
+				if (['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified']
+					.includes(type)) {
+					if (type == 'lossNumber' || type == 'retainedSampleQuantity') {
+						if (Number(data.lossNumber) + Number(data.retainedSampleQuantity) > data.qualifiedQuantity) {
+							this.$refs.uToast.show({
+								type: "error",
+								icon: false,
+								message: "损耗合格数与留样合格数之和不能大于样品合格数",
+							}, )
+							data[type] = 0
+						}
+
+					} else {
+						if (Number(data.lossNumberUnqualified) + Number(data.retainedSampleUnqualified) > data
+							.noQualifiedQuantity) {
+							this.$refs.uToast.show({
+								type: "error",
+								icon: false,
+								message: "损耗不合格数与留样不合格数之和不能大于样品不合格数",
+							}, )
+							data[type] = 0
+						}
+					}
+				}
+
+				this.$set(this, 'form', JSON.parse(JSON.stringify((data))))
+			}
 
 		}
 	}

+ 86 - 14
pages/repair/repair/index.vue

@@ -39,12 +39,13 @@
 			</Cell>
 			<Cell cellType="more" title="片区负责人部门">
 				<view class="cell-tip-right" slot="more">
-					{{ addForm.repairGroupName }}
+					{{ getDeptName(addForm.areaPersonInChargeGroupId,listData)}}
 				</view>
 			</Cell>
 			<Cell cellType="more" title="片区负责人">
 				<view class="cell-tip-right" slot="more">
-					{{ addForm.repairUserName }}
+					<zxz-uni-data-select style="width:300rpx" disabled :localdata="allList"
+						v-model="addForm.areaPersonInChargeUserId"></zxz-uni-data-select>
 				</view>
 			</Cell>
 		</view>
@@ -60,7 +61,8 @@
 			<view class="item">
 				<view class="label">领导部门</view>
 				<view class="value-wrap">
-					<input type="text" :value="addForm.leaderDeptName" @click="openPicker" placeholder="请选择" />
+					<input type="text" :value="addForm.leaderDeptName" @click="openPicker('leaderDeptName')"
+						placeholder="请选择" />
 				</view>
 			</view>
 			<view class="item">
@@ -70,6 +72,20 @@
 						@change="handleUserChange"></zxz-uni-data-select>
 				</view>
 			</view>
+			<view class="item">
+				<view class="label">维修部门</view>
+				<view class="value-wrap">
+					<input type="text" :value="addForm.repairGroupName" @click="openPicker('repairGroupName')"
+						placeholder="请选择" />
+				</view>
+			</view>
+			<view class="item">
+				<view class="label">维修人</view>
+				<view class="value-wrap" style="padding-left: 0">
+					<zxz-uni-data-select :localdata="userList1" v-model="addForm.repairUserId"
+						@change="handleUserChange1"></zxz-uni-data-select>
+				</view>
+			</view>
 			<view class="item">
 				<view class="label">期望完成时间</view>
 				<view class="value-wrap">
@@ -129,6 +145,7 @@
 	} from '@/utils/utils.js'
 	import selectUser from '../selectUser/index.vue'
 	import dayjs from 'dayjs'
+	let depName = ''
 	export default {
 		components: {
 			CellTip,
@@ -176,12 +193,16 @@
 				equipmentInfo: '',
 				addForm: {},
 				listData: [],
-				userList: []
+				userList: [],
+				userList1: [],
+				allList: [],
+				depKey: ''
 			}
 		},
 		onShow() {},
 		onLoad(data) {
 			this.getDept()
+			this.getUser('', true)
 			if (data.id) {
 				this.selectedEquipment(data.id)
 			}
@@ -264,6 +285,30 @@
 			// 图片删除
 			imagedelete(index) {
 				this.form.images.splice(index, 1);
+			},
+			getDeptName(id, listData) {
+				console.log(id, 'id')
+				if (!id) {
+
+					return ''
+
+				}
+				console.log(12121)
+
+				if (depName) {
+					return depName
+				}
+				listData.forEach((item => {
+					if (item.id == id) {
+						depName = item.name
+					}
+					if (item.children && item.children.length) {
+						return this.getDeptName(id, item.children)
+					}
+				}))
+
+
+
 			},
 
 			// ***
@@ -291,6 +336,10 @@
 					leaderUserId: this.addForm.leaderUserId,
 					leaderName: this.addForm.leaderName,
 					images: this.form.images,
+					repairUserId: this.addForm.repairUserId,
+					repairGroupId: this.addForm.repairGroupId,
+					repairGroupName: this.addForm.repairGroupName,
+					repairUserName: this.addForm.repairUserName,
 				}
 				save(params)
 					.then(res => {
@@ -310,27 +359,49 @@
 			handleUserChange(obj) {
 				this.addForm.leaderUserName = obj.text
 			},
+			handleUserChange1(obj) {
+				this.addForm.repairUserName = obj.text
+			},
 			confirmDep(data, name) {
-				console.log('----------------------------------')
-				console.log(data)
-				console.log(name)
-				this.addForm.leaderDeptName = name
-				this.addForm.leaderDeptId = data[0]
-				this.addForm.leaderUserName = ''
-				this.addForm.leaderUserId = ''
+				if (this.depKey == 'leaderDeptName') {
+					this.addForm.leaderDeptName = name
+					this.addForm.leaderDeptId = data[0]
+					this.addForm.leaderUserName = ''
+					this.addForm.leaderUserId = ''
+				} else {
+					this.addForm.repairGroupName = name
+					this.addForm.repairGroupId = data[0]
+					this.addForm.repairUserName = ''
+					this.addForm.repairUserId = ''
+				}
+
+
+
+
 				this.getUser(data[0])
 			},
-			getUser(deptCode) {
+			getUser(deptCode, init) {
 				getUserPage({
 					pageNum: 1,
 					size: -1,
 					groupId: deptCode
 				}).then(data => {
-					this.userList = data.list.map(item => {
+					let list = data.list.map(item => {
 						item.text = item.name
 						item.value = item.id
 						return item
 					})
+					if (init) {
+						this.allList = list
+					}
+
+
+					if (this.depKey == 'leaderDeptName') {
+						this.userList = list
+					} else {
+						this.userList1 = list
+					}
+
 				})
 			},
 			getDept() {
@@ -338,7 +409,8 @@
 					this.listData = data
 				})
 			},
-			openPicker() {
+			openPicker(key) {
+				this.depKey = key
 				this.$refs.treePicker._show()
 			},
 			// 选择的设备