<!-- 数据看板-设备管控-超期服役排行 -->
<template>
	<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
		<view class="equipmentControl">
			<!-- 超期服役排行 -->
			<view class="table" v-if="pageType==1">
				<view class="table-border">
					<view class="table-th">
						<view class="table-th-li">
							<view>排行</view>
							<view>学院单位</view>
							<view>设备总数(台)</view>
							<view>超期服役数(台)</view>
						</view>
					</view>
					<view class="table-tb">
						<view class="table-tb-li" v-for="(item,index) in dataList" :key="index">
							<view>
								<text
									:class="index==0?'sortOne':(index==1?'sortTow':(index==2?'sortThree':'sortFive'))">{{index+1}}</text>
							</view>
							<view>{{item.deptName}}</view>
							<view>{{item.deviceNum}}</view>
							<view>{{item.extendedService}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 设备使用寿命 -->
			<view class="table-tow" v-if="pageType==2">
				<view class="table-border">
					<view class="table-th">
						<view class="table-th-li">
							<view>学院单位</view>
							<view>5年内(台)</view>
							<view>10年内(台)</view>
							<view>12年内(台)</view>
							<view>20年内(台)</view>
						</view>
					</view>
					<view class="table-tb">
						<view class="table-tb-li" v-for="(item,index) in dataList" :key="index">
							<view>{{item.deptName}}</view>
							<view>{{item.fiveYears}}</view>
							<view>{{item.tenYears}}</view>
							<view>{{item.twelveYears}}</view>
							<view>{{item.twentyYears}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
		</view>
		
	</scroll-view>
</template>

<script>
	import {
		config
	} from '@/api/request/config.js'
	import {
		reportAppletReportApiEquipOverdueGetLifePageList,
		reportAppletReportApiEquipLifeGetReportBsEquipLifeList
	} from '@/pages/api/index.js'
	export default {
		name: "equipmentControl",
		components: {

		},
		data() {
			return {
				pageType: 1,
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
				},
				dataList: [],
				total: 0,
				getDataType:false,
			}
		},
		onLoad(option) {
			if (option.pageType) {
				this.pageType = option.pageType;
				if (this.pageType == 1) {
					uni.setNavigationBarTitle({
						title: '超期服役排行'
					})
				} else if (this.pageType == 2) {
					uni.setNavigationBarTitle({
						title: '设备使用寿命统计'
					})
				}
			}
		},
		created() {

		},
		beforeMount() {

		},
		mounted() {
			if (this.pageType == 1) {
				this.getList();
			} else if (this.pageType == 2) {
				this.getListTow();
			}
		},
		methods: {
			//滚动事件
			scrollGet() {
				let self = this;
				if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
					this.$set(this, 'getDataType', true);
				} else {
					this.queryParams.page += 1;
					this.$nextTick(() => {
						if (this.pageType == 1) {
							this.getList();
						} else if (this.pageType == 2) {
							this.getListTow();
						}
					})
				}
			},
			async getList() {
				let self = this;
				const {
					data
				} = await reportAppletReportApiEquipOverdueGetLifePageList(this.queryParams);
				if (data.code == 200) {
					if (self.queryParams.page == 1) {
						this.dataList = data.data.records;
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					} else {
						this.dataList = [...this.dataList, ...data.data.records]
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					}
				}
			},
			async getListTow() {
				let self = this;
				const {
					data
				} = await reportAppletReportApiEquipLifeGetReportBsEquipLifeList(this.queryParams);
				if (data.code == 200) {
					if (self.queryParams.page == 1) {
						this.dataList = data.data.records;
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					} else {
						this.dataList = [...this.dataList, ...data.data.records]
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					}
				}
			},
			
			dateClick(index) {
				this.dateIndex = index;
			},
		},
	}
</script>

<style lang="stylus" scoped>
	.info-max-box{
		height: 100%;
		width: 100%;
	}
	.equipmentControl {
		height: 100%;
		width: 100%;
		background: #363744;
		box-sizing: border-box;

		.table {
			width: 750rpx;

			.table-border {
				overflow: auto;

				.table-th {
					width: 750rpx;
					height: 80rpx;
					background: rgba(162, 162, 162, 0.2);
					padding: 0 30rpx;
					box-sizing: border-box;

					.table-th-li {
						height: 80rpx;
						display: flex;
						justify-content: flex-start;

						>view {
							font-weight: 400;
							font-size: 30rpx;
							color: #FFFFFF;
							line-height: 80rpx;
							text-align: center;
							margin-right: 18rpx;
							width: 120rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						>view:nth-of-type(1) {
							width: 90rpx;
							text-align: left;
						}

						>view:nth-of-type(2) {
							width: 168rpx;
						}

						>view:nth-of-type(3) {
							width: 190rpx;
						}

						>view:nth-of-type(4) {
							width: 300rpx;
						}
					}
				}

				.table-tb {
					width: 750rpx;
					border-bottom: 1rpx dashed rgba(216, 216, 216, 0.2);
					background: #3E414F;
					padding: 0 30rpx;
					box-sizing: border-box;

					.table-tb-li {
						height: 80rpx;
						border-bottom: 1rpx dashed rgba(216, 216, 216, 0.2);
						display: flex;
						justify-content: flex-start;

						>view {
							font-weight: 400;
							font-size: 28rpx;
							color: #FFFFFF;
							line-height: 80rpx;
							text-align: center;
							margin-right: 38rpx;
							width: 120rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;

						}

						>view:nth-of-type(1) {
							width: 90rpx;
							text-align: left;
						}

						>view:nth-of-type(2) {
							width: 168rpx;
						}

						>view:nth-of-type(3) {
							width: 190rpx;
						}

						>view:nth-of-type(4) {
							width: 300rpx;
						}

					}
				}
			}

		}

		.sortOne {
			display: inline-block;
			width: 40rpx;
			height: 40rpx;
			padding: 4rpx;
			box-sizing: border-box;
			background: rgba(255, 0, 0, 0.2);
			font-weight: 400;
			font-size: 28rpx;
			color: #FF0000;
			line-height: 40rpx;
			text-align: center;
			border-radius: 20rpx;
		}

		.sortTow {
			display: inline-block;
			width: 40rpx;
			height: 40rpx;
			padding: 4rpx;
			box-sizing: border-box;
			background: rgba(255, 153, 0, 0.2);
			font-weight: 400;
			font-size: 28rpx;
			color: #FF9900;
			line-height: 40rpx;
			text-align: center;
			border-radius: 20rpx;
		}

		.sortThree {
			display: inline-block;
			width: 40rpx;
			height: 40rpx;
			padding: 4rpx;
			box-sizing: border-box;
			background: rgba(255, 242, 0, 0.2);
			font-weight: 400;
			font-size: 28rpx;
			color: #FFF200;
			line-height: 40rpx;
			text-align: center;
			border-radius: 20rpx;
		}

		.sortFive {
			display: inline-block;
			width: 40rpx;
			height: 40rpx;
			padding: 4rpx;
			box-sizing: border-box;
			background: rgba(1, 131, 250, 0.2);
			font-weight: 400;
			font-size: 28rpx;
			color: #0183FA;
			line-height: 40rpx;
			text-align: center;
			border-radius: 20rpx;
		}

		.table-tow {
			width: 750rpx;

			.table-border {
				overflow: auto;

				.table-th {
					width: 860rpx;
					height: 80rpx;
					background: rgba(162, 162, 162, 0.2);
					padding: 0 30rpx;
					box-sizing: border-box;

					.table-th-li {
						height: 80rpx;
						display: flex;
						justify-content: flex-start;

						>view {
							font-weight: 400;
							font-size: 30rpx;
							color: #FFFFFF;
							line-height: 80rpx;
							text-align: center;
							margin-right: 18rpx;
							width: 140rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						>view:nth-of-type(1) {
							width: 168rpx;
							text-align: left;
						}

					}
				}

				.table-tb {
					width: 860rpx;
					border-bottom: 1rpx dashed rgba(216, 216, 216, 0.2);
					background: #3E414F;
					padding: 0 30rpx;
					box-sizing: border-box;

					.table-tb-li {
						height: 80rpx;
						border-bottom: 1rpx dashed rgba(216, 216, 216, 0.2);
						display: flex;
						justify-content: flex-start;

						>view {
							font-weight: 400;
							font-size: 28rpx;
							color: #FFFFFF;
							line-height: 80rpx;
							text-align: center;
							margin-right: 38rpx;
							width: 140rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;

						}

						>view:nth-of-type(1) {
							width: 168rpx;
							text-align: left;
						}

					}
				}
			}

		}
	}
	.get-data-null-p {
		text-align: center;
		height: 100rpx;
		line-height: 100rpx;
		color: #999;
		padding-bottom:200rpx;
	}
</style>
