<template>
	<u-navbar title="滞留" bgColor='#D3832A' leftIconColor='#ffffff' titleStyle='color:#ffffff'
		placeholder :autoBack="true" leftIconSize='35'></u-navbar>
	<view class="topbox">
		<view class="scanbox">
			<image src="/pagesHome/static/miniqc.png"></image>
			<input placeholder="扫描或输入包条码"/>
		</view>
		<!-- <view class="viewboxs">
			<view>数量：10</view>
			<view>滞留日期：<text class="siz">2023-08-01 至 2023-08-12</text></view>
		</view> -->
	</view>
	<scroll-view class="scvm" scroll-y="true">
		<view class="itembox" v-for="(item,index) in codelist">
			<view class="topon1">
				<view>{{index+1}}</view>
				<view>
					<!-- <view class="xzc">正常</view> -->
					<!-- <view>异常</view> -->
					<!-- <image src="/pagesHome/static/removeitem.png"></image> -->
				</view>
			</view>
			<view class="topon2">
				<image src="/pagesHome/static/checi.png"></image>
				<view>滞留车次：{{item.retentionCarNo}}</view>
			</view>
			<view class="topon2" @click.stop="goorderdetail(item)">
				<image src="/pagesHome/static/checi.png"></image>
				<view>订单号：{{item.orderCode}}</view>
			</view>
			<view class="topon2">
				<image src="/pagesHome/static/checi.png"></image>
				<view>包件码：{{item.packageCode}}</view>
			</view>
		</view>
	</scroll-view>
<!-- 	<view class="butys">
		<view class="qut">取消</view>
		<view class="conf">确认滞留</view>
	</view> -->
	<saomiao2></saomiao2>
</template>

<script lang="ts" setup>
	import {
		warehouseRetentionretentionPackageList,
		warehouseRetentionretentionScanPackage
	} from '@/api/user.js'
	import {
		onLoad,
		onShow,
		onHide,
		onUnload
	} from '@dcloudio/uni-app'
	import { reactive, toRefs } from "vue";
	const details=reactive({
		scancode:'',
		codelist:[],
		pageNum:1,
		pageSize:10,
	})
	onLoad((op) => {
		// details.upshelfScanType = op.type
		// details.scancode = '23072506516-3'
		// scandata()
		// setTimeout(()=>{
		// 	details.scancode='23072506670-2'
		// 	scandata()
		// },4500)
		init()
		uni.$on('scancodedate', function (code) {
			if (code) {
				// console.log(code);
				details.scancode = code
				scandata()
			}
		})
	})
	
	function goorderdetail(item){
		uni.navigateTo({
			url:'/pagesHome/pages/orderDetails/orderDetails?orderCode='+item.orderCode
		})
	}
	function init(){
		details.pageNum=1
		details.codelist=[]
		initpage()
	}
	function jiazai(){
		details.pageNum++
		initpage()
	}
	async function initpage(){
		let data={
			pageNum:details.pageNum,
			pageSize:details.pageSize,
		}
		let res=await warehouseRetentionretentionPackageList(data)
		if(res.code==200){
			details.codelist=details.codelist.concat(res.data.records)
		}else{
			
		}
	}
	async function scandata(){
		let data={
			orderPackageCode:details.scancode
		}
		let res=await warehouseRetentionretentionScanPackage(data)
		if(res.code==200){
			uni.showToast({
				title:'扫码成功',
				icon:'none'
			})
			init()
		}else{
			
		}
	}
	const {
		scancode,
		codelist,
		pageNum,
		pageSize,
	}=toRefs(details)
</script>

<style lang="scss">
	.butys{
		display: flex;
		align-items: center;
		margin-top: 20upx;
		justify-content: space-around;
		>.conf{
			width: 320upx;
			height: 100upx;
			border-radius: 20upx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32upx;
			font-weight: 400;
			color: #FFFFFF;
			background-color: #D3832A;
		}
		>.qut{
			width: 320upx;
			height: 100upx;
			border-radius: 20upx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32upx;
			font-weight: 400;
			color: #5A6875;
			background-color: #FFFFFF;
		}
	}
	.scvm{
		width: 100%;
		height: 74vh;
		margin-top: 20upx;
		.itembox{
			width: 686upx;
			border-radius: 20upx;
			padding: 0 20upx;
			box-sizing: border-box;
			background-color: #ffffff;
			margin: auto;
			margin-bottom: 20upx;
			>.topon1{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20upx 10upx;
				box-sizing: border-box;
				border-bottom: 4upx solid #EEEEEE;
				>view:nth-of-type(1){
					width: 50rpx;
					height: 50rpx;
					background: #178AF220;
					border-radius: 50%;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 28upx;
					font-weight: 500;
					color: #178AF2;
				}
				>view:nth-of-type(2){
					display: flex;
					align-items: center;
					>view{
						width: 136upx;
						height: 64upx;
						border-radius: 8upx;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 28rpx;
						font-weight: 400;
						color: #90A0AF;
						background-color: #F5F5F6;
						margin-right: 20upx;
					}
					.xzc{
						background-color: #178AF2 !important;
						color: #ffffff !important;
					}
					.xze{
						background-color: #F8544B !important;
						color: #ffffff !important;
					}
					>image{
						width: 64upx;
						height: 64upx;
					}
				}
			}
			>.topon2{
				display: flex;
				align-items: center;
				justify-content: flex-start;
				padding: 20upx 10upx;
				box-sizing: border-box;
				border-bottom: 4upx solid #EEEEEE;
				>image{
					width: 64upx;
					height: 64upx;
					margin-right: 20upx;
				}
				>view{
					font-size: 28upx;
					font-weight: 400;
					color: #020B18;
				}
			}
		}
	}
	.topbox{
		width: 100%;
		padding: 20upx 32upx;
		box-sizing: border-box;
		background-color: #ffffff;
		>.scanbox{
			display: flex;
			align-items: center;
			width: 686upx;
			height: 80upx;
			background: #F5F5F6;
			border-radius: 8upx;
			box-sizing: border-box;
			padding: 20upx 30upx;
			font-size: 28upx;
			color: #020B18;
			>image{
				width: 32upx;
				height: 32upx;
				margin-right: 12upx;
			}
			>input{
				font-size: 28upx;
			}
		}
		.viewboxs{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 20upx;
			>view{
				font-size: 30upx;
				font-weight: 400;
				color: #020B18;
			}
			.siz{
				font-size: 28upx;
			}
		}
	}
</style>
