<template>
	<view class="container">
		<view class="tabar">
			<view>
				<image class="icblack" src="../../static/hoem/icon_back.png" @click="$wskj.goBack(1)"></image>
			</view>
			<view>设置记录</view>
		</view>
		<view class="bgList">
			<scroll-view scroll-y style="height: 100%;">
				<view class="inspectionList" v-for="(item,index) in list" :key="index">
					<view class="toiletInfo">
						<view class="info">
							<image class="hread" src="../../static/hoem/ic_hread.png"></image>
							<view class="title">
								<view class="toiletName">{{item.toiletId}}公厕</view>
								<view class="devicesName">设备：<text
										v-for="(item,index) in item.setEquipmentBindings">{{item}}</text></view>
							</view>
						</view>
					</view>
					<u-line class="line" length="90%"></u-line>

					<view class="inspectionInfo">
						<text>巡查周期：
							<!-- {{item.setInspectioncycle}} -->
							<text v-if="item.setInspectioncycle == 1">每一天一次</text>
							<text v-if="item.setInspectioncycle == 2">每两天一次</text>
							<text v-if="item.setInspectioncycle == 3">每三天一次</text>
							<text v-if="item.setInspectioncycle == 4">每四天一次</text>
							<text v-if="item.setInspectioncycle == 5">每五天一次</text>
							<text v-if="item.setInspectioncycle == 6">每六天一次</text>
							<text v-if="item.setInspectioncycle == 7">每七天一次</text>
						</text>
					</view>
					<view class="people">
						<text>巡查人员：{{item.setInspectors}}</text>
					</view>
					<u-line class="line" length="90%"></u-line>

					<view class="patrol">
						<view></view>
						<view class="modify">
							<view @click="onDelete(item.id)" class="delete">删除</view>
							<view @click="onEdit(item)">编辑</view>
						</view>
					</view>
				</view>
			</scroll-view>

		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				show: false
			}

		},
		onLoad() {

		},
		onShow() {
			this.getList()
		},
		methods: {
			black() {
				uni.navigateBack({
					delta: 1, //返回层数，2则上上页
				})
			},
			//设置记录列表
			getList() {
				const params = {
					url: '/system/log/list',
					data: {},
				}
				this.$request(params).then(res => {
					this.list = res.rows
				})
			},
			//删除设置公厕记录
			onDelete(id) {
				const params = {
					url: '/system/log/remove',
					data: {
						ids: [id]
					},
				}
				this.$request(params).then(res => {
					this.$u.toast('删除成功')
					this.getList()
				})
			},
			//编辑设置公厕记录
			onEdit(item) {
				uni.navigateTo({
					url: '/pages/index/setPatrol?type=2&id=' + item.id + '&toiletId=' + item.toiletId
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		background: linear-gradient(91deg, #FDEDEE 0%, #FFFFFF 100%);
		height: 100%;
		width: 100%;
		display: flex;
		flex-direction: column;
		padding-top: 60rpx;

		.bgList {
			flex: 1;
			overflow-y: auto;
			padding: 0 24rpx;
			background-color: #F8F4F4;

			.inspectionList {
				display: block;
				padding: 24rpx;
				margin-top: 20rpx;
				background-color: #FFFFFF;
				position: relative;
				border-radius: 14rpx 14rpx 14rpx 14rpx;

				.inspectionInfo {
					display: flex;
					color: #999999;
					font-size: 24rpx;

				}

				.people {
					display: flex;
					color: #999999;
					font-size: 24rpx;
				}

				.line {
					padding: 20rpx;
					padding-right: 15rpx;
				}

				.toiletInfo {
					display: flex;
					justify-content: space-between;

					.toInspected {
						width: 125rpx;
						height: 54rpx;
						text-align: center;
						color: #FB262A;
						position: absolute;
						top: 0%;
						right: 0%;
						background: #FDEDEE;
						border-radius: 0rpx 14rpx 0rpx 0rpx;
					}

					.info {
						display: flex;
					}

					.title {
						padding-left: 10rpx;

						.toiletName {
							color: #333333;
							font-size: 28rpx;
							font-weight: 700;
						}

						.devicesName {
							color: #999999;
							font-size: 24rpx;
							text{
								margin-left: 10rpx;
							}
						}
					}

					.hread {
						width: 75rpx;
						height: 75rpx;
					}
				}

				.patrol {
					display: flex;
					justify-content: space-between;
					padding: 20rpx;

					.modify {
						display: flex;
						font-size: 24rpx;
						color: #FB262A;
						font-weight: 800;

						view {
							padding: 0 33rpx;
						}

						.delete {
							// padding-right: 77rpx;
						}

					}
				}

			}
		}

		.tabar {
			height: 99rpx;
			color: #333333;
			display: flex;
			align-items: center;
			font-weight: 800;
			font-size: 36rpx;
			padding: 10rpx;
			background: linear-gradient(91deg, #FDEDEE 0%, #FFFFFF 100%);

			.icblack {
				width: 36rpx;
				text-align: center;
				margin-top: 15rpx;
				height: 36rpx;
			}
		}


	}
</style>