<template>
	<view>
		<view class="card" v-for="(item,index) in list" :class="item.background_=='grey'?'card-gery':'card'" :key="index" @tap="firstInspectionInfo(item.plan_id,item)">
			<view class="card-left">
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>物料名称:</view><text>{{item.product_name}}</text>
					</view>
					<view class="card-right">
						<image class="glass-cion" v-if="item.check==0" src="../../static/search.png"></image>
						<image class="sh-cion" v-if="item.check==1" src="../../static/dsh.png"></image>
						<image class="sh-cion" v-if="item.check==2" src="../../static/ysh.png"></image>
					</view>
				</view>
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>物料编号:</view><text>{{item.product_number}}</text>
					</view>
				</view>
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>生产日期:</view><text>{{item.production}}{{item.week}}</text>
					</view>
				</view>
				<view class="card-dow-list">
					<view class="card-up-list-list">
						<view>班次:</view>
						<text v-if="item.frequency==0" style="color:white;background-color: #333333;padding: 5upx;">夜班</text>
						<text v-if="item.frequency==1" >白班</text>
					</view>
					<view class="card-up-list-list">
						<view>产线:</view><text>{{item.line_title}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		firstCheckLists
	} from "../../api/user.js";
	export default {
		onLoad() {
			this.bindData();
			this.getTime()
		},
		data() {
			return {
				list: [],
				todays:'',
				todayTime:''
			};
		},
		methods: {
			getTime: function() {
			
				var date = new Date(),
					year = date.getFullYear(),
					month = date.getMonth() + 1,
					day = date.getDate(),
					hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
					minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
					second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var timer = year + '-' + month + '-' + day
				this.todays=timer
				this.todayTime= hour + '-' + minute+'-'+second
				console.log("当前时间", timer)
				return timer;
			
			},
			bindData() {
				firstCheckLists({type:5}).then(res => {
					this.list = res;
					this.list.map(item=>{
						if(item.production == this.todays&&this.todayTime>'07:45:00'){
							item.today=true
						}
						else{
							item.today=false
						}
					})
					console.log("leib",this.list)
				})
			},
			firstInspectionInfo(plan_id,item) {
				console.log("id",plan_id)
				uni.navigateTo({
					url: `../tcqList/tcqList?plan_id=${plan_id}&planInfo=${encodeURIComponent(JSON.stringify(item))}`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss">
	@import "./index.scss";
</style>
