<template>
	<view class="">
		<view @click="goDetail(item)" class="data" v-for="(item, index) in list" :key="index">
			<view class="top">
				<view class="left">
					<view class="title">
						<text>IMEI：{{item.imei}}</text>
						<text @click.stop="copy(item.imei)" style="text-decoration: underline;"
							class="base-color padding-left-20">复制</text>
					</view>
				</view>
				<view class="right">
					<view v-if="item.defenseStatus==1" style="font-size: 24rpx;" class="radius sm cu-btn line-green">
						已上线
					</view>
					<view v-if="item.defenseStatus==2" class="radius sm cu-btn line-red">
						已下线
					</view>
				</view>
			</view>
			<view class="item">
				<view class="left">
					<view style="padding: 0 30rpx;">
						<view class="content flex">
							<u-icon size="32" name="bookmark-fill" color="#5064eb"></u-icon>
							<text class="text-bold padding-left-10">设备名称：</text>
							<text>{{item.deviceName}}</text>
						</view>
						<view class="content flex">
							<u-icon size="36" name="map-fill" color="#5064eb"></u-icon>
							<text class="text-bold padding-left-10">安装位置：</text>
							<text>{{item.deviceInstallAddress || '未知'}}</text>
						</view>
						<view v-if="item.deviceType==100030" class="content flex align-center justify-start">
							<u-icon size="36" name="home" color="#fd9510"></u-icon>
							<text class="text-bold padding-left-10">所属企业：</text>
							<text v-text="item.enterpriseNames?item.enterpriseNames:'未知'"
								style="padding-top: 8rpx;"></text>
						</view>
						<view class="content flex">
							<u-icon size="32" name="clock-fill" color="#5064eb"></u-icon>
							<text class="text-bold padding-left-10">更新时间：</text>
							<text style="padding-top: 8rpx;" v-text="item.updateTime?item.updateTime:'未知'"></text>
						</view>
					</view>
				</view>
			</view>
			<view class="bottom flex">
				<view @click.stop="goDetail(item)" style="font-size: 22rpx;font-weight: 800;"
					class="cu-btn  sm round  base-line">
					查看详情
				</view>
				<view @click.stop="goAlarm(item)" class="cu-btn  sm round base-line"
					style="margin: 0 20rpx;font-size: 22rpx;font-weight: 800;">
					<text v-if="item.deviceType==100030">抄表记录</text>
					<text v-else>告警记录</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'card',
		props: {
			list: {
				type: Array,
				default: () => {
					[]
				}
			}
		},
		data() {
			return {
				loading: false
			};
		},
		created() {
			let that = this;
			setTimeout(function() {
				that.loading = true
			}, 500)
		},
		methods: {
			copy(data) {
				uni.setClipboardData({
					data: data
				})
			},
			goDetail(item) {
				getApp().globalData.fireHydrantDetail = item
				uni.navigateTo({
					url: '/pages/index/fire/detail'
				})
			},
			goAlarm(item) {
				uni.navigateTo({
					url: "/pages/index/fire/alarm-record?imei=" + item.imei
				})
			}
		}
	};
</script>

<style lang="scss">
	.line-green {
		border-color: #16aa5d;
		color: #16aa5d;
	}

	.line-red {
		border-color: #cf0000;
		color: #cf0000;
	}

	.data {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 6rpx;
		box-sizing: border-box;
		padding: 20rpx 10rpx;
		font-size: 28rpx;

		.top {
			display: flex;
			justify-content: space-between;
			padding-bottom: 20rpx;
			border-bottom: 1rpx solid $dt-border-color-sm;

			.left {
				display: flex;
				align-items: center;

				.title {
					margin: 0 10rpx;
					font-size: 30rpx;
				}
			}

			.right {
				margin-right: 20rpx;
			}
		}

		.item {
			margin: 5rpx 0 20rpx 0;

			.content {
				border-bottom: 1rpx dashed #DDDDDD;
				padding: 30rpx 0;
			}
		}

		.bottom {
			display: flex;
			margin-top: 30rpx;
			justify-content: flex-end;
			align-items: center;
		}
	}
</style>
