<template>
	<view class="addIssue">
		<view class="fixedheader">
			<headers :showBack="true" :themeType="true">
				<view class="headerName">
					查看落实记录
				</view>
			</headers>
		</view>
		<view class="search-box" :style="{paddingTop: mobileTopHeight + 44 + 'px'}">
			<view class="box-header">
				<view>
					<view>
						{{riskListPointInfo.riskPointName}}
					</view>
				</view>
				<view class="riskcolor riskcolor_table" :class="{
				  riskcolor1: riskListPointInfo.riskLevel == 1,
				  riskcolor2: riskListPointInfo.riskLevel == 2,
				  riskcolor3: riskListPointInfo.riskLevel == 3,
				  riskcolor4: riskListPointInfo.riskLevel == 4,
				}">{{riskLevelUp(riskListPointInfo.riskLevel)}}</view>
			</view>
		</view>
		<view class="content" :style="{paddingTop: mobileTopHeight + 100 + 'px'}">
			<view class="content_main" v-if="selectWorkerInfoList.length > 0">
				<view class="main3_box" v-for="item in selectWorkerInfoList" :key="item.id">
					<view class="box-item">
						<view>责任区域:</view>
						<view>{{item.responsibleAreaName}}</view>
					</view>
					<view class="box-item">
						<view>管控责任人:</view>
						<view>{{item.responsiblePersonControlName}}</view>
					</view>
					<view class="box-item">
						<view>落实时间:</view>
						<view>{{item.implementationTime}}</view>
					</view>
					<view class="box-item">
						<view>落实情况:</view>
						<view>{{item.implementationStatus}}</view>
					</view>
					<view class="box-item">
						<view>落实照片:</view>
						<view>{{item.implementationPhoto}}</view>
					</view>
					<view class="box-item">
						<view>其他说明:</view>
						<view>{{item.otherInstruction}}</view>
					</view>
				</view>
			</view>
			<view class="new-nodata" v-else>
				<view></view>
				<text>暂无数据...</text>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobileTopHeight: 0,
				projectDetail: {},
				pageNo: 1,
				pageSize: 10,
				selectWorkerInfoList: [],
				isLoadMore: false,
				loadStatus: 'more',
				activeName: "",
				searchName: "",
				libraryId: "",
				checked: false,
				riskLevelList: [{
						id: 1,
						name: "重大风险",
					},
					{
						id: 2,
						name: "较大风险",
					},
					{
						id: 3,
						name: "一般风险",
					},
					{
						id: 4,
						name: "低风险",
					},
				],
				riskListPointInfo: {},
			}
		},
		onLoad(opts) {
			console.log(112233, opts)
			this.projectDetail = JSON.parse(uni.getStorageSync('projectDetail'))
			this.libraryId = opts.libraryId;
			this.pointId = opts.id,
			this.getSelectWorkerInfoList();
			this.getRiskListPointQueryByIdFn();
		},
		mounted() {
			var that = this
			uni.getSystemInfo({
				success(res) {
					that.mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : 0;
					uni.setStorageSync('systemInfo', res)
					console.log(res)
				}
			})
		},
		onReachBottom() {
			console.log(1)
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.isLoadMore = true
				this.pageNo += 1
				this.getSelectWorkerInfoList();
			}
		},
		onPullDownRefresh() {
			console.log(2)
			this.pageNo = 1
			this.selectWorkerInfoList = []
			this.getSelectWorkerInfoList()
		},
		methods: {
			// 通过id查询管控清单信息
			getRiskListPointQueryByIdFn() {
				let that = this;
				let data = {
					projectSn: this.projectDetail.projectSn,
					id: this.pointId,
				};
				this.sendRequest({
					url: 'xmgl/riskListSource/queryById',
					method: 'GET',
					data: data,
					success: res => {
						if (res.code == 200) {
							that.riskListPointInfo = res.result;
						}
					}
				})
			},
			loadData() {
				this.pageNo = 1
				this.selectWorkerInfoList = []
				this.getSelectWorkerInfoList()
				console.log(this.searchName)
			},
			getSelectWorkerInfoList() {
				let data = {
					pageNo: this.pageNo,
					pageSize: this.pageSize,
					projectSn: this.projectDetail.projectSn,
					sourceId: this.pointId,
				}

				this.sendRequest({
					url: 'xmgl/riskListWorkable/page',
					method: 'GET',
					data: data,
					success: res => {
						uni.hideLoading()
						if (res.code == 200) {
							console.log("workList======================", res)
							const resultList = res.result.records.map(item => {
								return {
									...item,
									checked: false,
									expandMoreShow: false,
								}
							})
							this.selectWorkerInfoList = this.selectWorkerInfoList.concat(resultList)
							if (res.result.records.length < this.pageSize) { //判断接口返回数据量小于请求数据量，则表示此为最后一页
								this.isLoadMore = true
								this.loadStatus = 'nomore'
							} else {
								this.isLoadMore = false
								// that.loadStatus='more'
							}
							uni.stopPullDownRefresh()
						}
					}
				})
			},
			showToast(title, type) {
				this.$refs.uToast.show({
					title: title,
					type: type,
				})
			},
		},
		computed: {
			riskLevelUp() {
				return (riskLevel) => {
					const find = this.riskLevelList.find((item) => riskLevel === item.id);
					return find ? find.name : "--";
				};
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		.content_main {
			margin-top: 26rpx;
			// background-color: white;
			padding-bottom: 138rpx;
			min-height: calc(100vh - 130rpx - 138rpx - 26rpx);

			>.main3_box:not(:first-child) {
				margin-top: 20rpx;
			}

			.pb_140 {
				padding-bottom: 140rpx !important;
			}

			.main3_box {
				padding: 30rpx 28rpx;
				background-color: white;
				// border-radius: 18rpx;
				position: relative;

				.box-bottom {
					width: 100%;
					padding: 0 26rpx;
					height: 112rpx;
					display: flex;
					align-items: center;
					background-color: #FFFFFF;
					box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.05);
					border-radius: 0 0 18rpx 18rpx;
					justify-content: flex-end;
					position: absolute;
					left: 0;
					bottom: 0;

					>view {
						padding: 10rpx 18rpx;
						border-radius: 6rpx;
						border: 2rpx solid #3E89FD;
						font-size: 28rpx;
						color: #3E89FD;
					}

					>view:not(:first-child) {
						margin-left: 20rpx;
					}

					.btn-error {
						border-color: #ED2B29;
						color: #ED2B29;
					}

					.btn-start {
						background-color: #3E89FD;
						border-color: #3E89FD;
						color: #FFFFFF;
					}
				}

				.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;
					font-size: 28rpx;

					>view:first-child {
						color: #808080;
					}

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

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

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

					>view:last-child {
						flex: 1;
						color: #4D4D4D;
						word-break: break-all;
						// 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 {
						display: flex;
						align-items: center;

						>view:last-child {
							font-weight: 800;
							font-size: 30rpx;
							color: #171717;
						}
					}

					// >view:last-child {
					// 	padding: 4rpx 36rpx 4rpx 20rpx;
					// 	border-radius: 4rpx;
					// 	// border: 2rpx solid #F1F1F1;
					// 	font-weight: 500;
					// 	font-size: 22rpx;
					// 	position: relative;
					// }

					.wks_active {
						color: #898989;
					}

					.wks_active::before {
						content: '';
						background-color: #898989;
						width: 16rpx;
						height: 16rpx;
						border-radius: 50%;
						position: absolute;
						top: 50%;
						right: 0;
						transform: translateY(-50%);
					}

					.sgz_active {
						color: #498CEC;
					}

					.sgz_active::before {
						content: '';
						width: 16rpx;
						height: 16rpx;
						background: #498CEC;
						border-radius: 50%;
						position: absolute;
						top: 50%;
						right: 0;
						transform: translateY(-50%);
					}

					.ztz_active {
						color: #C38100;
					}

					.ztz_active::before {
						content: '';
						width: 16rpx;
						height: 16rpx;
						background: #C38100;
						border-radius: 50%;
						position: absolute;
						top: 50%;
						right: 0;
						transform: translateY(-50%);
					}

					.ywg_acitve {
						color: #88CF65;
					}

					.ywg_acitve::before {
						content: '';
						width: 16rpx;
						height: 16rpx;
						background: #88CF65;
						border-radius: 50%;
						position: absolute;
						top: 50%;
						right: 0;
						transform: translateY(-50%);
					}
				}
			}
		}

		.confrim-bottom {
			width: 100%;
			padding: 26rpx 26rpx;
			background-color: #FFFFFF;
			box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.05);
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: fixed;
			bottom: 0;
			z-index: 1;

			>view:first-child {
				display: flex;
				align-items: center;
			}

			.confrim-btn {
				display: flex;

				>view {
					padding: 10rpx 20rpx;
					font-weight: 500;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border: 2rpx solid #D9D9D9;
					border-radius: 6rpx;
					color: #808080;
				}

				.btn-error {
					border: 2rpx solid #ED2B29;
					color: #ED2B29;
				}

				.btn-primary {
					background-color: #5181F6;
					color: #FFFFFF;
				}

				>view:nth-child(n + 2) {
					margin-left: 12rpx;
				}
			}
		}

	}

	.riskcolor {
		padding: 8rpx 12rpx;
		// width: 128rpx;
		flex: inherit !important;
		text-align: center;
		color: #4D4D4D;
	}

	.riskcolor1 {
		background-color: #eb4047;
	}

	.riskcolor2 {
		background-color: #ffbf00;
	}

	.riskcolor3 {
		background-color: #ffff00;
	}

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

	.icon-left,
	.icon-right {
		width: 32rpx;
		height: 32rpx;
		background-image: url('@/static/staffAttendance/attendance-icon1.png');
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.icon-right {
		transform: rotate(90deg);
	}

	.icon-top {
		transform: rotate(-90deg);
	}

	.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;
		}
	}

	/deep/ .van-cell,
	.item-cell {
		padding: 22rpx 26rpx;
	}

	/deep/ .van-cell__title,
	.item-cell_title {
		font-weight: 500;
		font-size: 30rpx;
		color: #1A1A1A;
	}

	/deep/ .van-collapse-item__content,
	/deep/ .uni-collapse-item__wrap-content {
		background-color: #F2F3F7;
		padding: 26rpx;
	}

	.content-main {
		padding: 26rpx;
	}

	.content-box1 {
		// height: 554rpx;
		// margin-top: 26rpx;
		position: relative;
		padding-bottom: 120rpx !important;

		.content-btn {
			width: 100%;
			padding: 18rpx 26rpx;
			background: #FFFFFF;
			box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.05);
			position: absolute;
			bottom: 0;
			left: 0;
			display: flex;
			justify-content: flex-end;

			>view {
				// width: 216rpx;
				background: #5181F6;
				border-radius: 6rpx;
				padding: 18rpx 24rpx;
				font-size: 28rpx;
				color: #FFFFFF;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.content-row {
			display: flex;
			align-items: flex-start;
			padding: 20rpx 0;
			// border-bottom: 2rpx solid #F2F2F2;
			font-size: 28rpx;

			>view:first-child {
				width: 162rpx;
				color: #808080;
			}

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

		.attachment {
			flex-direction: column;
			align-items: flex-start;

			>view:not(:first-child) {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 32rpx;
				width: 100%;

				>view:first-child {
					display: flex;
					align-items: center;
					width: 70%;

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

					>view {
						font-size: 28rpx;
						color: #171717;
						margin-left: 32rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}

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

	.content-box {
		width: 698rpx;
		padding: 26rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(3, 92, 181, 0.1), 0rpx 8rpx 40rpx 0rpx rgba(0, 0, 0, 0.05);
		// border-radius: 16rpx;

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

			.header-title {
				font-weight: 500;
				font-size: 30rpx;
				color: #1A1A1A;
			}

			>view:last-child {
				font-size: 22rpx;
				color: #4D4D4D;
				background-color: #FFFF00;
				padding: 4rpx 14rpx;
			}
		}
	}


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

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

		.headerName {
			z-index: 1;
		}
	}

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

	/deep/ .uni-collapse-item__title-arrow {
		display: none;
	}

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

	.icon-screen {
		display: flex;
		flex-direction: column;
		margin-left: 22rpx;

		>view:nth-child(1) {
			border-bottom: 12rpx solid #333333;
			border-right: 10rpx solid transparent;
			border-left: 10rpx solid transparent;
		}

		>view:nth-child(2) {
			border-top: 12rpx solid #333333;
			border-right: 10rpx solid transparent;
			border-left: 10rpx solid transparent;
			margin-top: 4rpx;
		}

		.icon-screen_active {
			border-bottom-color: #108BC7 !important;
			border-top-color: #108BC7 !important;
		}
	}

	.search-box {
		background-color: white;
		width: 100%;
		position: fixed;
		z-index: 99;
		
		.box-header {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 26rpx;
		
			>view:first-child {
				display: flex;
				align-items: center;
				// flex: 1;
				width: 70%;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 1; /* 限制为两行 */
				overflow: hidden;
		
				>view:last-child {
					font-weight: 800;
					font-size: 30rpx;
					color: #171717;
				}
			}
		
			// >view:last-child {
			// 	padding: 4rpx 20rpx;
			// 	border-radius: 4rpx;
			// 	border: 2rpx solid #F1F1F1;
			// 	font-weight: 500;
			// 	font-size: 22rpx;
			// }
		
			.wks_active {
				background-color: #898989;
				color: #1A1A1A;
			}
		
			.sgz_active {
				background-color: #BED0FA;
				color: #5181F6;
			}
		
			.ztz_active {
				background-color: #C38100;
				color: #FFFFFF;
			}
		
			.ywg_acitve {
				background-color: #88CF65;
				color: #1A1A1A;
			}
		}

		.uni-form-item {
			padding: 20rpx 26rpx;
			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');
			}
		}
	}
</style>