<template>
	<view class="lists page">
		<ContentLoadingMore class="contentMore" :list='list'>
			<view class="cardbox">
				<view class="cardContent" v-for="(item, index) in list" :key="item.PLNR">
					<!-- <scanningList :item='item'/> -->
					<view class="listItemTitle">
						<view>
							<view class="item">PL号：{{ list[index] }}</view>
							<!-- <view class="item">物料编号：{{ item.MATNR }}</view>
							<view class="item">物料描述：{{ item.MAKTX }}</view>
							<view class="item">数量：{{ item.MAKTX }}</view> -->
						</view>
						<u-button size="mini" type="primary" plain @click="deleGonds(index)">
							<u-icon name="trash" size="28"></u-icon>
							删除
						</u-button>
					</view>
				</view>
			</view>
		</ContentLoadingMore>
		<!-- <BottomBtn :btnArr="btnArr" @getBtnHandle="getBtnHandle"></BottomBtn> -->
	</view>
</template>

<script>
import StickyNavBar from '@/components/StickyNavBar/index.vue';
import ContentLoadingMore from '@/components/ContentLoadingMore/index.vue';
import BottomBtn from '@/components/BottomBtn/index.vue';
import scanningList from "./scanningList.vue"
import { parseTime} from "@/utils/ruoyi";
export default {
	components: {
		StickyNavBar,
		ContentLoadingMore,
		BottomBtn,
		scanningList,
	},
	props:{
		list: {
			type: Array,
			default: function () {
				return [];
			}
		},
	},
	data() {
		return {
			type: 'select',
			border: true,
			current: 0,
			status: 'loadmore',
			btnArr: [
				{
					style: '',
					type: 'warning',
					text: '返回',
					way: 'goBack'
				},
				{
					style: '',
					type: 'primary',
					text: '提交',
					way: 'goSubmit'
				}
			],
			nlpla: '',
			orderBoxNum: '',
			
		};
	},
	created() {
	},
	onLoad(option) {
		if(option && option.order){
			this.orderBoxNum = option.order
		}
	},
	computed:{
	},
	methods: {
		goSubmit() {
			const checkboxArr = this.list.filter(item => item.checkedBox)
			if (checkboxArr.length === 0) {
				this.$u.toast('暂无提交数据');
				return;
			}
			this.$u.api.sapApi
				.sapPickingDn(checkboxArr)
				.then((res) => {
					this.loading = false;
					if(!Array.isArray(res)){
						return
					}
					if (res.every((item) => item.TYPE === 'S')) {
						this.$u.toast('提交成功');
					}
					const foundObject = res.find(item => item.TYPE === 'E');
					if(foundObject && foundObject.MESSAGE){
						this.$u.toast(foundObject.MESSAGE);
					}
				});
		},
		deleGonds(idx) {
			this.$emit('deleGonds',idx)
		},
		// 加载更多
		onReachBottom() {
			console.log('加载更多inventoryCounting');
		},
		getBtnHandle(row) {
			console.log('getBtnHandle', row);
			this[row.way]();
		},
		goBack() {
			console.log('进来');
			uni.navigateBack({
				delta: 0
			});
		},
		changeTab(index) {
			this.current = index;
		},
	}
};
</script>

<style lang="scss">
.lists{
	min-height: calc(100vh - 700rpx);
}
.selectSheet {
	border-bottom: 1px solid #ccc;
}
/deep/ .u-sticky {
	top: 0 !important;
	background: #fff;
}
.tabTwo{
	/deep/ .u-sticky-wrap{
		height: 330rpx !important;
	}
}
.contentMore {
	padding: 20rpx;
}
.cardbox {
	// padding: 0rpx 20rpx;
}
.cardContent {
	border-radius: 8px;
	background: #fff;
	margin-bottom: 20rpx;

}
.listItemTitle {
	display: flex;
	justify-content: space-between;
	padding: 20rpx;
	border-bottom: 2px solid #f8f8f8;
	.u-btn {
		width: 150rpx;
		margin: 0px;
		margin-top: 10rpx;
	}
	.item {
		line-height: 50rpx;
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		word-break: break-all;
		font-weight: 600;
	}
}
</style>
