<template>
	<view class="addIssue">
		<!-- <view class="fixedheader">
			<headers :showBack="true">
				<view class="headerName">
					施工日志
				</view>
			</headers>
		</view> -->
		<view class="content" :style="{paddingTop: mobileTopHeight + 'px'}">
			<view class="content_main">
				<view class="content_main-header">
					{{qualityRegionInfo.fullPath}}
				</view>
				<view class="main2_box" v-if="ocrBuildLogAllList.length > 0">
					<view class="main2_box-main" v-for="item in ocrBuildLogAllList" :key="item.id">
						<view class="box-header">
							<view>{{item.riskPointName}}</view>
						</view>
						<view class="box-item">
							<view>风险等级</view>
							<view class="riskcolor riskcolor_table" :class="{
												  riskcolor1: item.riskLevel == 1,
												  riskcolor2: item.riskLevel == 2,
												  riskcolor3: item.riskLevel == 3,
												  riskcolor4: item.riskLevel == 4,
												}">{{riskLevelUp(item.riskLevel)}}</view>
						</view>
						<view class="box-item">
							<view>风险描述</view>
							<view>{{item.riskDescription}}</view>
						</view>
						<view class="box-item">
							<view>可能导致的事故</view>
							<view>{{ accidentTypeUp(item.accidentTypeId) }}</view>
						</view>
						<view class="box-item">
							<view>责任人</view>
							<view>{{item.checkWorkerNames ? item.checkWorkerNames : '--'}}</view>
						</view>
						<view class="box-content">
							<view>管控措施</view>
							<view @click.stop="item.expandMoreShow = !item.expandMoreShow">
								{{item.expandMoreShow ? '收起详细': '展开详细'}}
							</view>
						</view>
						<template v-if="item.expandMoreShow">
							<view class="box-item">
								<view>工程措施</view>
								<view>{{item.engineeringMeasure ? item.engineeringMeasure : '--'}}</view>
							</view>
							<view class="box-item">
								<view>管理措施:</view>
								<view>{{item.managementMeasure ? item.managementMeasure : '--'}}
								</view>
							</view>
							<view class="box-item">
								<view>个体防护:</view>
								<view>{{item.personalProtection ? item.personalProtection : '--'}}
								</view>
							</view>
							<view class="box-item">
								<view>应急措施:</view>
								<view>{{item.emergencyMeasure ? item.emergencyMeasure : '--'}}
								</view>
							</view>
							<view class="box-item">
								<view>教育措施:</view>
								<view>{{item.educationalMeasure ? item.educationalMeasure : '--'}}
								</view>
							</view>
						</template>
					</view>
				</view>
				<view class="main1_box" v-else>
					<view class="new-nodata">
						<view></view>
						<text>暂无数据...</text>
					</view>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		isJSON
	} from "@/utils/tool.js"
	export default {
		data() {
			return {
				mobileTopHeight: 0,
				projectDetail: {},
				formInline: {
					type: 2,
					month: "",
				},
				ocrBuildLogAllList: [],
				ocrBuildLogInfo: {
					id: "",
				},
				qualityRegionInfo: {},
				riskLevelList: [{
						id: 1,
						name: "重大风险",
					},
					{
						id: 2,
						name: "较大风险",
					},
					{
						id: 3,
						name: "一般风险",
					},
					{
						id: 4,
						name: "低风险",
					},
				],
				accidentTypeList: [],
			}
		},
		onLoad(opts) {
			this.ocrBuildLogInfo.id = opts.id;
			this.projectDetail = JSON.parse(uni.getStorageSync('projectDetail'));
			this.getQualityRegionQueryById();
			this.getOcrBuildLogList();
			this.getDicProjectTypeList();
			// uni.setNavigationBarTitle({
			// 	title: '风险分级管控清单'
			// })
		},
		mounted() {
			var that = this
			uni.getSystemInfo({
				success(res) {
					that.mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : 0;
					uni.setStorageSync('systemInfo', res)
					console.log(res)
				}
			})
		},
		methods: {
			getQualityRegionQueryById() {
				let data = {
					projectSn: this.projectDetail.projectSn,
					id: this.ocrBuildLogInfo.id
				}
				this.sendRequest({
					url: 'xmgl/qualityRegion/queryById',
					method: 'POST',
					data: data,
					success: res => {
						if (res.code == 200) {
							this.qualityRegionInfo = res.result;
						}
					}
				})
			},
			getOcrBuildLogList() {
				let data = {
					projectSn: this.projectDetail.projectSn,
					regionIds: this.ocrBuildLogInfo.id,
					pageNo: 1,
					pageSize: -1,
				}
				this.sendRequest({
					url: 'xmgl/riskListSource/page',
					method: 'GET',
					data: data,
					success: res => {
						if (res.code == 200) {
							this.ocrBuildLogAllList = res.result.records.map(item => {
								return {
									...item,
									expandMoreShow: false
								}
							});
						}
					}
				})
			},
			showToast(title, type) {
				this.$refs.uToast.show({
					title: title,
					type: type,
				})
			},
			// 获取字典工程类别列表
			getDicProjectTypeList() {
				let that = this;
				let data = {
					projectSn: this.projectDetail.projectSn,
				};
				this.sendRequest({
					url: 'xmgl/riskListPotentialAccidentType/list',
					method: 'GET',
					data: data,
					success: res => {
						if (res.code == 200) {
							this.accidentTypeList = res.result.sort(
								(a, b) => Date.parse(a.createTime) - Date.parse(b.createTime)
							);
						}
					}
				})
			},
		},
		computed: {
			riskLevelUp() {
				return (riskLevel) => {
					const find = this.riskLevelList.find((item) => riskLevel === item.id);
					return find ? find.name : "--";
				};
			},
			accidentTypeUp() {
				return (accidentTypeId) => {
					const find = this.accidentTypeList.find((item) => accidentTypeId === item.id);
					return find ? find.type : "--";
				};
			},
		}
	}
</script>

<style scoped lang="scss">
	.riskcolor {
		color: white !important;
		padding: 8rpx 12rpx;
		width: 140rpx;
		margin-left: 10rpx;
		flex: inherit !important;
		text-align: center;
	}

	.riskcolor_table {
		padding: 2rpx 12rpx;
		display: inline-block;
	}

	.riskcolor1 {
		background-color: #eb4047;
	}

	.riskcolor2 {
		background-color: #ffbf00;
	}

	.riskcolor3 {
		background-color: #ffff00;
	}

	.riskcolor4 {
		background-color: #006fbf;
	}

	.addIssue {
		min-height: 100vh;
		background-color: #F2F3F7;
	}

	.content {
		.pb-138 {
			padding-bottom: 138rpx;
		}

		.content_main {

			// margin-top: 26rpx;
			.content_main-header {
				padding: 26rpx;
				background-color: #4198F5;
				color: white;
			}

			.main1_box {
				background-color: white;
				min-height: 650rpx;
				position: relative;
			}

			.main2_box {
				.main2_box-btn {
					margin-top: 26rpx;
					background-color: white;
					padding: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-weight: 500;
					font-size: 30rpx;
					color: #5382F6;

					>.u-icon {
						margin-left: 10rpx;
					}
				}

				.main2_box-main {
					padding: 20rpx 26rpx;
					margin-top: 26rpx;
					position: relative;
					background-color: white;

					.box-item1 {
						margin-top: 20rpx;
						background-color: white;
						font-size: 28rpx;
						color: #808080;
						display: flex;
						justify-content: space-between;
					}

					.box-content {
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-top: 26rpx;

						>view:last-child {
							font-size: 24rpx;
							color: #4D8EEC;
						}

						>view:first-child {
							font-size: 28rpx;
							color: #808080;
						}
					}

					.box-item {
						display: flex;
						// align-items: center;
						margin-top: 26rpx;
						font-size: 28rpx;

						>view:first-child {
							width: 192rpx;
							margin-right: 26rpx;
							color: #808080;
						}

						>view:last-child {
							flex: 1;
							color: #4D4D4D;
							// display: -webkit-box;
							// -webkit-box-orient: vertical;
							// -webkit-line-clamp: 1;
							// /* 限制为两行 */
							// overflow: hidden;
						}
					}

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

						>view:first-child {
							font-weight: 500;
							font-size: 30rpx;
							color: #1A1A1A;
						}

						// >view:last-child {
						// 	font-weight: 500;
						// 	font-size: 24rpx;
						// 	color: #4D8EEC;
						// }
					}
				}
			}

			.main3_box {
				margin-top: 26rpx;
				background-color: white;
				padding: 26rpx 22rpx;
				position: relative;

				.box-content_detail {
					font-size: 28rpx;
					color: #4D4D4D;
					margin-top: 4rpx;
				}

				.webkit-clamp_2 {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					/* 限制为两行 */
					overflow: hidden;
				}

				.box-content {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 26rpx;

					>view:last-child {
						font-size: 24rpx;
						color: #4D8EEC;
					}

					>view:first-child {
						font-size: 28rpx;
						color: #808080;
					}
				}

				.box-item {
					display: flex;
					align-items: center;
					margin-top: 26rpx;
					font-size: 28rpx;

					>view:first-child {
						width: 168rpx;
						margin-right: 26rpx;
						color: #808080;
					}

					>view:last-child {
						flex: 1;
						color: #4D4D4D;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 1;
						/* 限制为两行 */
						overflow: hidden;
					}
				}

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

					>view:first-child {
						font-weight: 500;
						font-size: 30rpx;
						color: #1A1A1A;
					}

					>view:last-child {
						font-weight: 500;
						font-size: 24rpx;
						color: #4D8EEC;
					}
				}
			}
		}

		.confrim-btn {
			width: 100%;
			padding: 18rpx 26rpx;
			background-color: #FFFFFF;
			box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.05);
			display: flex;
			position: fixed;
			bottom: 0;
			z-index: 1;

			>view {
				width: 100%;
				height: 76rpx;
				font-weight: 500;
				font-size: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background-color: #5181F6;
				border-radius: 0rpx 6rpx 6rpx 0rpx;
				color: #FFFFFF;
			}
		}
	}

	.fixedheader {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		z-index: 999;

		/deep/ .headerBox {
			border-bottom: none;
		}

		.headerName {
			z-index: 1;
		}
	}

	.search-box {
		background-color: white;
		width: 100%;
		position: fixed;
		z-index: 99;

		.uni-form-item {
			padding: 26rpx 26rpx 0;
			position: relative;
			display: flex;

			.uni-input {
				border: 2rpx solid #E4E4E4;
				border-radius: 68rpx;
				padding: 0;
				font-size: 30rpx;
				color: #444444;

				/deep/ .u-content {
					background-color: #FFFFFF !important;

					.u-input {
						background-color: #FFFFFF !important;
						color: #999999 !important;
					}
				}
			}

			.search-btn {
				width: 72rpx;
				height: 72rpx;
				background: #498CEC;
				border-radius: 48rpx;
				margin-left: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				>image {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

		/deep/ .u-dropdown {
			padding-right: 60rpx;
		}

		.calendar_box {
			position: absolute;
			right: 28rpx;
			bottom: 20rpx;

			.calendar {
				width: 32rpx;
				height: 32rpx;
				background-image: url('@/static/workTicketManage/calendar.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
			}

			.calendar_active {
				background-image: url('@/static/workTicketManage/calendar-active.png');
			}
		}
	}

	.scroll-view {
		margin: 10rpx 26rpx;
		width: calc(100% - 26rpx - 26rpx);
		max-height: 60vh;
		border-radius: 6rpx;
	}

	/deep/ .u-dropdown__menu__item__text {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		/* 限制为两行 */
		overflow: hidden;
	}

	.cell-box {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		position: relative;
		box-sizing: border-box;
		width: 100%;
		padding: 13px 16px;
		font-size: 14px;
		line-height: 27px;
		color: #606266;
		background-color: #fff;
		text-align: left;

		>view {
			flex: 1;
			margin-right: 20rpx;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 1;
			/* 限制为两行 */
			overflow: hidden;
		}

		.box-active {
			color: rgb(49, 144, 243);
		}

		>image {
			width: 32rpx;
			height: 32rpx;
		}
	}

	/deep/ .u-mask {
		z-index: 10 !important;
	}

	/deep/ .u-dropdown__content {
		// height: initial !important;
		// top: 166rpx !important;
		overflow: visible !important;
	}

	/deep/ .van-dropdown-item__content,
	/deep/ .u-cell-item-box {
		margin: 20rpx 26rpx;
		width: calc(100% - 26rpx - 26rpx);
		border-radius: 6rpx;
	}

	/deep/ .u-cell-item-box {
		// max-height: 60vh;
		// overflow-y: scroll;
	}

	/deep/ .uicon-arrow-down {
		// position: absolute;
		// top: 50%;
		// right: -4px;
		margin-top: -5px;
		border: 3px solid;
		border-color: transparent transparent #dcdee0 #dcdee0;
		-webkit-transform: rotate(-45deg);
		transform: rotate(-45deg);
		opacity: .8;
		content: '';
	}

	/deep/ .u-dropdown__menu__item__arrow--rotate .uicon-arrow-down {
		border-color: transparent transparent rgb(49, 144, 243) rgb(49, 144, 243);
	}

	/deep/ .uicon-arrow-down::before {
		display: none;
	}

	/deep/ .u-dropdown__menu {
		flex-wrap: wrap;
		// height: 166rpx !important;
		box-shadow: none;

		.u-dropdown__menu__item {
			width: 33%;
			// height: 82rpx;
			flex: initial;
		}
	}

	.new-nodata {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		>view {
			width: 300rpx;
			height: 300rpx;
			background-image: url('@/static/staffAttendance/nodata.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
		}

		>text {
			font-size: 22rpx;
			color: #808080;
			margin-top: 60rpx;
		}
	}

	.new-nodata_height {
		min-height: 500rpx;
		position: relative;
	}

	.new-nodata {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		>view {
			width: 300rpx;
			height: 300rpx;
			background-image: url('@/static/staffAttendance/nodata.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
		}

		>text {
			font-size: 22rpx;
			color: #808080;
			margin-top: 60rpx;
		}
	}
</style>