<template>
	<!-- 设备概览 -->
	<view class="overview">
		<view class="main" v-for="(item, index) in deviceList" :key="index" >
			<u--image :src="item.showPhoto" radius="5" :lazy-load="true" width="80" height="80"></u--image>
			<view class="content" @click="toDetails(item)">
				<view class="c-name">
					<u-text :text="item.name"></u-text> 
				</view>
				<view class="c-addtime">
					<u-text :text="item.specifications"></u-text>  
				</view>
				<view class="c-status">
					<u-tag text="正常" plain size="mini" v-if="item.status==0"></u-tag>
					<u-tag text="故障" plain size="mini" type="warning" v-if="item.status==1"></u-tag>
				</view>
			</view>
			<view>
				<u-tag text="未盘" plain size="mini" type="error" v-if="item.assetCheckStatus== 0"></u-tag>
				<u-tag text="驳回" plain size="mini" type="warning" v-if="item.assetBack== 1"></u-tag>
			</view>
			<u-icon name="arrow-right" @click="toDetails(item)"></u-icon>
		</view>
		
		<view class="btn" v-if="status == 1">
			<u-button type="primary" class="submit" @click="ok" text="通 过"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 1.2搜索内容
				search: '',
				userId: null,
				detailsId: null,
				status: null,
				// 3.设备列表
				deviceList: [
				],
				
				// 配置项
				actionStyle: {
					background: 'hsl(200, 88%, 55%)',
					color: '#fafaff',
					'border-radius': '1vw',
					'line-height': '26px'
				}
			}
		},
		onLoad: function(options) {
			let data = JSON.parse(options.managecheck);
			this.detailsId = data.id;
			this.userId = data.userId;
			this.status = data.status;
			console.log("managecheck id = "+ data.id)
			this.getList()
		},
		
		methods: {
			async getList() {
				const { data:res } = await this.$http('/queryAssetCheckList',{
					detailsId: this.detailsId,
					userId: this.userId
				})
				if(res.code) return
				this.deviceList = res.data
				for (var i = 0; i < this.deviceList.length; i++) {
					this.deviceList[i].showPhoto = this.API_URL + this.deviceList[i].picUrl.split(",")[0]
				}
			},
			async ok(){
				const { data:res } = await this.$http('/pdTaskDetailCheckOk/'+this.detailsId,{})
				if(res.code) return
				uni.navigateBack({ delta: 1 });
			},
			// 跳转详情页
			toDetails(item) {
				wx.navigateTo({
						url:'manage_zc_detail?zc='+JSON.stringify(item),    
				    })
			}
		}
	}
</script>

<style lang="scss">
	.overview {
		background: #f6f6f6;
		padding: 2.667vw 0;
		height: 100vh;
		
		.btn{
			padding: 2.667vw;
			.u-button{
				margin-bottom: 1vh;
			}
			.u-form{
				margin-bottom: 1vh;
			}
		}
		// 展示信息
		.main {
			background: #ffffff;
			margin-bottom: 2.667vw;
			display: flex;
			justify-content: space-around;
			padding: 2vh 0;
			
			.u-image{
				float: left;
			}
			.content{
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-around;
				display: flex;
				width: 55vw;
				.c-status{
					display: flex;
				}
			}
		}
	}
</style>
