From 83206a4017aa82e1658208cb55b78833e35deac7 Mon Sep 17 00:00:00 2001
From: Mr.Shi <1878285526@qq.com>
Date: 星期一, 11 九月 2023 18:15:51 +0800
Subject: [PATCH] 小程序

---
 minipro_standard/pages_inspect/pages/equipmentInspection/equipmentInspection.vue |  106 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 62 insertions(+), 44 deletions(-)

diff --git a/minipro_standard/pages_inspect/pages/equipmentInspection/equipmentInspection.vue b/minipro_standard/pages_inspect/pages/equipmentInspection/equipmentInspection.vue
index d42f60f..a730917 100644
--- a/minipro_standard/pages_inspect/pages/equipmentInspection/equipmentInspection.vue
+++ b/minipro_standard/pages_inspect/pages/equipmentInspection/equipmentInspection.vue
@@ -2,7 +2,7 @@
 	<view class="box1">
 		<!--    璁惧+鏃ユ湡   -->
 		<view class="box_list">
-			<view class="box_list_item" @click="open">
+			<view class="box_list_item" @click="show = true">
 				<view class="box_list_item_left">
 					<text>妫�楠岃澶�</text><text>*</text>
 				</view>
@@ -69,6 +69,10 @@
 		<view class="box_footer">
 			<button class="box_footer_submit" v-preventReClick @click="submit">鎻愪氦</button>
 		</view>
+		<!-- 鏌ョ湅澶у浘 -->
+		<Preview :list="form.files" :current="current" v-if="isOpen" />
+		<!-- 閫夋嫨璁惧 -->
+		<ytyDataPicker :show="show" :dataList="columns" @select="handleSelect" @search="handleSearch" @close="show = false" />
 		<!-- 閫夋嫨鏃堕棿 -->
 		<u-datetime-picker :show="showTime" v-model="currentDate" @cancel="showTime = false" @confirm="queding" mode="datetime"></u-datetime-picker>
 	</view>
@@ -78,13 +82,20 @@
 	import { getBarcodeContent } from '@/util/api/WorkOrderAPI'
 	import { saveBean, getDeviceByCondition, getsbInfo } from '@/util/api/QualityAPI'
 	import { queryListByCode, uploadFiles } from '@/util/api/index'
-	import { QRCodeType, baseUrl } from '@/common/config.js'
+	import { QRCodeType, baseUrl, fileType } from '@/common/config.js'
 	import { setTime, judgmentType } from '@/util/utils.js'
 	import { mapState } from 'vuex'
+	import ytyDataPicker from '@/components/yty-data-picker/yty-data-picker.vue'
+	import Preview from '@/components/Preview/Preview.vue'
 
 	export default {
 		data() {
 			return {
+				list1: [
+					'https://cloudfactory.oss-cn-hangzhou.aliyuncs.com/deviceCheck/20230911/e228a809-0a6b-443c-9a2c-78d5c1b1b633.mp4',
+					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
+					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
+				],
 				status: [{
 						name: '姝e父',
 						active: true,
@@ -98,8 +109,10 @@
 				],
 				columns: [],
 				path: '',
+				show: false,
 				showTime: false,
 				currentDate: new Date(),
+				current: 0,
 				form: {
 					equipmentId: '', // 璁惧id
 					equipmentName: '', //璁惧鍚嶇О
@@ -110,14 +123,33 @@
 				}
 			};
 		},
+		components:{
+			ytyDataPicker,
+			Preview
+		},
 		onLoad() {
 			this.form.time = setTime(new Date(), '-')
 			this.getqueryListByCode()
+			this.getSB('')
 		},
 		computed: {
 			...mapState(['session'])
 		},
 		methods: {
+			// 鍒犻櫎鎸囧畾鏂囦欢
+			dele(i) {
+				this.form.files.splice(i, 1)
+			},
+			// 閫夋嫨璁惧
+			handleSelect(e) {
+				this.form.equipmentId = e.code
+				this.form.equipmentName = e.name
+				this.show = false
+			},
+			// 鎼滅储璁惧
+			handleSearch(e) {
+				this.getSB(e)
+			},
 			// 纭閫夋嫨鏃ユ湡
 			queding(val) {
 				this.form.time = uni.$u.timeFormat(val.value, 'yyyy-mm-dd hh:MM:ss')
@@ -125,6 +157,7 @@
 			},
 			// 鎵爜
 			openCode() {
+				var that = this
 				uni.scanCode({
 					onlyFromCamera: true,
 					success: function (result) {
@@ -136,8 +169,8 @@
 									getsbInfo(res.data.id)
 										.then(res1 => {
 											if (res1.code === 200) {
-												this.form.equipmentId = res1.data.id
-												this.form.equipmentName = res1.data.name
+												that.form.equipmentId = res1.data.id
+												that.form.equipmentName = res1.data.name
 											}
 										})
 								} else {
@@ -205,49 +238,23 @@
 				})
 			},
 			// 鑾峰彇褰撳墠鐢ㄦ埛涓嬫墍鏈夎澶�
-			getSB() {
-				getDeviceByCondition({})
+			getSB(name) {
+				getDeviceByCondition({ name })
 					.then(res => {
 						if (res.code === 200 && res.data && res.data.length > 0) {
-							this.columns = []
+							let arr = []
 							res.data.forEach(item => {
-								this.columns.push({ text: item.name, id: item.id })
+								arr.push({ name: item.name, code: item.id })
 							})
+							this.columns = arr
+						} else {
+							this.columns = []
 						}
 					})
 			},
-			// 鑾峰彇鏂囦欢
-			async upFile(e) {
-				if (this.form.files.length + e.target.files.length > 9) {
-					uni.showToast({
-						title: '鏈�澶氬彧鑳戒笂浼�9涓浘鐗�/瑙嗛',
-						icon: 'none',
-						duration: 2000
-					});
-					return
-				}
-				for (let i = 0; i < e.target.files.length; i++) {
-					let type = e.target.files[i].type
-					let index = type.indexOf('/')
-					let data = type.substring(index + 1, type.length)
-					const format = new FormData()
-					format.append('file', e.target.files[i])
-					format.append('folder', this.path)
-					let res = await uploadFiles(format)
-					if (res.code === 200) {
-						form.files.push({
-							fileUrl: res.data.imgaddr,
-							filename: res.data.imgname,
-							filesize: e.target.files[i].size,
-							type: judgmentType(data.toLowerCase()) ? 0 : 1,
-							url: res.data.url
-						})
-					}
-				}
-				// upload.value.value = ''
-			},
 			// 鐐瑰嚮涓婁紶
 			uploadFile() {
+				var that = this
 				uni.chooseImage({
 					success: (chooseImageRes) => {
 						const tempFilePaths = chooseImageRes.tempFilePaths;
@@ -257,19 +264,23 @@
 							filePath: tempFilePaths[0],
 							name: 'file',
 							header: {
-								'Cookie': 'eva-auth-token=' + this.session
+								'Cookie': 'eva-auth-token=' + that.session
 							},
 							formData: {
-								'folder': this.path
+								'folder': that.path
 							},
 							success: (uploadFileRes) => {
-								console.log(JSON.parse(uploadFileRes.data));
 								let res = JSON.parse(uploadFileRes.data)
-								this.form.files.push({
+								let type = ''
+								for (let i = 0; i < fileType.length; i++) {
+									if (tempFilePaths[0].indexOf(fileType[i].name) !== -1) {
+										type = fileType[i].type
+									}
+								}
+								that.form.files.push({
 									fileUrl: res.data.imgaddr,
 									filename: res.data.imgname,
-									// filesize: e.target.files[i].size,
-									type: judgmentType(tempFilePaths[0]) ? 0 : 1,
+									type,
 									url: res.data.url
 								})
 							}
@@ -298,6 +309,13 @@
 		height: 100%;
 		position: absolute;
 		background: #F7F7F7;
+		
+		.sb {
+			width: 100%;
+			height: 800rpx;
+			padding: 30rpx;
+			box-sizing: border-box;
+		}
 
 		.box_list {
 			padding: 0 30rpx 0 30rpx;

--
Gitblit v1.9.3