shubandetail.vue 12.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
<template>
	<view class="box">
		<view class="infotou">
			<view class="shubaninfohead">
				<view class="shubaninfoleft">设备编号:{{equipment_log.number}}</view>
				<view class="shubaninforight">
					<image src="/static/img/fenxiang.png"></image>
					<button open-type="share">享</button>
				</view>
			</view>

			<view class="shucompany">
				<view class="shuimg">
					<image src="/static/img/company.png"></image>
				</view>
				<view class="companyname">所属公司:{{equipment_log.name}}</view>
			</view>
			<view class="shucompany weizhi">
				<view class="shuimg">
					<image src="/static/img/weizhi.png"></image>
				</view>
				<view class="companyname">所在位置:{{equipment_log.address}}</view>
			</view>
			<view class="shucompany weizhi">
				<view class="shuimg">
					<image src="/static/img/time.png"></image>
				</view>
				<view class="companyname">数板时间:{{equipment_log.time}}</view>
			</view>
			<view class="shucompany weizhi">
				<view class="shuimg">
					<image src="/static/img/yichang.png"></image>
				</view>
				<view class="companyname" v-if="equipment_log.status == 'normal'">异常状态:正常</view>
				<view class="companyname" v-if="equipment_log.status == 'hidden'">异常状态:不正常</view>
			</view>

		</view>
		<view class="yiqi">
			<view class="yiqihead">
				<view class="yiqiheadleft">仪器读数</view>
				<view class="yiqiheadright">{{equipment_log.papers}}</view>
			</view>
			<view class="yiqihead">
				<view class="yiqiheadleft">复核数量</view>
				<view class="yiqiheadright">{{equipment_log.fuhe}}</view>
			</view>
		</view>
		<view class="yewu">

			<view class="yebiaoshi">
				<view class="biaoshileft">业务标识</view>
				<view class="enterword">
					<input type="text" value="" placeholder="请输入业务标识" placeholder-class="word" v-model="biaoshi" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">业务描述</view>
				<view class="enterword">
					<input type="text" value="" placeholder="请输入业务描述" placeholder-class="word" v-model="description" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">字段1</view>
				<view class="enterword">
					<input type="text" value="" placeholder="填写字段" placeholder-class="word" v-model="ziduan1" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">字段2</view>
				<view class="enterword">
					<input type="text" value="" placeholder="填写字段" placeholder-class="word" v-model="ziduan2" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">字段3</view>
				<view class="enterword">
					<input type="text" value="" placeholder="填写字段" placeholder-class="word" v-model="ziduan3" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">字段4</view>
				<view class="enterword">
					<input type="text" value="" placeholder="填写字段" placeholder-class="word" v-model="ziduan4" />
				</view>
			</view>
			<view class="yebiaoshi">
				<view class="biaoshileft">字段5</view>
				<view class="enterword">
					<input type="text" value="" placeholder="填写字段" placeholder-class="word" v-model="ziduan5" />
				</view>
			</view>
		</view>
		<!-- 相关照片 -->
		<view class="photo" v-if="fenxiangor">
			<view class="aboutphoto">相关照片</view>

			<view class="imgbox">

				<view v-for="(item,index) in imglist" :key="index" class="imgshang">
					<view class="upload" >
						<image :src="item" @click="viewimgtu(index)"></image>
						<view class="chahao" @click="del(index)">
							<image src="../../static/img/chahao3.png"></image>
						</view>
					</view>
				</view>
				<view class="upload" @click="shoseimg">
					<image src="/static/img/upload.png"></image>
				</view>
				
				<view class='upload' @click="camera">
					<image src="/static/img/camera.png"></image>
				</view>

			</view>
		</view>
		
		<view class="photo" v-else>
			<view class="aboutphoto">相关照片</view>
		
			<view class="imgbox">
		
				<view v-for="(item,index) in imglist" :key="index" class="imgshang">
					<view class="upload" >
						<image :src="item" @click="viewimgtu(index)"></image>
						
					</view>
				</view>
				
		
			</view>
		</view>

		<view class="subshuju" @click="edifenxiangor?set_number:''" v-if="edifenxiangor">提交数据</view>
		<!-- <view class="subshuju"  v-else>提交数据</view> -->
		



	</view>
</template>

<script>
	import app from "../../App.vue"
	export default {
		data() {
			return {
				// 详情数据
				equipment_log: "",
				// 输入框数据
				biaoshi: "",
				description: "",
				ziduan1: "",
				ziduan2: "",
				ziduan3: "",
				ziduan4: "",
				ziduan5: "",
				image: [],
				chuanimg: '/static/img/upload.png',
				imglist:[],
				number:'',
				id:'',
				is_share:0,
				fenxiangor:true,
				edifenxiangor:true
			}
		},
		methods: {
			//选择照片
			shoseimg() {
				let baseurl=uni.getStorageSync("baseurl")
				
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['album'], //从相册选择
					// sourceType: ['camera'],//拍摄照片
					// sourceType: '',
					success: (chooseImageRes) => {
						console.log(909090808080)
						const tempFilePaths = chooseImageRes.tempFilePaths;
			
						let images = tempFilePaths[0]
						console.log(images)
						let head = {
							'token': uni.getStorageSync('token'),
			
						}
			
						uni.uploadFile({
							url: baseurl+'/api/person/upload', 
							filePath: tempFilePaths[0],
							name: 'images',
							token: uni.getStorageSync('token'),
							formData: {},
							header: head,
							// images:images
							success: (uploadFileRes) => {
								console.log(uploadFileRes);
								let data = JSON.parse(uploadFileRes.data)
								console.log(data)
								
								console.log('000999888',this.imglist)
								this.imglist.push(data.data.src) 
							}
						});
					},
					fail: function(err) {
						console.log('76543221')
						console.log(err, "失败的回调")
					}
				});
			
			
			
			},
			//拍摄照片上传
		
			camera() {
				let baseurl=uni.getStorageSync("baseurl")
				uni.chooseImage({
					count:1,
					sizeType: ['original', 'compressed'],
					//sourceType: ['album'], //从相册选择
					 sourceType: ['camera'],//拍摄照片
					// sourceType: '',
					success: (chooseImageRes) => {
						console.log(909090808080)
						const tempFilePaths = chooseImageRes.tempFilePaths;
				
						let images = tempFilePaths[0]
						console.log(images)
						let head = {
							'token': uni.getStorageSync('token'),
				
						}
				
						uni.uploadFile({
							url: baseurl+'/api/person/upload', 
							filePath: tempFilePaths[0],
							name: 'images',
							token: uni.getStorageSync('token'),
							formData: {},
							header: head,
							// images:images
							success: (uploadFileRes) => {
								console.log(uploadFileRes);
								let data = JSON.parse(uploadFileRes.data)
								console.log(data)
								this.imglist.push(data.data.src) 
							}
						});
					},
					fail: function(err) {
						console.log('76543221')
						console.log(err, "失败的回调")
					}
				});
							
			
			
			},
			//删除图片
			del(index){
				let newimglist=this.imglist;
				for(var i=0;i<newimglist.length;i++){
					if(i==index){
						newimglist.splice(i,1)
					}
					
				}
				
				this.imglist=newimglist;
				console.log('9999888',this.imglist)
			},
				
			// 获取数管剩余时间次数
			
			// 获取数板信息详情
			get_shubandetail() {
				console.log('666666',this.number)
				let t = this;
				let url = "api/equipment/getEquipmentDetail";
				let param = {
					number: this.number,
					equipment_log_id: t.id,
					is_share:t.is_share
					
				};
				app.post(url, param, 'post').then(r => {
					
					t.equipment_log = r.equipment_log;
					t.biaoshi=r.equipment_log.biaoshi;
					t.description=r.equipment_log.description;
					t.ziduan1=r.equipment_log.ziduan1;
					t.ziduan2=r.equipment_log.ziduan2;
					t.ziduan3=r.equipment_log.ziduan3;
					t.ziduan4=r.equipment_log.ziduan4;
					t.ziduan5=r.equipment_log.ziduan5;
					t.imglist=r.equipment_log.images
					
					
				}).catch(err => {
					console.log(err)
				})
			},
			// 提交数据
			set_number() {
				console.log(123)
				let t = this;
				
				if (this.imglist.length == 0) {
					uni.showToast({
						title: '请上传相关图片',
						icon: 'none'
					})
					return false
				}
				let url = "api/equipment/setEquipmentLog";
				let param = {
					number: t.equipment_log.number,
					equipment_log_id: t.equipment_log.id,
					fuhe: t.equipment_log.fuhe,
					biaoshi: t.biaoshi,
					description: t.description,
					ziduan1: t.ziduan1,
					ziduan2: t.ziduan2,
					ziduan3: t.ziduan3,
					ziduan4: t.ziduan4,
					ziduan5: t.ziduan5,
					images: t.imglist
				}
				app.post(url, param, 'post').then(r => {
					console.log(r)
					uni.showToast({
						title:'编辑成功',
						icon:'none'
					})
					t.edifenxiangor=false
				}).catch(err => {
					console.log(err)
				})
			},
			//图片预览
			viewimgtu(index) {
				console.log('999000',index)
				
				uni.previewImage({
					current: this.imglist[index],
					urls: this.imglist,
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {},
				})
			},

		},
		onLoad(options) {
			
			
			console.log('777777',options)
			this.number=options.number;
			this.id=options.id;
			if(options.type==1){
				this.is_share=1;
				this.fenxiangor=false;
				this.edifenxiangor=false
			}else{
				this.is_share=0;
				this.fenxiangor=true;
				this.edifenxiangor=true
			}
			
			this.get_shubandetail()
		},
		
		
		onShow() {
			
			
		},
		onShareAppMessage: function(res) {
			if (res.from === 'button') {
				// 来自页面内转发按钮
			}
			return {
				title: "智能点数小程序",
				path: 'pages/shubandetail/shubandetail?share=' + 'true'+'&type='+1+'&number='+this.number+'&id='+this.id
			}
		},
	}
</script>

<style>
	.imgbox{
		display:flex;
		align-items: center;
		flex-wrap: wrap;
	}
	.imgshang{
		display:flex;
		align-items: center;
	}
	.infotou {
		background: #fff;
		padding: 34rpx 32rpx;
		box-sizing: border-box;
	}

	.shubaninfohead {
		display: flex;
		align-items: center;
		justify-content: space-between;


	}

	image {
		width: 100%;
		height: 100%;
	}

	.shubaninforight {
		width: 31rpx;
		height: 31rpx;
		font-size: 0;
		position: relative;
	}

	.shubaninforight button {
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		opacity: 0;
	}

	.shubaninfoleft {
		color: #0A0808;
		font-size: 36rpx;
		font-weight: bold;
	}

	.shucompany {
		display: flex;
		align-items: center;
		margin-top: 30rpx;
	}

	.shuimg {
		width: 30rpx;
		height: 30rpx;
		font-size: 0;
	}

	.companyname {
		color: #7F8389;
		font-size: 28rpx;
		margin-left: 30rpx;
	}

	.weizhi {
		margin-top: 18rpx;
	}

	.yiqihead {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.yiqi {
		background: #fff;
		box-sizing: border-box;
	}

	.yiqihead {
		padding: 42rpx 32rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #f5f5f5;
		margin-top: 20rpx;
	}

	.yebiaoshi {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 34rpx 32rpx;
		box-sizing: border-box;
	}

	.yiqiheadleft {
		color: #0A0808;
		font-size: 30rpx;
		font-weight: bold;
	}

	.yiqiheadright {
		color: #7F8389;
		font-size: 28rpx;
	}

	.yewu {
		background: #FFFFFF;
	}

	.yebiaoshi {
		color: #0A0808;
		font-size: 30rpx;
	}

	.enterword {
		color: #7F8389;
		font-size: 28rpx;
		width: 300rpx;

	}

	.enterword input {
		text-align: right;
	}

	.word {
		color: #7F8389;
		font-size: 28rpx;
	}

	.photo {
		padding: 32rpx;
		box-sizing: border-box;
		background: #fff;
		margin-top: 20rpx;
	}

	.aboutphoto {
		color: #0A0808;
		font-size: 30rpx;
	}

	.upload {
		width: 160rpx;
		height: 160rpx;
		font-size: 0;
		margin-top: 30rpx;
		margin-left:14rpx;
		position: relative;
	}
	.chahao{
		width:40rpx;
		height:40rpx;
		position:absolute;
		top:-10rpx;
		right:-10rpx;
	}

	.subshuju {
		width: 686rpx;
		height: 100rpx;
		background: rgba(243, 152, 0, 1);
		box-shadow: 0rpx 4rpx 18rpx rgba(0, 0, 0, 0.04);
		opacity: 1;
		border-radius: 10rpx;
		color: #fff;
		font-size: 32rpx;
		text-align: center;
		line-height: 100rpx;
		margin: 42rpx auto;
	}
</style>