<template>
	<div class="political-outlook">
		<div class="content">
			<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
				<el-tab-pane :label="'形象进度'" name="first"></el-tab-pane>
				<el-tab-pane :label="'安全隐患'" name="second"></el-tab-pane>
				<el-tab-pane :label="'验收记录'" name="third"></el-tab-pane>
				<el-tab-pane :label="'旁站记录'" name="four"></el-tab-pane>
			</el-tabs>
			<div class="tabs-one" v-if="activeIndex == 0">
				<div class="tabList">
					<div>序号</div>
					<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.engineeringName}}</div>
						<div>
							<el-tooltip class="box-item" effect="dark" :content="item.progressDescribe" placement="top-start">
								<span>{{item.progressDescribe}}</span>
							</el-tooltip>
						</div>
						<div class="list-img">
							<el-image
								fit="contain"
								class="el-img"
								:src="BASEURL + '/image/' + item.imageUrl"
								:preview-src-list="[BASEURL + '/image/' + item.imageUrl]"
							>
							<template #error>
									<el-image :src="noDataImage" :preview-src-list="[noDataImage]" fit="contain" class="el-no-img" alt="" />
								</template>
							</el-image>
							<!-- <img :src="item.fieldAcquisitionUrl" alt="" srcset=""> -->
						</div>
						<div>{{item.createUserName}}</div>
						<div>{{item.createTime}}</div>
					</div>
					<div class="notoDta" v-if="partyMemberList.length == 0">
						<img src="@/assets/images/noData.png" alt="" />
						<p>暂无数据</p>
					</div>
				</el-scrollbar>
			</div>
			<div class="tabs-two" v-if="activeIndex == 1">
				<div class="tabList">
					<div>序号</div>
					<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.engineeringName}}</div>
						<div>{{item.status == 2
                            ? '待整改'
                            : item.status == 3
                            ? '待复查'
                            : item.status == 4
                            ? '待核验'
                            : item.status == 5
                            ? '合格'
                            : ''}}</div>
						<div>{{item.inspectManName}}</div>
						<div>{{item.inspectTime}}</div>
						<div>{{item.changeName}}</div>
					</div>
					<div class="notoDta" v-if="partyMemberList.length == 0">
						<img src="@/assets/images/noData.png" alt="" />
						<p>暂无数据</p>
					</div>
				</el-scrollbar>
			</div>
			<div class="tabs-three" v-if="activeIndex == 2">
				<div class="tabList">
					<div>序号</div>
					<div>危大工程名称</div>
					<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.engineeringName}}</div>
						<div>
							<el-tooltip class="box-item" effect="dark" :content="item.acceptanceDesc" placement="top-start">
								<span>{{item.acceptanceDesc}}</span>
							</el-tooltip>
						</div>
						<div>{{item.acceptanceResult == 1?'合格':'不合格'}}</div>
						<div class="list-img">
							<el-image
								fit="contain"
								class="el-img"
								:src="BASEURL + '/image/' + item.photo"
								:preview-src-list="[BASEURL + '/image/' + item.photo]"
							>
							<template #error>
									<el-image :src="noDataImage" :preview-src-list="[noDataImage]" fit="contain" class="el-no-img" alt="" />
								</template>
							</el-image>
							<!-- <img :src="item.fieldAcquisitionUrl" alt="" srcset=""> -->
						</div>
						<div>{{item.applyAcceptanceUserName}}</div>
						<div>{{item.createTime}}</div>
					</div>
					<div class="notoDta" v-if="partyMemberList.length == 0">
						<img src="@/assets/images/noData.png" alt="" />
						<p>暂无数据</p>
					</div>
				</el-scrollbar>
			</div>
			<div class="tabs-four" v-if="activeIndex == 3">
				<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.buildSituation}}</div>
						<div class="list-img">
							<el-image
								fit="contain"
								class="el-img"
								:src="BASEURL + '/image/' + item.imageUrl"
								:preview-src-list="[BASEURL + '/image/' + item.imageUrl]"
							>
							<template #error>
										<el-image :src="noDataImage" :preview-src-list="[noDataImage]" fit="contain" class="el-no-img" alt="" />
								</template>
							</el-image>
							<!-- <img :src="item.fieldAcquisitionUrl" alt="" srcset=""> -->
						</div>
						<div>{{item.createUserName}}</div>
						<div>{{item.createTime}}</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 type { TabsPaneContext } from 'element-plus'
import noDataImage from "@/assets/images/vehicleManagement/car.png";
import { getProgressRecordApi, getInspectionRecordApi, getEngineeringRecordApi, getSideStationApi } from "@/api/modules/agjtCommandApi";
const store = GlobalStore();
const props = defineProps(["tip"]);
const BASEURL = import.meta.env.VITE_API_URL;
const activeName = ref('first')
const activeIndex = ref(0 as any)
const onlineWorkList = ref([
	{ name: "在职", value: 1 },
	{ name: "离职", value: 2 }
])
const memberTypeList = ref([
	{ name: "劳务人员", value: 1 },
	{ name: "管理人员", value: 2 },
	{ name: "临时人员", value: 3 }
]);
const alarmTypeList = ref(["报警", "预警"]);
let pageNo = ref(1 as any);
let moreScroll = ref(true as any);
const refScrollbar = ref(null as any); // 绑定到滚动的盒子上
const deviceList = ref([] as any); // 设备列表
const searchForm = ref({
	memberType: '',
	belongCompany: '',
	workState: '',
	name: '',
	idCard: ''
});

const partyMemberList = ref([] as any);
const handleClick = (tab: TabsPaneContext, event: Event) => {
//   console.log(tab, event)
//   console.log('tab',tab.index)
//   console.log('activeName',activeName.value)
//   if(activeName.value === 'first') console.log('1')
//   if(activeName.value === 'second') console.log('2')
//   if(activeName.value === 'third') console.log('3')
	activeIndex.value = tab.index
	partyMemberList.value = [];
	getMemberCountList('search')
	console.log('activeIndex',activeIndex.value)
}
//获取数据
const getMemberCountList = async (tip:any) => {
	let requestData:any = {
		projectSn: store.sn,
		pageNo: tip == 'search'?1:pageNo.value,
		pageSize: 100
	}
	let requestFn:any;
	if(activeIndex.value == 0){
		requestFn = getProgressRecordApi;
	} else if(activeIndex.value == 1){
		requestFn = getInspectionRecordApi;
		requestData.isDangerousEngineering = 1;
	} else if(activeIndex.value == 2){
		requestFn = getEngineeringRecordApi;
	} else if(activeIndex.value == 3){
		requestFn = getSideStationApi;
	}
	const res: any = await requestFn(requestData);
	console.log("获取危大工程数据", res);
	if(tip == 'more'){
		if(activeIndex.value == 0){
			partyMemberList.value = partyMemberList.value.concat(res.result.records);
		} else if(activeIndex.value == 1){
			partyMemberList.value = partyMemberList.value.concat(res.result.page.records);
		} else if(activeIndex.value == 2){
			partyMemberList.value = partyMemberList.value.concat(res.result.records);
		} else if(activeIndex.value == 3){
			partyMemberList.value = partyMemberList.value.concat(res.result.records);
		}
	} else {
		if(activeIndex.value == 0){
			partyMemberList.value = partyMemberList.value.concat(res.result.records);
		} else if(activeIndex.value == 1){
			partyMemberList.value = partyMemberList.value.concat(res.result.page.records);
		} else if(activeIndex.value == 2){
			partyMemberList.value = partyMemberList.value.concat(res.result.records);
		} else if(activeIndex.value == 3){
			partyMemberList.value = partyMemberList.value.concat(res.result.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 getMemberCountList('search');
	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;
		.tabs-one{
			height: 100%;
			margin: 0 3%;
			.tabList {
				display: flex;
				// width: 100%;
				height: 5%;
				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: 17%;
				}
			}
			.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%;
							}
						}
							.el-no-img{
							width: 30px;
							height: 30px;
							}
					}
					div {
						width: 17%;
						white-space: nowrap; //单行
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
				.listStyle:hover {
					background: #091f3f;
				}
			}
		}
		.tabs-two{
			height: 100%;
			margin: 0 3%;
			.tabList {
				display: flex;
				// width: 100%;
				height: 5%;
				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: 17%;
				}
			}
			.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%;
							}
						}
							.el-no-img{
							width: 30px;
							height: 30px;
							}
					}
					div {
						width: 17%;
						white-space: nowrap; //单行
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
				.listStyle:hover {
					background: #091f3f;
				}
			}
		}
		.tabs-three{
			height: 100%;
			margin: 0 3%;
			.tabList {
				display: flex;
				// width: 100%;
				height: 5%;
				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%;
							}
						}
							.el-no-img{
							width: 30px;
							height: 30px;
							}
					}
					div {
						width: 20%;
						white-space: nowrap; //单行
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
				.listStyle:hover {
					background: #091f3f;
				}
			}
		}
		.tabs-four{
			height: 100%;
			margin: 0 3%;
			.tabList {
				display: flex;
				// width: 100%;
				height: 5%;
				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: 50px;
						height: 25px;
					}
						.el-img {
							width: 30px;
							height: 30px;
							img {
								display: flex;
								align-items: center;
								width: 100%;
								height: 100%;
							}
						}
							.el-no-img{
							width: 30px;
							height: 30px;
							}
					}
					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>
