<template>
	<!-- 已申请物料cell -->
	<view class="applied-cell" @click="handleClick">
		<view class="title-view">
			<text class="title-text">{{title}}</text>
			<view>
				<text>退件时间：</text>
				<text>{{info.createTime ? $u.timeFormat(info.createTime, 'yyyy.mm.dd hh:MM:ss') : ''}}</text>
			</view>
		</view>
		<view class="line-view"></view>
		<view class="list-content">
			<view class="list-item" v-for="(item, index) in info.items" :key="index">
				<SpareCell :item="item"/>
			</view>
		</view>
		<view class="line-view"></view>
		<view class="info-item">
			<view>
				<text>退件编号：</text>
				<text @longpress="handleLongpress">{{info.batchNumber}}</text>
			</view>
			<text class="copy-view" @click="$u.throttle(handleLongpress, 500)">复制</text>
		</view>
		<view class="line-view"></view>
		<view class="bottom-view">
			<view class="total-view">
				<text>合计：</text>
				<text class="amount-view">x{{info.items.length}}</text>
				<text>种</text>
			</view>
		</view>
	</view>
</template>

<script>
	import SpareCell from "@/components/parts/spareCell.vue"
	export default {
		components: {
			SpareCell
		},
		props: {
			info: {
				type: Object,
				default() {
					return {}
				}
			}
		},
		data() {
			return {
			}
		},
		computed: {
			title() {
				// 退件中：32 已打回，其他：退件中
				var text = '退件中'
				for (var item of this.info.items) {
					if (item.status == 32) {
						text = '已打回'
						break
					}
				}
				return this.info.finished ? '退件完成' : text
			},
			// total() { // 合计
			// 	var i = 0
			// 	for (var item of this.info.items) {
			// 		i += item.quantity
			// 	}
			// 	return i
			// },
		},
		methods: {
			handleLongpress() { // 长按复制单号
				uni.setClipboardData({
					data: this.info.number,
					success: function () {
						console.log('success');
					}
				})
			},
			handleClick(){}
		}
	}
</script>

<style lang="scss" scoped>
	.applied-cell {
		padding: 30rpx;
		background-color: #FFFFFF;
		border-radius: 12rpx;
		margin-bottom: 20rpx;
		.title-view{
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 26rpx;
			color: #333333;
			.title-text {
				font-size: 36rpx;
				font-weight: bold;
			}
		}
		.line-view {
			background-color: #F4F5F7;
			height: 2rpx;
			width: 100%;
			margin-top: 20rpx;
		}
		
		.list-content {
			margin-top: 40rpx;
			margin-bottom: 40rpx;
		
			.list-item {
				margin-bottom: 30rpx;
			}
		}
		.info-item {
			margin-top: 24rpx;
			margin-bottom: 24rpx;
			color: #333333;
			font-size: 26rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		
			.detail-left-view {}
		
			.copy-view {
				color: #2272FF;
				padding-left: 30rpx;
			}
		}
		.bottom-view {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 24rpx;
			margin-bottom: 4rpx;
			.total-view {
				font-size: 32rpx;
				font-weight: bold;
				color: #333333;
				.amount-view {
					color: #2272FF;
					padding-right: 10rpx;
				}
			}
			
		}
	}

</style>
