operateLog.vue 14.6 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 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
<template>
	<view class="pageWrapper">
		<CustomNavbar :title="navBarTitle" goBackUrl="/pages/home/home" @gobackDeal="gobackDeal">
		</CustomNavbar>

		<view class="body-wrapper">
			<view class="demo-uni-row">
				<uni-row>
					<uni-col :span="7" class="_title">
						<view>工程名称</view>
					</uni-col>
					<uni-col :span="15">
						<uni-data-select v-model="form.productName" :localdata="selectListLv1" :clear="false"
							@change="changeLv1"></uni-data-select>
					</uni-col>
				</uni-row>
			</view>
			<view class="demo-uni-row">
				<uni-row class="demo-uni-row mb-10">
					<uni-col :span="7" class="_title">
						<view>爆区名称</view>
					</uni-col>
					<uni-col :span="15">
						<uni-data-select v-model="form.artilleryAreaName" :localdata="selectListLv2" :clear="false"
							@change="changeLv2"></uni-data-select>
					</uni-col>
				</uni-row>
			</view>
			<view class="demo-uni-row">
				<uni-row class="demo-uni-row mb-10">
					<uni-col :span="7" class="_title">
						<view>记录时间</view>
					</uni-col>
					<uni-col :span="15">
						<uni-data-select v-model="form.artilleryAreaName" :localdata="selectListLv2" :clear="false"
							@change="changeLv2"></uni-data-select>
					</uni-col>
				</uni-row>
			</view>
		</view>


		<view class="footer-wrapper">
			<view class="funcBtn end" @tap="resetForm">
				搜索
			</view>
		</view>

		<view class="" v-show="!connected" style="text-align: center; color: darkgray; margin-top:20rpx;">
			{{ pageLoadText }}
		</view>
	</view>
</template>

<script>
	import CustomNavbar from '@/pages/component/CustomNavbar.vue';
	import {
		blueToothMixin
	} from '../../common/mixin.js'
	import {
		getCurrentTime,
		showCustomToast,
		showCustomModal
	} from '../../common/util.js'
	import {
		getSelectList,
		getDetailInfo,
		saveData,
		getDict
	} from '../../api/blueToothMeasure.js'
	export default {
		mixins: [blueToothMixin],
		components: {
			CustomNavbar,
		},
		data() {
			return {
				navBarTitle: '炮孔测量',
				redirectUrl: '/pages/home/blueSearch?refer=blueMeasure',
				// 表单数据相关
				zhuangyaoDict: [],
				form: {
					'productName': '',
					'artilleryAreaName': '',
					'cannonHoleArrayNum': '',
					'cannonHoleNum': '',
					'status': '',
					'expectedDepth': '',
					'actualDepth': '',
					'actualWaterLevel': ''
				},
				dataList: [],
				selectListLv1: [],
				selectListLv2: [],
				selectListLv3: [],
				selectListLv4: [],
				selectListLv5: [],
			};
		},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			uni.hideLoading()
			// this.dataList = uni.getStorageSync('importDataList') || []
			// console.log('this.dataList',JSON.stringify(this.dataList));
			this.getDictInfo()
			this.getSelectListLv1()

			// this.initLink()
		},
		methods: {
			async getDictInfo() {
				let res = await getDict({
					type: 'zhuangyao_type'
				})
				if (res) {
					this.zhuangyaoDict = res.map((item) => {
						return {
							text: item.dictLabel,
							value: item.dictValue
						}
					})
				}
			},
			changeLvCommonReset(lvNum) { // 下拉列表值改变,清空级联数据公共方法
				let newFildArr = []
				let newDataListSelectArr = []

				let formFieldArr = [
					'productName', 'artilleryAreaName', 'cannonHoleArrayNum', 'cannonHoleNum',
					'status', 'expectedDepth',
					'actualDepth', 'actualWaterLevel'
				]


				let dataListSelectArr = [
					'selectListLv1', 'selectListLv2', 'selectListLv3',
					'selectListLv4', 'selectListLv5'
				]

				// [1, 2, 3, 4, 5];  lvNum:2  => [3, 4, 5]
				newFildArr = formFieldArr.slice(lvNum);
				newFildArr.forEach((key) => {
					this['form'][key] = ''
				});
				newDataListSelectArr = dataListSelectArr.slice(lvNum);
				newDataListSelectArr.forEach((key) => {
					this[key] = []
				});

			},
			async getSelectListLv1() {
				// const dataArr = JSON.parse(JSON.stringify(this.dataList))
				// // 获取第一个数据列表
				// this.selectListLv1 = getCascadeList(dataArr, {
				// 	productName: null
				// }).map((item) => {
				// 	return {
				// 		text: item.productName,
				// 		value: item.productName
				// 	}
				// })
				const res = await getSelectList({
					productName: '',
					artilleryAreaName: '',
					cannonHoleArrayNum: '',
					cannonHoleNum: ''
				})
				console.log('响应res', res)
				this.selectListLv1 = res.map((item) => {
					return {
						text: item,
						value: item
					}
				})
			},
			changeLv1(e) {
				// console.log("e:", e);
				this.changeLvCommonReset(1)

				this.getSelectListLv2(e)

			},

			async getSelectListLv2(prevLvVal) {
				// const dataArr = JSON.parse(JSON.stringify(this.dataList))
				// this.selectListLv2 = getCascadeList(dataArr, {
				// 	productName: prevLvVal,
				// }).map((item) => {
				// 	return {
				// 		text: item.artilleryAreaName,
				// 		value: item.artilleryAreaName
				// 	}
				// })
				// //console.log('this.selectListLv2', this.selectListLv2)
				const res = await getSelectList({
					productName: prevLvVal,
					artilleryAreaName: '',
					cannonHoleArrayNum: '',
					cannonHoleNum: ''
				})
				console.log('响应res', res)
				this.selectListLv2 = res.map((item) => {
					return {
						text: item,
						value: item
					}
				})
			},
			changeLv2(e) {
				//console.log("e:", e);

				this.changeLvCommonReset(2)
				this.getSelectListLv3(e)
			},

			async getSelectListLv3(prevLvVal) {
				// const dataArr = JSON.parse(JSON.stringify(this.dataList))
				// this.selectListLv3 = getCascadeList(dataArr, {
				// 	productName: this.form.productName,
				// 	artilleryAreaName: prevLvVal
				// }).map((item) => {
				// 	return {
				// 		text: item.cannonHoleArrayNum,
				// 		value: item.cannonHoleArrayNum
				// 	}
				// })
				const res = await getSelectList({
					productName: this.form.productName,
					artilleryAreaName: prevLvVal,
					cannonHoleArrayNum: '',
					cannonHoleNum: ''
				})
				console.log('响应res', res)
				this.selectListLv3 = res.map((item) => {
					return {
						text: item,
						value: item
					}
				})
			},
			changeLv3(e) {
				//console.log("e:", e);
				this.changeLvCommonReset(3)
				this.getSelectListLv4(e)
			},

			async getSelectListLv4(prevLvVal) {
				// const dataArr = JSON.parse(JSON.stringify(this.dataList))
				// this.selectListLv4 = getCascadeList(dataArr, {
				// 	productName: this.form.productName,
				// 	artilleryAreaName: this.form.artilleryAreaName,
				// 	cannonHoleArrayNum: prevLvVal
				// }).map((item) => {
				// 	return {
				// 		text: item.cannonHoleNum,
				// 		value: item.cannonHoleNum
				// 	}
				// })
				const res = await getSelectList({
					productName: this.form.productName,
					artilleryAreaName: this.form.artilleryAreaName,
					cannonHoleArrayNum: prevLvVal,
					cannonHoleNum: ''
				})
				console.log('响应res', res)
				this.selectListLv4 = res.map((item) => {
					return {
						text: item,
						value: item
					}
				})
			},
			changeLv4(e) {
				// this.changeLvCommonReset(4)
				// //console.log("e:", e);
				// this.getSelectListLv5(e)
				this.getDetailInfo(e)
			},

			// getSelectListLv5(prevLvVal) {
			// 	const dataArr = JSON.parse(JSON.stringify(this.dataList))
			// 	this.selectListLv5 = getCascadeList(dataArr, {
			// 		productName: this.form.productName,
			// 		artilleryAreaName: this.form.artilleryAreaName,
			// 		cannonHoleArrayNum: this.form.cannonHoleArrayNum,
			// 		cannonHoleNum: prevLvVal,
			// 	}).map((item) => {
			// 		return {
			// 			text: item.boreholeNumber,
			// 			value: item.boreholeNumber
			// 		}
			// 	})
			// },
			// changeLv5(e) {
			// 	//console.log("e:", e);
			// 	this.getDetailInfo(e)
			// },
			async getDetailInfo() {
				let res = await getDetailInfo()
				if (res) {
					this.form['status'] = res['status']
					this.form['expectedDepth'] = res['expectedDepth']
					this.form['designInclination'] = res['designInclination']
					return
				}
				showCustomToast({
					title: '暂无详情信息'
				})
			},
			async saveData() { // 保存当前表单数据到本地
				let formFieldArr = [
					'productName', 'artilleryAreaName', 'cannonHoleArrayNum',
					'cannonHoleNum', 'boreholeNumber'
				]
				var validFlag = true
				for (var i = 0; i < formFieldArr.length; i++) {
					console.log('this.form[formFieldArr[i]]', i, this.form[formFieldArr[i]])
					if (!this.form[formFieldArr[i]]) {
						validFlag = false
						break;
					}
				}
				if (!validFlag) {
					showCustomModal({
						content: `手动填写数据不可为空`
					})
					return
				}
				// const index = this.dataList.findIndex((item) => {
				// 	return item.productName === this.form.productName &&
				// 		item.artilleryAreaName === this.form.artilleryAreaName &&
				// 		item.cannonHoleArrayNum === this.form.cannonHoleArrayNum &&
				// 		item.cannonHoleNum === this.form.cannonHoleNum &&
				// 		item.boreholeNumber === this.form.boreholeNumber
				// })
				if (this.form.measureDepth && this.form.shuiwei) {

					let res = await saveData({
						...this.form
					})
					// this.$set(this.dataList[index], 'actualWaterLevel', this.form.actualWaterLevel);
					// this.$set(this.dataList[index], 'actualDepth', this.form.actualDepth);
					// this.$set(this.dataList[index], 'remark', getCurrentTime());
					// uni.setStorageSync('importDataList', JSON.parse(JSON.stringify(this.dataList)))
					if (res) {
						uni.showToast({
							title: '保存成功',
							icon: false
						})
						this.resetForm()
					}
					return
				}
				showCustomModal({
					content: '孔深水位不能为空',
				})
			},
		}
	};

	/**
	 * 处理级联数据方法
	 */
	function getCascadeList(originArr = [], paramObj) {
		let sonArr = new Array()
		// let sonArr = new Set()


		if (paramObj.artilleryAreaName && paramObj.productName && paramObj.cannonHoleArrayNum && paramObj
			.cannonHoleNum) { // 返回第5级
			const tempArr = originArr.filter((item) => {
				return item.productName === paramObj.productName &&
					item.artilleryAreaName === paramObj.artilleryAreaName &&
					item.cannonHoleArrayNum === paramObj.cannonHoleArrayNum &&
					item.cannonHoleNum === paramObj.cannonHoleNum
			})
			const uniqueArray = Array.from(new Map(tempArr.map(item => [item.boreholeNumber, item])).values());
			return uniqueArray
		}

		if (paramObj.artilleryAreaName && paramObj.productName && paramObj.cannonHoleArrayNum) { // 返回第4级
			const tempArr = originArr.filter((item) => {
				return item.productName === paramObj.productName &&
					item.artilleryAreaName === paramObj.artilleryAreaName &&
					item.cannonHoleArrayNum === paramObj.cannonHoleArrayNum
			})
			const uniqueArray = Array.from(new Map(tempArr.map(item => [item.cannonHoleNum, item])).values());
			return uniqueArray
		}

		if (paramObj.artilleryAreaName && paramObj.productName) { // 返回第三级
			const tempArr = originArr.filter((item) => {
				return item.productName === paramObj.productName &&
					item.artilleryAreaName === paramObj.artilleryAreaName
			})
			const uniqueArray = Array.from(new Map(tempArr.map(item => [item.cannonHoleArrayNum, item])).values());
			return uniqueArray
		}


		if (paramObj.productName) { // 返回2级列表
			const tempArr = originArr.filter((item) => { // 二级列表基于1级选择后的值进行过滤
				return item.productName === paramObj.productName
			})
			const uniqueArray = Array.from(new Map(tempArr.map(item => [item.artilleryAreaName, item])).values());
			return uniqueArray
		}


		if (!paramObj.productName) { // 返回1级列表
			const uniqueArray = Array.from(new Map(originArr.map(item => [item.productName, item])).values());
			return uniqueArray
		}
	}
</script>

<style lang="scss">
	::v-deep .uni-select__input-placeholder {
		// placeholder样式调整
		font-size: 30rpx !important;
	}

	.inputEle {
		height: 110rpx;
		display: flex;
		align-items: center;
	}

	.uni-col-7 {
		font-size: 32rpx;
		font-weight: bold;
		color: #000000;
		line-height: 110rpx;
	}

	.demo-uni-row {
		line-height: 70rpx;
		padding-left: 15rpx;

		.uni-select {
			height: 108rpx;
		}
	}

	.only-read-row {
		background: #E3E6EC !important;
		height: 108rpx;
		align-items: center;
		display: flex;
		line-height: 70rpx;
		position: relative;
		padding-left: 13rpx;

		&:after {
			content: '米';
			width: 70rpx;
			height: 70rpx;
			position: absolute;
			right: 48rpx;
			top: 50%;
			transform: translateY(-50%);
			text-align: center;
			line-height: 70rpx;
			font-size: 29rpx;
			color: #000000;
		}
	}

	::v-deep .uni-row::after {
		clear: both;
		width: 608rpx;
		border-bottom: 1rpx solid #E3E6EC;
		transform: translateX(18rpx);
	}


	.pageWrapper {
		width: 100vw;
		height: calc(100vh-44rpx);
		padding-top: 44rpx;
		background: linear-gradient(180deg, #007AFF 0%, #419AFF 16%, #EFF1F4 43%);
	}

	.body-wrapper {
		margin: 0 auto;
		width: 690rpx;
		padding-top: 20rpx;
		padding-left: 15rpx;
		padding-right: 15rpx;
		background: #FFFFFF;
		border-radius: 10rpx;

		.sumary-title {
			position: relative;
			padding-left: 50rpx;
			font-size: 32rpx;
			color: #007AFF;
			margin-top: 20rpx;
			margin-bottom: 20rpx;

			&:before {
				content: '';
				width: 16rpx;
				height: 16rpx;
				background: #007AFF;
				border-radius: 50%;
				position: absolute;
				left: 20rpx;
				top: 50%;
				transform: translateY(-50%);
			}
		}
	}

	.logo-wrapper {
		display: flex;
		justify-content: center;

		image {
			width: 366rpx;
			height: 432rpx;
			margin: 0 auto;
		}
	}

	// ._title {
	// 	// border: 1px solid lightgray;
	// 	height: 70rpx;
	// 	text-align: center;
	// 	line-height: 70rpx;
	// 	margin-right: 10rpx;
	// 	font-size: 32rpx;
	// 	font-weight: bold;
	// 	color: #000000;
	// }

	._content {
		// border: 1px solid lightgray;
		height: 70rpx;
		line-height: 70rpx;
		padding-left: 20rpx;
		position: relative;

		// &:after {
		// 	content: 'm';
		// 	width: 70rpx;
		// 	height: 70rpx;
		// 	// border-left: 1px solid lightgray;
		// 	position: absolute;
		// 	right: -12rpx;
		// 	top: 0;
		// 	text-align: center;
		// 	line-height: 70rpx;
		// 	font-size: 29rpx;
		// 	color: #000000;
		// }
	}

	.funcBtn {
		width: 280rpx;
		height: 70rpx;
		line-height: 70rpx;
		background: #007AFF;
		border-radius: 35rpx;
		text-align: center;
		font-size: 29rpx;
		color: #FFFFFF;
		border: 2px solid #007AFF;

		&.end {
			background: #FFFFFF;
			;
			color: #007AFF;
		}

		&.loading {
			opacity: 0.5;
		}
	}

	.footer-wrapper {
		display: flex;
		justify-content: space-around;
		margin-top: 50rpx;
	}


	.unaffix {
		&:after {
			display: none;
		}
	}

	/**
 * 蓝牙连接互动相关
 */
	page {
		color: #333;
	}

	/*划线  */
	.line {
		background-color: blue;
		height: 5px;
		width: 100%;
	}

	.div {
		background-color: white;
		height: 10px;
		width: 10px;
	}

	.blank {
		height: 150rpx;
	}
</style>