ソースを参照

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_app

ezhizao_zx 8 ヶ月 前
コミット
cc6eb8896c
1 ファイル変更63 行追加2 行削除
  1. 63 2
      pages/onSiteInspection/form.vue

+ 63 - 2
pages/onSiteInspection/form.vue

@@ -79,7 +79,16 @@
 			</view>
 			</view>
 		</view>
-
+		<!-- 拍照上传部分 -->
+		<view class="title unfit-title uni-row">
+			<text>拍照上传</text>
+		</view>
+		<view class=" uni-row" style="padding: 24rpx;
+		margin: 0 16rpx;
+		background-color: #ffffff;
+		border-radius: 12rpx;">
+		<uni-file-picker v-model="photoList" :readonly="!editable()"   return-type="array" :image-styles="imageStyles" @select="select" file-mediatype="image" class="my-files" @delete="handleDeletedPhoto" ></uni-file-picker>
+		</view>
 		<!-- 咨询部分 -->
 		<view class="title unfit-title uni-row">
 			<text>咨询</text>
@@ -155,6 +164,7 @@
 	import {
 		store
 	} from '@/store/index.js'
+	import {getURL} from '@/api/sys/user.js'
 	import {
 		saveOnSiteInspecion,
 		selectInspecion,
@@ -164,6 +174,8 @@
 		getInspectionStandardsList
 	} from '@/api/business/inspectionStandards.js'
 	const lot = ref({})
+	const urlList = JSON.parse(uni.getStorageSync('baseUrl'))
+	const webHost = ref(urlList.baseUrl)
 	const isEventTriggered = ref(false); // 创建一个标志位
 	const unfitInfos = ref([]) //废品信息
 	const consultations = ref([]) //咨询信息
@@ -179,6 +191,13 @@
 		status: 0,
 	})
 	const initStatus = ref(0)
+	const photoList = ref([])
+	const selected = ref([]);
+	const selectedPhotos = ref([])
+	const imageStyles = {
+				width:60,
+				height:60
+			}
 	const editable = () => {
 		// if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:edit')) {
 		// 	return true
@@ -236,6 +255,31 @@
 		})
 
 	}
+	function upLoadImageHandler(arg) {
+		getURL(arg).then(res =>{
+			let data = JSON.parse(res)
+						   selectedPhotos.value.push({
+							   url:data.fileName,
+							   pictureName:data.originalFilename
+						   })
+						   console.log(selectedPhotos.value)
+						   })
+	}
+	function select (e) {
+		console.log(e)
+		const {
+			tempFilePaths,
+			tempFiles
+		} = e	
+		tempFiles.forEach((item,index)=>{
+			upLoadImageHandler({ filePath: tempFilePaths[index],name:item.name})
+		})
+	}
+	function handleDeletedPhoto(e) {
+		let fileName = selectedPhotos.value.map(info => info.name)
+			let index = fileName.findIndex(name => name === e.tempFile.name);
+			selectedPhotos.value.splice(index,1)
+	}
 
 	onShow(() => {
 		 uni.$off('addWasteInfoEvent');
@@ -253,8 +297,14 @@
 					processInspecion.value.flag = false
 					unfitInfos.value = res.data.processInspectionDetails;
 					initStatus.value = res.data.status
+					selectedPhotos.value = res.data.processInspectionPictureList
+					photoList.value = res.data.processInspectionPictureList.map(item => {  
+					  return { ...item, url: webHost.value + item.url };
+					});
+					console.log(selectedPhotos.value)
+					console.log(photoList.value)
+					// photoList.value = res.data.processInspectionPictureList
 					consultations.value = res.data.dayworkItemConsults;
-					console.log("res", res);
 					console.log(processInspecion.value)
 					//判断是否移交到了仪器室
 					getInstrumentRoomInspectionList()
@@ -422,6 +472,8 @@
 		processInspecion.value.user = store.userInfo;
 		processInspecion.value.inspectionCarrierId = processInspecion.value.lot.inspectionCarrierId
 		processInspecion.value.inspectionCarrierCode = processInspecion.value.lot.inspectionCarrierCode
+		processInspecion.value.processInspectionPictureList = selectedPhotos.value
+		console.log(photoList.value)
 		console.log(processInspecion.value)
 		if(processInspecion.value.flag) {
 			//打开选择仪器室的弹窗
@@ -830,4 +882,13 @@
 	.uni-input-input:disabled {
 	    background-color: #f5f7fa;
 	}
+	.my-files {
+		display: flex;
+		justify-content: center;
+		
+		:deep(.uni-file-picker__container) {
+		flex-direction: row;
+			
+		}
+	}
 </style>