<template>
	<view class="taskList">
		<!-- -->
		<u-navbar
			title="任务列表"
			:safeAreaInsetTop="false"
		>
			<view class="u-nav-slot" slot="right" @click="show = true">
				...
			</view>
		</u-navbar>
		<u-popup :show="show" mode="center" @close="close">
			<view>
				<u-button type="primary" size="small" text="切换账号" @click="changeUser"></u-button>
			</view>
		</u-popup>
		<view v-if="taskList.length!=0" style="margin-top:44px;">
			<view class="taskItem" v-for="(item,index) in taskList" :key="index">
				<view class="title">机器编号：{{item.name}}</view>
				<view class="item" v-for="i in item.list" :key="i.id">
					<view class="rowItem">
						<view class="num">
							炉号：{{i.heat_number?i.heat_number:'-'}}
						</view>
						<view :class="i.status == 1?'status right':'status right finish'">
							状态：<text>{{i.status == 1 ? '未完成' : '已完成'}}</text>
						</view>
					</view>
					<view class="code rowItem">
						编号：{{i.art_number}}
					</view>
					<view class="code rowItem">
						<view>
							数量：{{i.total}}
						</view>
						<view class="right">
							面次：{{i.face}}
						</view>
					</view>
					<view class="rowItem">
						<view class="planTime">
							计划完成时间：{{i.real_time ? i.real_time : '-'}}
						</view>
						<view class="lookdetails right" @click="goProgress(i)">
							检测
						</view>
					</view>
					<view class="planTime rowItem">
						备注：{{i.remake}}
					</view>
				</view>
			</view>
		</view>
		<view v-else class="empty-list">
			<view class="empty-list-content">
				<image src="/static/list-empty.png"></image>
				<p class="empty-list-text">暂无数据</p>
			</view>
		</view>
	</view>
</template>


<script>
	import {getTaskList,logout} from "@/api/user.js"
	export default {
		data() {
			return {
				taskList:[],
				show:false
			};
		},
		methods:{
			close() {
			  this.show = false
			},
			getData(){
				getTaskList().then(res=>{
					
					this.taskList = res.data
				})
			},
			changeUser(){
				logout().then(res=>{
					console.log(res)
					uni.redirectTo({
						url: '/pages/login/login'
					})
					uni.removeStorage({
					    key: 'userToken'
					})
					this.$store.commit('logout')
				})
			},
			goProgress(item){
				// uni.navigateTo({
				// 	url:'/pages/processList/processList?id=' + item.id+'&code=' + item.art_number+'&heat_num='+item.heat_number
				// });
			}
		},
		onLoad() {
			console.log(uni.getStorageSync('userToken'))
			if(uni.getStorageSync('userToken')){
				console.log("已登录");
				this.getData()
				
			}else{
				uni.redirectTo({
					url:'/pages/login/login'
				})
			}
			
		}
	}
</script>

<style lang="scss">
	/deep/.u-popup__content{
		border-radius:20upx;
		padding:50upx 70upx;
	}
.taskList{
	min-height: calc(100vh - 100upx);
	background-color: #F7F8FA;
	.taskItem{
		background: #FFFFFF;
		box-shadow: 0upx 4upx 13upx 0upx rgba(17,21,38,0.06);
		padding:30upx 25upx;
		margin-bottom:20upx;
		.title{
			font-size: 36upx;
			font-family: Alibaba PuHuiTi;
			font-weight: 400;
			color: #333333;
		}
		.item{
			background: #F6F6F6;
			border-radius: 4upx;
			padding:25upx 20upx;
			margin-top:30upx;
			.rowItem{
				margin-bottom:25upx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			.code{
				font-size: 28upx;
				font-family: Alibaba PuHuiTi;
				font-weight: 400;
				color: #333333;
			}
			.right{
				width:171upx;
			}
			.num{
				font-size: 28upx;
				font-family: Alibaba PuHuiTi;
				font-weight: 400;
				color: #0DC0F4;
			}
			.status{
				font-size: 28upx;
				font-family: Alibaba PuHuiTi;
				font-weight: 400;
				color: #333333;
				text{
					color:#FFAD0F;
				}
			}
			.finish{
				color:#0DC0F4 !important;
			}
			.planTime{
				
				font-size: 24upx;
				font-family: Alibaba PuHuiTi;
				font-weight: 400;
				color: #999999;
			}
			.lookdetails{
				font-size: 24upx;
				font-family: Alibaba PuHuiTi;
				font-weight: 400;
				color: #0076F6;
			}
		}
	}
	.empty-list{
		padding-top:20%;
		text-align: center;
	}
}
/deep/.u-navbar__content__left{
	display: none;
}
</style>
