<template>
	<view class="container">
		<view class="add_btn">
			<u-button type="primary" size="small" text="去上报" style="width: 80px;" @click="addAlarm"
				icon="plus-circle"></u-button>
		</view>
		<view class="list">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
				@scrolltolower="lower" @scroll="scroll">
				<view class="card" v-for="(item,index) in list" @click="toDetail(item.id)">
					<view class="title">{{item.license}}</view>
					
					<view class="name_1 flex">事件类型：{{item.name}}</view>
					
					<view class="name_1 flex">上报时间：{{item.create_time}}</view>

					<view class="name_1 flex">
						<u-tag text="已通过" type="success" v-if="item.status == 1"></u-tag>
						<u-tag text="拒绝" type="warning" v-else-if="item.status == 2"></u-tag>
						<u-tag text="审核中" type="error" v-else></u-tag>

					</view>
				</view>
			</scroll-view>


		</view>
	</view>

</template>

<script>
	import {
		get,
		post
	} from '@/common/request.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getAlarmList()
		},
		methods: {
			onPullDownRefresh() {
				setTimeout(() => {
					this.getAlarmList()
					uni.stopPullDownRefresh();
				}, 500);
			},
			addAlarm(){
				uni.navigateTo({
					url:'/pages/order/addAlarm'
				})
			},
			async getAlarmList() {
				await get('/myapi/api/yq_driver/troubleList').then((res) => {
					this.list = res.data
				})
			},
			toDetail(id){
				uni.navigateTo({
					url:'/pages/order/detailAlarm?id='+id
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.container {
		padding: 20px;


		.add_btn {
			position: fixed;
			top: 50px;
			right: 10px;
			z-index: 1;
		}

		.list {

			.scroll-Y {
				height: calc(100vh - 86px);

				.card {
					background-color: #fff;
					padding: 10px;
					margin-bottom: 10px;
					font-size: 14px;
					border-radius: 10px;
					border: 1px solid #f4f4f4;
					.title {
						font-size: 18px;
						font-weight: 700;
						height: 40px;
						line-height: 40px;
						border-bottom: 1px solid #f4f4f4;
						display: flex;
						justify-content: space-between;
						align-items: center;
					}

					.flex {
						display: flex;

						.icon-right {
							margin-right: 5px;
						}
					}

					.name_1 {
						margin: 10px 0;

					}
				}
			}
		}

	}
</style>