<template>
	<!-- 设备概览 -->
	<view class="overview">
		<view class="title">
			<u-tag plain size="large" :text="taskName"></u-tag>
		</view>
		<view class="main" v-for="(item, index) in deviceList" :key="index" >
			<view class="u-img">
				<img src="../../static/list.png" ></img>
			</view>
			<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.value"></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>
					<u-tag text="已审核" plain size="mini" type="warning" v-if="item.status==2"></u-tag>
				</view>
			</view>
			<u-icon name="arrow-right" @click="toDetails(item)"></u-icon>
		</view>
		<!-- <view class="btn" v-if="userinfo.roleId == 1 &&showBtn">
			<u--form>
					<u--textarea v-model="taskRemark" placeholder="请输入备注内容" ></u--textarea>
			</u--form>
			<u-button type="primary" class="submit" @click="no" text="驳 回"></u-button>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 1.2搜索内容
				search: '',
				taskName: '',
				taskRemark: '',
				detailsId: null,
				taskId: null,
				userId: null,
				picUrl: '',
				// 3.设备列表
				deviceList: [
				],
				
				// 配置项
				actionStyle: {
					background: 'hsl(200, 88%, 55%)',
					color: '#fafaff',
					'border-radius': '1vw',
					'line-height': '26px'
				},
				showBtn : false,
				userinfo: null
			}
		},
		
		onLoad: function(options) {
			let data = JSON.parse(options.managed);
			this.taskName = data.taskName;
			this.detailsId = data.id;
			this.taskId = data.taskId;
			this.userId = data.userId;
			this.showBtn = (data.status == 2 && data.taskStatus<3)
			this.userinfo = uni.getStorageSync('userinfo');
		},
		
		onShow: function() {
			this.getList()
		},
		
		methods: {
			async getList() {
				const { data:res } = await this.$http('/queryDetailsCheckList',{
					taskId: this.taskId,
					userId: this.userId
				})
				if(res.code) return
				this.deviceList = res.data
			},
			// async no(){
			// 	if(this.taskRemark == '')
			// 	return uni.showToast({
			// 		title: '请输入备注',
			// 		icon: 'success'
			// 	});
				
			// 	const { data:res } = await this.$http('/pdTaskCheckNo',{
			// 		id: this.detailsId,
			// 		value: this.taskRemark
			// 	})
			// 	if(res.code) return
			// 	uni.navigateBack({ delta: 1 });
			// },
			// 跳转详情页
			toDetails(item) {
				wx.navigateTo({
						url:'manage_check_detail?managecheck='+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;
				}
			}
			
			.u-img{
				height: 80px;
				width: 80px;
				position: relative;
				img{
					height: 60px;
					width: 60px;
					position: absolute;
					top: 0;
					bottom: 0;
					left: 0;
					right: 0;
					margin: auto;
				}
			}
		}
		.title{
			margin: 1vh 2.5vw;
			.u-tag{
				
			}
		}
	}
</style>
