<!-- 批量盘点提交结果 -->
<template>
	<view class="container-wrap">
		<uni-nav-bar title="提交结果" :status-bar="true" background-color="#3F92F9" color="#FFF">
			<view slot="left">
				<u-icon name="account-fill" color="#FFF" size="35"></u-icon>
				<span style="padding: 0 5rpx;color: #FFFFFF;">{{ userInfo.name }}</span>
			</view>
			<view slot="right" @tap="$utils.back()">
				<span style="color: #FFFFFF;">返回</span>
			</view>
		</uni-nav-bar>
		<view class="container">
			<!-- 扫描到RFID标签时，打开质检结果 -->
			<view class="title">异常物料</view>
			<view class="info">
				<view class="row flex-start">
					<view class="col">
						<view class="label">
							物料类型：
						</view>
						<view class="value">
							{{ data.materialType }}
						</view>
					</view>
					<view class="col">
						<view class="label">
							标签编码：
						</view>
						<view class="value">
							{{ data.materialCode }}
						</view>
					</view>
				</view>
				<view class="row flex-start">
					<view class="col">
						<view class="label">
							物料名称：
						</view>
						<view class="value">
							{{ data.materialName }}
						</view>
					</view>
				</view>
				<view class="row flex-start">
					<view class="col">
						<view class="label">
							所在仓库：
						</view>
						<view class="value">
							{{ data.saveHouse }}
						</view>
					</view>
					<view class="col">
						<view class="label">
							放置区域：
						</view>
						<view class="value">
							{{ data.stockArea }}
						</view>
					</view>
				</view>
				<view class="row flex-start">
					<view class="col">
						<view class="label">
							库存件数：
						</view>
						<view class="value">
							{{ data.tagNum }}
						</view>
					</view>
					<view class="col">
						<view class="label">
							库存数量：
						</view>
						<view class="value">
							{{ data.quantity }}
						</view>
					</view>
				</view>
			</view>
			<view class="title border">异常明细</view>
			<view class="info bottom-list">
				<view class="item border" v-for="(item, index) in list" :key="index">
					<view class="row">
						<view class="col">
							<view class="label">标签值：</view>
							<view class="value">{{ item.rfidCode }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">数量：</view>
							<view class="value">{{ item.quantity }}</view>
						</view>
						<view class="col">
							<view class="label">异常情况：</view>
							<view class="value">{{ item.statusColor === 'red' ? '不存在库' : '未扫描到' }}</view>
						</view>
					</view>
					<view class="row">
						<view class="col">
							<view class="label">处置意见：</view>
						</view>
					</view>
					<view class="row">
						<u-input 
							v-model="item.dealRemark" 
							type="textarea" 
							:border="true" 
							border-color="#333"
						/>
					</view>
				</view>
			</view>
		</view>
		<view class="btn">
			<my-fixed-button :customClick="true" @click="over" text="提交申请"></my-fixed-button>
		</view>
	</view>
</template>

<script>
	const uhf = uni.requireNativePlugin('js-uhf');
	export default {
		data() {
			return {
				data: {},
				list: [],
				rfidItems: []
			};
		},
		methods: {
			over() {
				this.list.forEach(item => {
					item.isInStock = (item.statusColor !== 'red')
				})
				console.log(this.list)
				this.$http.CompleteEveryDayBatchCheck({
					detailId: this.data.id,
					materialCode: this.data.materialCode,
					stockHouseId: this.data.stockHouseId,
					rfidItems: this.rfidItems,
					scanfErrorTagList: this.list
				}).then(res => {
					console.log(res)
					if(res.code === 0) {
						this.$msg.showToast(res.msg || '操作成功！')
						setTimeout(() => {
							this.$utils.back(2)
						}, 1000)
					}
				})
			}
		},
		onLoad(option) {
			this.data = JSON.parse(option.data)
			this.list = JSON.parse(option.list)
			this.rfidItems = JSON.parse(option.rfidItems)
			console.log(this.data)
		},
		onUnload() {
		}
	}
</script>

<style lang="scss" scoped>
.container-wrap {
	overflow: hidden;
	.container {
		padding: 0 10rpx;
		height: calc(100vh - var(--status-bar-height) - 44px);
		overflow: hidden;
		display: flex;
		flex-direction: column;
		padding-bottom: 80rpx;
		background-color: #FFFFFF;
		.title {
			margin: 20rpx 60rpx;
			font-size: 36rpx;
			font-weight: bold;
			text-align: center;
		}
		.reading {
			padding: 40rpx 0;
		}
		.info {
			padding: 10rpx 60rpx;
			border-radius: 10rpx ;
			.row {
				justify-content: space-between;
				align-items: flex-start;
				.col {
					display: flex;
					flex: 1;
					overflow: hidden;
					justify-content: flex-start;
				}
				.label {
					color: inherit;
					font-size: 28rpx;
					width: 140rpx;
				}
				.value {
					color: inherit;
					font-size: 28rpx;
					flex: 1;
					overflow: hidden;
					word-wrap: break-word;
				}
			}
			.item {
				padding: 20rpx 0;
			}
			.border {
				border-top: 1px solid #333;
			}
		}
		.bottom-list {
			flex: 1;
			overflow: auto;
		}
		.btn {
			height: 180rpx;
			.row {
				padding: 0;
				padding-bottom: 10rpx;
				width: 100%;
				&:last-child {
					padding-bottom: 0;
				}
			}
		}
	}
}
</style>
