<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<text style="color: white;font-size: 1rem;">{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="item in list" :key="item.id">
					<template v-slot:body>
						<view style="min-height: 110px;width: 100%;display: flex;flex-direction: column;">
							<view style="display: flex;flex-direction: row;align-items: center;">
								<image class="order-title-image" src="/static/images/icon_warning.png" mode="widthFix">
								</image>
								<text style="margin-left: 5px;font-size: 1rem;">{{item.rtuName}}</text>
								<text style="margin-left: 5px;font-size: 0.9rem;">[{{item.rtuCode}}]</text>
							</view>
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view style="font-size: 0.7rem;">预警时间:</view>
								<view style="margin-left:10px;font-size: 0.7rem;">
									{{item.warningHappenTime}}
								</view>
							</view>
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view style="font-size: 0.7rem;">恢复时间:</view>
								<view v-if="item.warningRecoveryTime!=null"
									style="margin-left:10px;font-size: 0.7rem;">{{item.warningRecoveryTime}}
								</view>
							</view>
							<view style="margin-top: 0px;display: flex;flex-direction: row;align-items: center;">
								<!-- <uIcons class="input-uni-icon" type="notification" size="18" color="#999" /> -->
								<text style="font-size: 0.7rem;">{{item.warningDesc}}</text>
							</view>
							<view style="margin-top:4px;display: flex;flex-direction: row;justify-content: flex-end;">
								<view
									style="display:flex;flex-direction: row;justify-content: center;width: 90px;height:28px;margin-right: 10px;border-radius:7px;background-color:lightblue"
									@click="toWarningPage(item.id)">
									<view style="display:flex;flex-direction: column;justify-content: center;">
										<uIcons class="input-uni-icon" type="info" size="18" color="coral" />
									</view>
									<view
										style="display:flex;flex-direction: column;justify-content: center;padding-left:5px;">
										<text style="color:black;font-size:0.6rem">预警详情</text>
									</view>
								</view>

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

				</uni-list-item>

			</uni-list>
			<uGroup>
				<view class="uni-pagination-box">
					<uPagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total"
						@change="change" />
				</view>
			</uGroup>
		</view>

		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
	// import pageNav from '@/components/page-nav/page-nav.vue';
	import http from '@/http/api.js';
	import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
	import uDataPicker from '@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue'
	import uGroup from '@/uni_modules/uni-group/uni-group.vue'
	import uSection from '@/uni_modules/uni-section/uni-section.vue'
	import uPagination from '@/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue'
	import uBreadcrumb from '@/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue'
	import uList from '@/uni_modules/uni-list/components/uni-list/uni-list.vue'
	import uListItem from '@/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue'
	import uIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
	export default {
		name: '',
		components: {
			uNavBar,
			uList,
			uListItem,
			uIcons,
			uGroup,
			uPagination,
			uBreadcrumb
		},
		onLoad(option) {
			this.rtuCode = option.rtuCode;
		},
		data() {
			return {
				list: [],
				title: '测站预警信息',
				desc: '',
				rtuCode: '',
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {
			// uni.setNavigationBarTitle({
			// 	title: ""
			// });
			this.loadList();
		},
		created() {

		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			loadList() {
				var that = this;
				const current = this.pageCurrent;
				const size = this.pageSize;
				const isSubmit = '0';
				var formdata = {};
				formdata['rtuCode'] = this.rtuCode;
				http.request({
					url: '/galaxy-test/rtu/warning/page',
					method: 'GET',
					data: formdata,
					params: {
						current,
						size,
						isSubmit
					},
				}).then(res => {
					if (res.data.records != null) {
						that.list = res.data.records;
					}
					this.total = res.data.total;

				}).catch(err => {
					console.log(err)
				})


			},
			toWarningPage(id) {
				var url = '/pages/warning/warninginfodetail?id=' + id;
				uni.navigateTo({
					url: url
				})
			},

		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}

	.order-title-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		// margin-right: 10px;
		width: 25px;
		height: 25px;
		border-radius: 50%;
	}

	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}

	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 30px;
	}

	.slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}

	.content-box {
		flex: 1;
		/* #ifdef APP-NVUE */
		justify-content: center;
		/* #endif */
		height: 100%;
		line-height: 44px;
		padding: 0 15px;
		position: relative;
		background-color: #fff;
		border-bottom-color: #f5f5f5;
		border-bottom-width: 1px;
		border-bottom-style: solid;
	}

	.content-text {
		font-size: 15px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding: 10px 0;
		background-color: #fff;
	}

	.button {
		border-color: #e5e5e5;
		border-style: solid;
		border-width: 1px;
		padding: 4px 8px;
		border-radius: 4px;
	}

	.button-text {
		font-size: 15px;
	}

	.slot-button {
		/* #ifndef APP-NVUE */
		display: flex;
		height: 100%;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 0 20px;
		background-color: #ff5a5f;
	}

	.slot-button-text {
		color: #ffffff;
		font-size: 14px;
	}
</style>
