<template>
	<view class="page-body">
		<page-header :name="pageData.name" :bg="'#1560e0'" :showLeft="true" @goBack="goBack()"></page-header>
		<view class="scroll-wrap">
			<view class="basic-info-wrap">
				<view class="info-wrap">
					<view @click="activeChange(item)" v-for="(item,index) in list"
						:class="activeData.name === item.name ? 'active item' : 'item'" :key="index">
						<status-tip class="status-wrap" :name="item.name" :status="item.status"
							:tip="item.status ? '运行' : '停止'"></status-tip>
					</view>
				</view>
				<view class="img-wrap">
					<image v-if="activeData.status" src="@/static/nitrogen.jpg" />
					<image v-else src="@/static/nitrogen-static.png" />
					<view>
						{{ activeData.name }}
					</view>
				</view>
				<view class="radius-wrap"></view>
			</view>
			<view class="detail-info-wrap">
				<page-card style="margin-bottom: 30rpx;" :notShow="true" :name="activeData.name">
					<template v-slot:content>
						<simple-table :tableHead="tableHead" :list="paramsList"></simple-table>
					</template>
				</page-card>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageData: {},
				activeData: {},
				list: [{
					name: '副立井1#空压机',
					status: 1
				}, {
					name: '副立井2#空压机',
					status: 1
				}],
				tableHead: ['名称', '参数/状态'],
				paramsList: [{
						name: '运行时间(h)',
						params: ['30439']
					},
					{
						name: '加载时间(s)',
						params: ['28116']
					},
					{
						name: '排气压力(MPa)',
						params: ['0.51']
					},
					{
						name: '排气温度(℃)',
						params: ['80.30']
					},
					{
						name: '电机电流(A)',
						params: ['0.00']
					},
					{
						name: '油气桶压力(MPa)',
						params: ['0.58']
					},
					{
						name: '油漆桶温度(℃)',
						params: ['72.40']
					},
					{
						name: 'KYJ自动运行停机',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ排气压力异常',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ风机接触器故障',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ主接触器故障',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ油压过低',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJA\D故障',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ风机过滤',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ排气高温',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ油滤压差',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ相序错误',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ主电机过流',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ空滤压差',
						params: [{
							status: 1
						}]
					},
					{
						name: 'KYJ油细压差',
						params: [{
							status: 1
						}]
					},
					{
						name: '重故障',
						params: [{
							status: 1
						}]
					},
					{
						name: '轻故障',
						params: [{
							status: 1
						}]
					}
				]
			}
		},
		onLoad(option) {
			this.pageData = JSON.parse(option.data)
			this.activeData = this.list[0]
		},
		methods: {
			goBack() { // 返回上一頁面
				uni.navigateBack()
			},
			activeChange(item) { // 切换状态
				this.activeData = item
			}
		}
	}
</script>

<style scoped lang="scss">
	.page-body {
		.scroll-wrap {
			height: calc(100vh - 85rpx);
			overflow: scroll;

			.basic-info-wrap {
				position: relative;
				height: auto;
				padding: 50rpx 49rpx 0;
				background: url(../../../static/page_bg.png);
				background-size: 120%;

				.info-wrap {
					display: flex;
					flex-wrap: wrap;
					border-bottom: 1rpx dashed #fff;
					padding-bottom: 30rpx;

					.item {
						display: flex;
						padding: 24rpx 14rpx;
						justify-content: space-between;
						width: 50%;
						color: #fff;
						font-size: 26rpx;

						.status-wrap {
							width: 100%;

							/deep/ .tip-wrap {
								justify-content: space-between;
							}
						}

						.params {
							color: #FFFF00;
						}
					}

					.active {
						background: #3495FA;
						box-shadow: 0px 3px 7px 0px rgba(0, 8, 35, 0.31);
						border-radius: 14px;
					}
				}

				.img-wrap {
					padding: 49rpx 0;
					text-align: center;

					image {
						width: 310rpx;
						height: 138rpx;
					}

					view {
						margin-top: 25rpx;
						color: #fff;
					}
				}

				.radius-wrap {
					position: absolute;
					left: 0;
					bottom: 0;
					width: 100vw;
					height: 30rpx;
					background-color: #fff;
					border-radius: 35rpx 35rpx 0 0;
				}
			}

			.detail-info-wrap {
				padding: 40rpx 35rpx;

				/deep/ .card-wrap:last-child {
					margin-bottom: 0 !important;
				}
			}
		}
	}
</style>