<template>
	<div class="political-outlook">
		<div class="content">
			<div class="top-count">
				<!-- <div class="rightHeader">
					<div class="day Selected" @click="changeSelect(1)" :class="checked == 1 ? 'active' : ''"><span>在施</span></div>
					<div class="year Selected" @click="changeSelect(2)" :class="checked == 2 ? 'active' : ''"><span>当月</span></div>
				</div> -->
				<div class="risk-count-all">
					<div class="all-sum">
						<span>{{ statisticsData.totalNum || 0 }}</span>
						<span>个</span>
					</div>
					<span>风险总数</span>
				</div>
				<div class="risk-classify">
					<div class="classify-item classify-one">
						<span>{{ statisticsData.greatFaultLevelNum || 0 }}</span>
						<span>重大风险</span>
					</div>
					<div class="classify-item classify-two">
						<span>{{ statisticsData.largerRiskNum || 0 }}</span>
						<span>较大风险</span>
					</div>
					<div class="classify-item classify-three">
						<span>{{ statisticsData.generalRiskNum || 0 }}</span>
						<span>一般风险</span>
					</div>
					<div class="classify-item classify-four">
						<span>{{ statisticsData.lowRiskNum || 0 }}</span>
						<span>低风险</span>
					</div>
				</div>
			</div>
			<!-- <div class="radio-content">
				<el-radio-group
					v-model="riskType"
				>
					<el-radio :label="1">动态风险</el-radio>
					<el-radio :label="2">静态风险</el-radio>
				</el-radio-group>
			</div> -->
			<div class="table-one">
				<div class="tabList">
					<div>序号</div>
					<div>风险点描述</div>
					<div>整改要求</div>
					<div>风险类型</div>
					<div>提出时间</div>
				</div>
				<el-scrollbar class="listBox" ref="refScrollbar">
					<div v-for="(item, index) in partyMemberList" class="listStyle" :key="item.id">
						<div>{{ index + 1 }}</div>
						<div>{{ item.problemDescription }}</div>
						<div>
							<el-tooltip class="box-item" effect="dark" :content="item.remark" placement="top-start">
								<span>{{item.remark}}</span>
							</el-tooltip>
						</div>
						<div>{{ item.level == 1
                          ? "重大"
                          : item.level == 2
                          ? "较大"
                          : item.level == 3
                          ? "一般"
                          : "低" }}</div>
						<div>{{ item.inspectTime }}</div>
					</div>
					<div class="notoDta" v-if="partyMemberList.length == 0">
						<img src="@/assets/images/noData.png" alt="" />
						<p>暂无数据</p>
					</div>
				</el-scrollbar>
			</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from "vue";
import { GlobalStore } from "@/stores";
import { getCompanyDataList, getMemberInfoList } from "@/api/modules/labor";
import { getStatisticsNumDataApi, getInspectionRecordApi } from "@/api/modules/agjtCommandApi";
const store = GlobalStore();
const props = defineProps(["tip"]);
const BASEURL = import.meta.env.VITE_API_URL;
const riskType = ref(1);
const enterpriseListData = ref([] as any);
let pageNo = ref(1 as any);
let moreScroll = ref(true as any);
const refScrollbar = ref(null as any); // 绑定到滚动的盒子上
const searchForm = ref({
	memberType: "",
	belongCompany: "",
	workState: "",
	name: "",
	idCard: ""
});
const checked = ref(1);
const partyMemberList = ref({} as any);
const statisticsData = ref({} as any)
const changeSelect = (index: any) => {
	checked.value = index;
};
// 获取顶部统计数据
const getStatisticsNumDataFn = async () => {
	let data = {
		projectSn: store.sn
	};
	const res: any = await getStatisticsNumDataApi(data);
	if (res.code == 200) {
		console.log('风险统计顶部统计数据', res)
		statisticsData.value = res.result;
	}
};
//获取企业列表
const getCompanyList = async () => {
	let data = {
		projectSn: store.sn,
		enterpriseName: "",
		userEnterpriseId: store.userInfo?.userEnterpriseId
	};
	const res: any = await getCompanyDataList(data);
	if (res.code == 200) {
		enterpriseListData.value = res.result;
	}
};
//获取数据
const getMemberCountList = async (tip: any) => {
	let requestData: any = {
		projectSn: store.sn,
		recordType: 1,
		pageNo: tip == "search" ? 1 : pageNo.value,
		pageSize: 100
	};
	const res: any = await getInspectionRecordApi(requestData);
	console.log("获取风险统计列表", res);
	if (tip == "more") {
		partyMemberList.value = partyMemberList.value.concat(res.result.page.records);
	} else {
		partyMemberList.value = res.result.page.records;
	}
	// 为图片拼接IP
	// partyMemberList.value.map((item:any) => {
	// 	item.fieldAcquisitionUrl = BASEURL + '/image/' + item.fieldAcquisitionUrl
	// })
	if (res.result.pages == pageNo.value) {
		moreScroll.value = false;
	} else {
		pageNo.value = pageNo.value + 1;
	}
};

onMounted(async () => {
	await getCompanyList();
	await getMemberCountList("search");
	await getStatisticsNumDataFn();
	refScrollbar.value.wrapRef.addEventListener("scroll", (e: any) => {
		// console.log("滚动容器", e);
		const scrollTop = e.target.scrollTop;
		const scrollHeight = e.target.scrollHeight;
		const clientHeight = e.target.clientHeight;
		// console.log("滚动容器", scrollTop, scrollHeight, clientHeight);
		// 向上加载更多
		if (scrollTop >= scrollHeight - clientHeight - 1) {
			// console.log("加载更多");
			if (moreScroll.value) {
				getMemberCountList("more");
			}
		}
	});
});
</script>

<style lang="scss" scoped>
@mixin flex {
	display: flex;
	align-items: center;
}
.political-outlook {
	height: 97%;
	margin: 0 60px;
	.content {
		height: 95%;
		width: 100%;
		margin-top: 10px;
		// background: url("@/assets/images/cardImg.png") no-repeat;
		background-size: 100% 100%;
		padding: 20px 15px;
		.top-count {
			width: 80%;
			height: 50%;
			margin: 0 auto;
			background-color: #0e244e;
			padding-top: 1%;
			.rightHeader {
				width: 100%;
				height: 8%;
				display: flex;
				justify-content: flex-end;
				color: #fff;
				font-size: 10px;
				text-align: center;
				.Selected {
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
					background: url("@/assets/images/dustNoise/rightImg2.png") no-repeat;
					background-size: 100% 100%;
					cursor: pointer;
				}
				.day {
					width: 8%;
					margin-right: 2%;
				}
				.year {
					width: 8%;
					margin-right: 2%;
				}
				.active {
					background: url("@/assets/images/dustNoise/rightImg.png") no-repeat;
					background-size: 100% 100%;
				}
			}
			.risk-count-all {
				display: flex;
				flex-direction: column;
				align-items: center;
				color: white;
				.all-sum {
					display: flex;
					align-items: center;
					span:nth-child(1) {
						font-size: 46px;
					}
					span:nth-child(2) {
						font-size: 26px;
						margin-top: 10px;
						margin-left: 5px;
					}
				}
				> span {
					margin-top: 1%;
					font-size: 14px;
				}
			}
			.risk-classify {
				width: 95%;
				height: 50%;
				display: grid;
				grid-gap: 20px;
				grid-template-columns: repeat(4, 1fr);
				color: white;
				margin: 0 auto;
				margin-top: 3%;
				.classify-item {
					width: 100%;
					height: 100%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
				}
				.classify-one {
					background-color: #e02020;
				}
				.classify-two {
					background-color: #f46649;
				}
				.classify-three {
					background-color: #ecbe45;
				}
				.classify-four {
					background-color: #5394f7;
				}
			}
		}
		.radio-content{
			margin-top: 2%;
			:deep(.el-radio) {
				.el-radio__label {
					color: #fff;
				}
				.el-radio__input {
					&.is-indeterminate {
						background: #5181f6;
					}
					&.is-checked {
						// border-left: 2px solid #5181f6;
						// background: #e2e8f8;
						background: rgba(81, 129, 246, 0.3);
						// background: url("@/assets/images/carPosition/chioceType.png") no-repeat;
						.el-radio__inner {
							background: #5181f6;
						}
					}
					.el-radio__inner {
						border: 1px solid #224ea8;
						background: none;
						&:hover {
						}
					}
				}
			}
		}
		.table-one {
			height: 30%;
			.tabList {
				display: flex;
				// width: 100%;
				height: 20%;
				background: url("@/assets/images/vehicleManagement/ListTitleImg.png") no-repeat;
				background-size: 100% 100%;
				// position: absolute;
				left: 75.5%;
				top: 75%;
				color: #ccc;
				font-size: calc(100vw * 14 / 1920);
				line-height: 30px;
				align-items: center;
				margin-top: 2%;
				div {
					text-align: center;
					width: 20%;
				}
			}
			.listBox {
				height: 69%;
				.listStyle {
					display: flex;
					align-items: center;
					text-align: center;
					color: #fff;
					font-size: 12px;
					margin-bottom: 5px;
					.list-img {
						.el-img {
							width: 30px;
							height: 30px;
							img {
								display: flex;
								align-items: center;
								width: 100%;
								height: 100%;
							}
						}
					}
					div {
						width: 20%;
						white-space: nowrap; //单行
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
				.listStyle:hover {
					background: #091f3f;
				}
			}
		}
		:deep() {
			.el-tabs__item {
				color: white;
			}
			.el-tabs__item.is-active {
				color: var(--el-color-primary);
			}
		}
	}
}
.notoDta {
	top: 35%;
	width: 20%;
	left: 40%;
	position: absolute;
	text-align: center;
	img {
		width: 40%;
		margin: 5% 30%;
	}
	p {
		color: #fff;
		font-size: calc(100vw * 14 / 1920);
		margin: -6% 37%;
	}
}
// element 组件样式
:deep() {
	.el-date-editor .el-range-input,
	.el-range-separator {
		color: #fff;
	}
	.el-input__wrapper {
		background: #112d59;
	}
	.el-input__inner {
		color: #fff;
	}
	.el-button {
		background-color: #2758c0;
		color: white;
		border-color: transparent;
	}
}
// ::v-deep .el-select .el-input .el-select__caret {
// 	color: #fff;
// }
</style>
