<template>

	<view class="">
		<view class="cu-list menu-avatar">
			<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
				v-for="(item,index) in getData" :key="index" :data-target="'move-box-' + index"
				@tap="goDeviceDetail(item)">
				<view class="cu-avatar round lg">
					<image class="image-bg" src="/static/device-icon.png"/>
				</view>
				<view class="content">
					<view class="pro-title">
						<view class="cut">{{item.owner_name}}</view>
					</view>
					<view class="pro-des  ">
						<view class="text-cut">
							{{item.unitinfo}}
						</view>
					</view>
					<view class="pro-date ">{{item.install_time}}</view>
				</view>
				<view class="nav-right num">
					<view class="text-grey">
						<!-- <span class="online">{{item.device_state}}</span> -->
						<span :class="item.device_state=='在线'?'online':'offline'">{{item.device_state}}</span>
						<!-- <span class="offline" v-if="item.status==1">离线</span>
						<span class="error" v-if="item.status==2">故障</span> -->
						<text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import json from '../../data/json.js';
	export default {
		data() {
			return {
				deviceManage: json.deviceManage,
				modalName: null,
				getData:[],
				dwtype:0
			};
		},

		onLoad: function(option) {
			this.dwtype=option.dwtype
			let url = "";
			switch (parseInt(option.dwtype)) {
				case 1:
					url = "火警"
					break;
				case 2:
					url = "水警"
					break;
				case 3:
					url = "烟感"
					break;
				case 4:
					url = "消防栓监测"
					break;
					case 5:
						url = "液位"
						break;
				case 6:
					url = "RTU测控终端"
					break;
				case 7:
					url = "电气火灾"
					break;
				case 16:
					url = "视频告警"
					break;
				case 17:
					url = "电梯报警"
					break;
				case 128:
					url = "井盖监测"
					break;
				case 129:
					url = "地磁"
					break;
				case 130:
					url = "门磁"
					break;
				case 131:
					url = "可燃气体"
					break;
				default:
					break;
			}
			uni.setNavigationBarTitle({
				title: "设备管理（" + url + "）",
			});
			
			this.getDeviceList({'company_code':uni.getStorageSync('selectedCode'),"dwtype":option.dwtype})

		},
		onNavigationBarButtonTap(e) {
			console.log(e)
			uni.navigateTo({
				url: './export/export?dwtype='+this.dwtype,

			});
		},
		methods: {

			// 页面跳转
			goDeviceDetail(item) {
				uni.navigateTo({
					url: '/pages/deviceDetail/deviceDetail?id='+item.id,
				});
			},
			
			// 设备类型数据请求
			async getDeviceList(params = {}) {
				const res = await this.$myRequest({
					url: 'DeviceManagement/getDeviceList',
					data:params,
					showLoading: true
				})
				this.getData=res.data.data;
				console.log(this.getData);
			},
			
		}

	}
</script>

<style lang="scss">
	.cu-item {
		height: 180rpx !important
	}
</style>
