dedsudiyu 1 年之前
父節點
當前提交
91e4803b7b
共有 2 個文件被更改,包括 338 次插入305 次删除
  1. 17 1
      pages_basics/api/index.js
  2. 321 304
      pages_basics/views/photoInspection.vue

+ 17 - 1
pages_basics/api/index.js

@@ -32,7 +32,7 @@ export const laboratoryEventFindByEventId = (data) => {
 		data: { ...data }
 	})
 };
-//进出记录-实验室列表
+//进出记录/离开检查-实验室列表
 export const laboratoryAppletSignSubList = (data) => {
 	return apiResquest({
 		url: `/laboratory/applet/signSubList`,
@@ -55,4 +55,20 @@ export const laboratoryAppletPhotoInspectList = (data) => {
 		method: 'POST',
 		data: { ...data }
 	})
+};
+//离开检查-检查项查询
+export const laboratoryAppletOutCheckList = (data) => {
+	return apiResquest({
+		url: `/laboratory/applet/outCheckList`,
+		method: 'POST',
+		data: { ...data }
+	})
+};
+//离开检查-提交
+export const laboratoryAppletAddPhotoInspect = (data) => {
+	return apiResquest({
+		url: `/laboratory/applet/addPhotoInspect`,
+		method: 'POST',
+		data: { ...data }
+	})
 };

+ 321 - 304
pages_basics/views/photoInspection.vue

@@ -1,77 +1,63 @@
 <!-- 拍照检查 -->
 <template>
-    <view id="photoInspection">
-		<view class="photInspection-max">
-			<view class="picker-max-box">
-				<view class="picker-title-box">
-					<view>*</view>
-					<view>实验室:</view>
-				</view>
-				<picker @change="buttonChange"
-					:range-key="'subjectName'" :value="subjectId" :range="buttonArray">
-					<view class="picker-min-box">
-						<view>{{buttonArrayIndex?buttonArray[buttonArrayIndex].subjectName:'请选择'}}</view>
-						<img src="@/pages_basics/images/icon_06.png">
-					</view>
-				</picker>
+	<view id="photoInspection">
+		<view class="picker-max-box">
+			<view class="picker-title-box">
+				<view>*</view>
+				<view>实验室:</view>
 			</view>
-			<!-- 有图片 -->
-			<view class="photo-b" v-if="pageType==1">
-				<view class="photo-max-box">
-				    <view class="photo-button" v-if="!newData.subUrl" @click="upImg('subUrl')">+ 添加</view>
-				    <img :src="baseUrl+newData.subUrl" v-else @click="upImg('subUrl')">
-				    <view class="photo-title">{{newData.sub}}</view>
-				</view>
-				<view class="photo-max-box">
-				    <view class="photo-button" v-if="!newData.garbageUrl" @click="upImg('garbageUrl')">+ 添加</view>
-				    <img :src="baseUrl+newData.garbageUrl" v-else @click="upImg('garbageUrl')">
-				    <view class="photo-title">{{newData.garbage}}</view>
-				</view>
-				<view class="photo-max-box">
-				    <view class="photo-button" v-if="!newData.dangerousUrl" @click="upImg('dangerousUrl')">+ 添加</view>
-				    <img :src="baseUrl+newData.dangerousUrl" v-else @click="upImg('dangerousUrl')">
-				    <view class="photo-title">{{newData.dangerous}}</view>
+			<picker @change="buttonChange" :range-key="'subName'" :value="subId" :range="subList">
+				<view class="picker-min-box">
+					<view>{{subListIndex?subList[subListIndex].subName:'请选择'}}</view>
+					<img src="@/pages_basics/images/icon_06.png">
 				</view>
-				<view class="photo-max-box">
-				    <view class="photo-button" v-if="!newData.sourceRiskUrl" @click="upImg('sourceRiskUrl')">+ 添加</view>
-				    <img :src="baseUrl+newData.sourceRiskUrl" v-else @click="upImg('sourceRiskUrl')">
-				    <view class="photo-title">{{newData.sourceRisk}}</view>
+			</picker>
+		</view>
+		<view class="null-p">请选择实验</view>
+		<view class="outCheckList-max-box">
+			<view class="for-add-max-box" v-for="(item,index) in outCheckData.list" :key="index">
+				<view class="for-add-img-box" v-if="outCheckData.isUpload">
+					<p v-if="!item.subUrl" @click="upImg(index)">+添加</p>
+					<img v-else :src="baseUrl+item.subUrl" @click="upImg(index)">
 				</view>
-			</view>
-			<!-- 无图片 -->
-			<view class="photo-b" v-if="pageType==2">
-				<view v-for="(item,index) in photoList" :key="index" @click="photoClick(item)" class="list-li" :class="!item.type?'color-A':'color-B'">
-					<view>{{item.name}}</view>
-					<img v-if="item.type" :src="item.icon">
+				<view @click="checkItem(index)" :class="outCheckData.isUpload?'for-add-name-p-one':'for-add-name-p-two'"
+					class="for-add-name-p">
+					{{item.checkOutName}}
 				</view>
-			</view>
+				<uni-icons v-if="item.checkType" class="for-add-icon" type="checkmarkempty" color='#fff' size="24"></uni-icons>
 
+			</view>
 		</view>
 		<view class="up-data-button" @click="upButton">离开</view>
 		<helang-compress ref="helangCompress"></helang-compress>
-    </view>
+	</view>
 
 </template>
 
 <script>
 	import helangCompress from '@/pages_basics/component/compress.vue';
-    import { config } from '@/api/request/config.js'
-    import { addPhotoInspection,outSubjectList } from '@/api/apiDemo/index.js'
-    export default {
+	import {
+		config
+	} from '@/api/request/config.js'
+	import {
+		laboratoryAppletSignSubList,
+		laboratoryAppletOutCheckList,
+		laboratoryAppletAddPhotoInspect
+	} from '@/pages_basics/api/index.js'
+	export default {
 		components: {
 			helangCompress
 		},
-        data() {
-            return {
-				baseUrl:config.base_url,
-                newData:{},
-				buttonArray:[],
-				buttonArrayIndex:"",
-				pageType:2,
-				photoList:[
-					{type:false,name:'实验室照片',icon:require('@/pages_basics/images/icon_pzjc_xz.png')},
-					{type:false,name:'垃圾桶清理后照片',icon:require('@/pages_basics/images/icon_pzjc_xz.png')},
-					],
+		data() {
+			return {
+				baseUrl: config.base_url,
+				newData: {},
+				subList: [],
+				subListIndex: "",
+				pageType: 2,
+				outCheckData: {
+					list: [],
+				},
 				params: {
 					maxSize: 400,
 					fileType: 'png',
@@ -79,114 +65,139 @@
 					minSize: 320
 				}
 
-            }
-        },
-        onLoad(option) {
-			this.newData = JSON.parse(decodeURIComponent(option.newData));
-			console.log(this.newData)
-        },
-        onShow(){
-			this.outSubjectList();
-        },
-        methods: {
-			photoClick(item){
-				item.type=!item.type;
+			}
+		},
+		onLoad(option) {
+			// this.newData = JSON.parse(decodeURIComponent(option.newData));
+			// console.log(this.newData)
+		},
+		onShow() {
+			this.laboratoryAppletSignSubList();
+		},
+		methods: {
+			buttonChange(e) {
+				this.subListIndex = e.mp.detail.value;
+				this.laboratoryAppletOutCheckList()
 			},
-			buttonChange(e){
-				console.log("e",e.mp.detail.value);
-				this.buttonArrayIndex = e.mp.detail.value;
+			//获取实验室
+			async laboratoryAppletSignSubList() {
+				const {
+					data
+				} = await laboratoryAppletSignSubList();
+				if (data.code == 200) {
+					this.subList = data.data;
+				}
+			},
+			//获取实验室-检查项
+			async laboratoryAppletOutCheckList() {
+				const {
+					data
+				} = await laboratoryAppletOutCheckList({
+					subId: this.subList[this.subListIndex].subId
+				});
+				if (data.code == 200) {
+					this.outCheckData = data.data;
+				}
 			},
-			async outSubjectList(){
-				const {data} = await outSubjectList();
-				if(data.code == 200){
-					this.buttonArray = data.data;
+			checkItem(index) {
+				if (!this.outCheckData.isUpload) {
+					this.$set(this.outCheckData.list[index], 'checkType', !this.outCheckData.list[index].checkType);
 				}
 			},
-            upButton(){
-                let self = this;
-				if(!this.buttonArrayIndex){
+			upButton() {
+				let self = this;
+				if (!this.subListIndex) {
 					uni.showToast({
 						title: '请选择实验室',
-						icon:"none",
-						mask:true,
+						icon: "none",
+						mask: true,
 						duration: 2000
 					});
 					return
 				}
-				if(!this.newData.subUrl){
-					uni.showToast({
-						title: '请上传实验室照片',
-						icon:"none",
-						mask:true,
-						duration: 2000
-					});
-					return
+				if (self.outCheckData.isUpload) {
+					for (let i = 0; i < self.outCheckData.list.length; i++) {
+						if (!self.outCheckData.list[i].subUrl) {
+							uni.showToast({
+								title: self.outCheckData.list[i].checkOutName + '-检查照片未上传',
+								icon: "none",
+								mask: true,
+								duration: 2000
+							});
+							return
+						}
+					}
+				} else {
+					for (let i = 0; i < self.outCheckData.list.length; i++) {
+						if (!self.outCheckData.list[i].checkType) {
+							uni.showToast({
+								title: '请点击确认' + self.outCheckData.list[i].checkOutName,
+								icon: "none",
+								mask: true,
+								duration: 2000
+							});
+							return
+						}
+					}
+				}
+				uni.showModal({
+					// title: '确认要退出吗?',
+					content: '确认提交吗?',
+					cancelColor: "#999",
+					confirmColor: "#0183FA",
+					success: function(res) {
+						if (res.confirm) {
+							self.laboratoryAppletAddPhotoInspect();
+							console.log('用户点击确定');
+						} else if (res.cancel) {
+							console.log('用户点击取消');
+						}
+					}
+				});
+			},
+			//拍照检查提交
+			async laboratoryAppletAddPhotoInspect() {
+				let self = this;
+				let obj = {
+					photoList: [],
+				}
+				for (let i = 0; i < self.outCheckData.list.length; i++) {
+					obj.photoList.push({
+						passOutId: self.subList[self.subListIndex].passOutId,
+						checkOut: self.outCheckData.list[i].checkOut,
+						checkOutName: self.outCheckData.list[i].checkOutName,
+						subUrl: self.outCheckData.isUpload ? self.outCheckData.list[i].subUrl : ''
+					})
 				}
-				if(!this.newData.garbageUrl){
+				const {
+					data
+				} = await laboratoryAppletAddPhotoInspect(obj);
+				if (data.code == 200) {
 					uni.showToast({
-						title: '请上传垃圾桶清理后照片',
-						icon:"none",
-						mask:true,
+						title: '提交成功',
+						icon: "none",
+						mask: true,
 						duration: 2000
 					});
-					return
+					setTimeout(function() {
+						uni.navigateBack();
+					}, 2000);
 				}
-                uni.showModal({
-                    // title: '确认要退出吗?',
-                    content: '确认提交吗?',
-                    cancelColor:"#999",
-                    confirmColor:"#0183FA",
-                    success: function (res) {
-                        if (res.confirm) {
-                            self.addPhotoInspection();
-                            console.log('用户点击确定');
-                        } else if (res.cancel) {
-                            console.log('用户点击取消');
-                        }
-                    }
-                });
-            },
-            //拍照检查提交
-            async addPhotoInspection(){
-				let obj = {
-					subjectId:this.buttonArray[this.buttonArrayIndex].subjectId,
-					subUrl:this.newData.subUrl,
-					garbageUrl:this.newData.garbageUrl,
-					dangerousUrl:this.newData.dangerousUrl,
-					sourceRiskUrl:this.newData.sourceRiskUrl,
-				}
-				if(this.newData.id){
-					obj.id = this.newData.id
-				}
-                const {data} = await addPhotoInspection(obj);
-                if(data.code == 200){
-                    uni.showToast({
-                        title: '提交成功',
-                        icon:"none",
-                        mask:true,
-                        duration: 2000
-                    });
-                    setTimeout(function(){
-                        uni.navigateBack();
-                    },2000);
-                }
-            },
-            upImg(name){
-                let self = this;
-                wx.chooseImage({
-                    count: 1,
-                    sizeType: ["original", "compressed"],
-                    sourceType: ["album", "camera"],
-                    success: function(res) {
-                        //let tempFilePaths = res.tempFilePaths[0];
-                        //self.uploadImg(tempFilePaths,name);
-						self.compress(res.tempFilePaths,name);
-                    }
-                });
-            },
+			},
+			upImg(index) {
+				let self = this;
+				wx.chooseImage({
+					count: 1,
+					sizeType: ["original", "compressed"],
+					sourceType: ["album", "camera"],
+					success: function(res) {
+						self.compress(res.tempFilePaths, index);
+					}
+				});
+			},
 			//图片压缩
-			compress(tempFilePaths,name) {
-				 let self = this;
+			compress(tempFilePaths, index) {
+				let self = this;
 				uni.showLoading({
 					title: '压缩中',
 					mask: true
@@ -200,8 +211,9 @@
 					minSize: this.params.minSize
 				}).then((res) => {
 					uni.hideLoading();
-					console.log('压缩成功')
-					self.uploadImg(res,name);
+					console.log('压缩成功-res', res)
+					console.log('压缩成功-name', index)
+					self.uploadImg(res, index);
 
 				}).catch((err) => {
 					uni.hideLoading();
@@ -211,185 +223,190 @@
 					})
 				})
 			},
-            async uploadImg(tempFilePaths,name){
-                var self = this;
-                uni.showLoading({
-                    title: '上传中',
-                    mask: true
-                });
-                uni.uploadFile({
-                    url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
-                    header:{'Authorization':uni.getStorageSync('token')},
-                    filePath: tempFilePaths,
-                    name: 'file',
-                    formData: {
-                        'user': 'test'
-                    },
-                    success: (uploadFileRes) => {
-                        let res = JSON.parse(uploadFileRes.data);
-						if(res.code == 200){
-							self.$set(self.newData,name,res.data.url);
-							self.$set(self.newData,"real"+name,res.data.url);
-						}else{
+			async uploadImg(tempFilePaths, index) {
+				var self = this;
+				uni.showLoading({
+					title: '上传中',
+					mask: true
+				});
+				uni.uploadFile({
+					url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
+					header: {
+						'Authorization': uni.getStorageSync('token')
+					},
+					filePath: tempFilePaths,
+					name: 'file',
+					formData: {
+						'user': 'test'
+					},
+					success: (uploadFileRes) => {
+						let res = JSON.parse(uploadFileRes.data);
+						if (res.code == 200) {
+							self.$set(this.outCheckData.list[index], 'subUrl', res.data.url);
+						} else {
 							uni.showToast({
 								title: res.msg,
-								icon:"none",
-								mask:true,
+								icon: "none",
+								mask: true,
 								duration: 2000
 							});
 						}
-                    },
-                    fail: err => {},
-                    complete: () => {
-                        uni.hideLoading()
-                    }
-                });
-            },
-        }
-    }
+					},
+					fail: err => {},
+					complete: () => {
+						uni.hideLoading()
+					}
+				});
+			},
+		}
+	}
 </script>
 
 <style lang="stylus" scoped>
-    #photoInspection{
-        height:100%;
-        width:100%;
-		display:flex;
-		flex-direction:column;
-		.photInspection-max{
-			flex:1;
-			padding-bottom:40rpx;
-			.photo-b{
-				overflow-y:scroll;
-				position: absolute;
-				top: 140rpx;
-				.photo-max-box{
-				    width:702rpx;
-				    height:422rpx;
-				    border-radius: 20rpx;
-				    background: #FFFFFF;
-				    border:4rpx dashed #E0E0E0;
-				    margin:20rpx 20rpx 0;
-				    .photo-button{
-				        height:336rpx;
-				        width:702rpx;
-				        color: #0183FA;
-				        font-size:30rpx;
-				        line-height 336rpx
-				        text-align center
-				    }
-				    img{
-				        height:336rpx;
-				        width:702rpx;
-				        border-top-left-radius :20rpx
-				        border-top-right-radius :20rpx
-				    }
-				    .photo-title{
-				        border-top:4rpx dashed #E0E0E0;
-				        line-height:82rpx;
-				        color: #333333;
-				        font-size: 30rpx;
-				        padding-left:28rpx;
-				    }
+	#photoInspection {
+		height: 100%;
+		width: 100%;
+		display: flex;
+		flex-direction: column;
+		overflow: hidden;
+
+		.null-p {
+			text-align: center;
+			font-size: 28rpx;
+			line-height: 100rpx;
+			color: #999;
+		}
+
+		.picker-max-box {
+			width: 100%;
+			padding: 20rpx 0;
+			display: flex;
+			background: #FFFFFF;
+			z-index: 100;
+
+			.picker-title-box {
+				padding: 0 20rpx;
+				display flex;
+
+				view {
+					line-height: 80rpx;
+					font-size: 28rpx;
 				}
-			}
 
-			.null-view-box{
-			    text-align center;
-			    line-height:100rpx;
-			    color:#999;
-			    font-size:26rpx;
-			}
-			.photo-b{
-				padding-bottom: 140rpx;
+				view:nth-child(1) {
+					color: red;
+				}
+
+				view:nth-child(2) {}
+
+				view:nth-child(3) {
+					color: #999;
+				}
 			}
-			.picker-max-box{
-				width: 100%;
-				padding:20rpx 0;
-				display:flex;
-				background: #FFFFFF;
-				position: fixed;
-				z-index: 100;
-				.picker-title-box{
-					padding:0 20rpx;
-					display flex
-					view{
-						line-height:80rpx;
-						font-size:28rpx;
-					}
-					view:nth-child(1){
-						color:red;
-					}
-					view:nth-child(2){
 
-					}
-					view:nth-child(3){
-						color:#999;
-					}
+			.picker-min-box {
+				display flex;
+				height: 80rpx;
+				width: 556rpx;
+				border: 1rpx solid #a2a2a2;
+				border-radius: 10rpx;
+				margin: 0 20rpx;
+
+				view {
+					flex: 1;
+					line-height: 80rpx;
+					padding: 0 20rpx;
+					color: #999;
+					font-size: 28rpx;
+					overflow: hidden;
+					text-overflow: ellipsis;
+					white-space: nowrap;
+				}
+
+				img {
+					width: 24rpx;
+					height: 12rpx;
+					margin: 35rpx 23rpx;
 				}
-				.picker-min-box{
-					display flex;
-					height:80rpx;
-					width:556rpx;
-					border:1rpx solid #a2a2a2;
-					border-radius:10rpx;
-					margin:0 20rpx;
-					view{
-						flex:1;
-						line-height:80rpx;
-						padding:0 20rpx;
-						color:#999;
-						font-size:28rpx;
-						overflow: hidden;
-						text-overflow:ellipsis;
-						white-space: nowrap;
+			}
+		}
+
+		.outCheckList-max-box {
+			margin-top: 30rpx;
+			flex: 1;
+			overflow-y: scroll;
+
+			.for-add-max-box {
+				margin: 0 30rpx;
+				padding-bottom: 40rpx;
+				position: relative;
+
+				.for-add-img-box {
+					background: #fff;
+					overflow: hidden;
+					border: 1px dashed #dedede;
+
+					border-top-left-radius: 20rpx;
+					border-top-right-radius: 20rpx;
+
+					p {
+						width: 690rpx;
+						height: 250rpx;
+						line-height: 250rpx;
+						text-align: center;
+						color: #0183FA;
 					}
-					img{
-						width:24rpx;
-						height:12rpx;
-						margin:35rpx 23rpx;
+
+					img {
+						width: 690rpx;
+						height: 250rpx;
 					}
 				}
-			}
-			.list-li{
-				width: 690rpx;
-				height: 100rpx;
-				background: #FFFFFF;
-				border-radius: 20rpx 20rpx 20rpx 20rpx;
-				display: flex;
-				justify-content: space-between;
-				margin: 20rpx 20rpx 0;
-				>view{
-					font-weight: 400;
+
+				.for-add-name-p {
+					background: #fff;
+					text-align: center;
+					line-height: 80rpx;
 					font-size: 30rpx;
-					color: #333333;
-					line-height: 100rpx;
-					text-align: left;
-					padding-left: 28rpx;
+					padding: 0 30rpx;
+					display: block;
+					overflow: hidden;
+					text-overflow: ellipsis;
+					white-space: nowrap;
 				}
-				>img{
-					width: 60rpx;
-					height: 60rpx;
-					margin-top: 44rpx;
+
+				.for-add-name-p-one {
+					border: 1px dashed #dedede;
+					border-top: none;
+					border-bottom-left-radius: 20rpx;
+					border-bottom-right-radius: 20rpx
 				}
 
-			}
-			.color-A{
-				border: 2rpx dotted #E0E0E0;
-			}
-			.color-B{
-				border: 2rpx dotted #0183FA;
+				.for-add-name-p-two {
+					border: 1px dashed #dedede;
+					border-radius: 20rpx
+				}
+
+				.for-add-icon {
+					position: absolute;
+					right: 0;
+					bottom: 40rpx;
+					background-color: #0183FA;
+					border-top-left-radius: 20rpx;
+					border-bottom-right-radius: 20rpx;
+				}
 			}
 		}
-		.up-data-button{
+
+		.up-data-button {
 			width: 750rpx;
 			height: 120rpx;
 			background: #0183FA;
-			line-height:120rpx;
-			text-align center
-			color:#fff;
+			line-height: 120rpx;
+			text-align center;
+			color: #fff;
 			font-size: 30rpx;
-			position: fixed;
 			bottom: 0;
 		}
-    }
-</style>
+	}
+</style>