<template>
	<view class="query-wrap">
		<view class="inner-item">
			<view class="inventory-item">
				<view class="shuo-item-name its">
					<view class="shuo-label">
						{{formData.prodName||"" }}
					</view>
					<view class="shuo-unit">
						<span>{{ formData.purcUnt }} ({{ formData.convrat
						}}{{formData.prcUnt}}/{{ formData.purcUnt }})</span>
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						规格:
					</view>
					<view class="shuo-cont">
						{{formData.spec}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						型号:
					</view>
					<view class="shuo-cont">
						{{formData.mol}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						出库数量:
					</view>
					<view class="shuo-unit">
						{{formData.children.length}}
					</view>
				</view>
			</view>
		</view>
		<view class="inner-item" v-for="(item,idex) in formData.children" :key="idex">
			<view class="text-title">
				{{idex+1}}
			</view>
			<liu-swipe-action :index="idex" @clickItem="clickItem">
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							sn编码:
						</view>
						<view class="shuo-cont">
							{{item.id}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							RFIF码:
						</view>
						<view class="shuo-cont">
							{{item.rfid}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							批次:
						</view>
						<view class="shuo-cont">
							{{item.lotNum}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							包装单位:
						</view>
						<view class="shuo-cont">
							<span>{{ item.pacunt }}({{item.pacCnt }}{{ item.prcUnt }}/{{ item.pacunt }})</span>
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							有效期至:
						</view>
						<view class="shuo-cont">
							{{item.prodExpy}}
						</view>
					</view>
				</view>
			</liu-swipe-action>
		</view>
		<uni-popup ref="popup">
			<uni-popup-dialog type="warn" :before-close="true" cancelText="取消" confirmText="确定" content="你确定删除当前记录吗？"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
		<view class="botm-btn" v-if="type=='outbond'">
			<button type="default" plain="true" style="width:240rpx;line-height: 70rpx;background: #01A992;color:#fff"
				@click.stop="subMitData()">确定</button>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	import moment from "moment";
	const paging = {
		current: 1,
		size: 10000
	};
	export default {
		data() {
			return {
				value: "",
				listData: [],
				formData: {},
				type: "",
				delIndex: 0,
				patIndex: 0
			}
		},
		computed: {
			...mapState(['consumeData'])
		},
		onShow() {
			let that = this;
			this.$forceUpdate();
			uni.getStorage({
				key: 'sumeDetails',
				success: function(res) {
					that.formData = res.data.snData;
					that.patIndex = res.data.itx;
				}
			});
		},
		mounted() {

		},
		methods: {
			...mapMutations(['setConmData']),
			//确定删除
			clickItem(e) {
				this.delIndex = e.index;
				this.$refs.popup.open();
			},
			dialogClose() {
				this.$refs.popup.close();
			},

			// 确定删除当前记录
			dialogConfirm() {
				let delData = {
					...this.formData
				};
				let patData = [...this.consumeData];
				delData.children.splice(this.delIndex, 1);
				this.formData = delData;
				patData[this.patIndex] = delData;
				if (delData.children.length == 0) {
					patData.splice(this.patIndex, 1);
				}
				this.setConmData(patData);
				this.$refs.popup.close();
				this.$forceUpdate();
				uni.setStorage({
					key: 'sumeDetails',
					data: {
						snData: delData,
						itx: this.patIndex
					}
				});
			},
		},
		watch: {

		}

	}
</script>

<style lang="scss" scoped>
	.query-wrap {
		width: 100%;
		height: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background-color: #F1F1F1;
		overflow-y: scroll;
		overflow-x: hidden;
		position: relative;
		padding-bottom: 200rpx;

		.botm-btn {
			width: 100%;
			height: 120rpx;
			background-color: #fff;
			position: fixed;
			left: 0;
			bottom: 0;
			padding-top: 40rpx;
		}


		.inner-item {
			width: 100%;
			height: auto;
			border-bottom: 2rpx solid #BDBDBD;
			padding: 20rpx 20rpx 20rpx 70rpx;
			box-sizing: border-box;
			position: relative;
			background-color: #fff;
			border-radius: 20rpx;
			margin-top: 10rpx;

			.text-title {
				width: 40rpx;
				height: 100%;
				color: #01A992;
				font-size: 32rpx;
				text-align: left;
				font-family: PingFangSC-semiBold;
				position: absolute;
				left: 0;
				top: 0;
				z-index: 100;
				display: flex;
				align-items: center;
				justify-content: center;
				border-right: 1px solid #000;
			}

			.item-stats {
				position: absolute;
				right: 20rpx;
				top: 30rpx;
				width: 96rpx;
				height: 46rpx;
				line-height: 46rpx;
				color: rgba(1, 169, 146, 1);
				font-size: 32rpx;
				text-align: left;
				font-family: PingFangSC-bold;
			}


			.inventory-item {
				width: 100%;
				height: 40rpx;
				color: rgba(16, 16, 16, 1);
				font-size: 28rpx;
				text-align: left;
				font-family: PingFangSC-semiBold;
				margin-top: 15rpx;
				display: flex;
				align-items: center;

				.shuo-label {
					color: rgba(16, 16, 16, 1);
					font-size: 28rpx;
					text-align: left;
					font-family: PingFangSC-regular;
					font-weight: bold;
				}


				.shuo-unit {
					color: rgba(0, 193, 0, 1.0);
					font-weight: bold;
					height: 50rpx;
					line-height: 50rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis
				}

				.shuo-cont-blue {
					color: #00BBFF;
					font-size: 25rpx;
					text-align: left;
					font-family: PingFangSC-regular;
					font-weight: bold;
					margin-left: 10rpx;
				}

				.shuo-cont,
				.suces,
				.shuo-error {
					color: rgba(16, 16, 16, 1);
					font-size: 25rpx;
					text-align: left;
					height: 40rpx;
					line-height: 40rpx;
					font-family: PingFangSC-regular;
					margin-left: 20rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis
				}

				.suces {
					color: rgba(0, 193, 0, 1.0);
					font-weight: bold;
				}

				.shuo-error {
					color: red;
					font-weight: bold;
				}

				.shuo-item-name {
					width: 100%;
					height: 100%;
					line-height: 20rpx;
					display: flex;
					align-items: center;

					.shuo-label {
						color: rgba(16, 16, 16, 1);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						text-align: justify;
						text-align-last: justify;
						margin-right: 20rpx;
						height: 50rpx;
						line-height: 50rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis
					}

					.shuo-cont {
						color: rgba(16, 16, 16, 1);
						font-size: 25rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						margin-left: 20rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis
					}
				}

				.shuo-item-tcl {
					width: 100%;
					height: 100%;
					line-height: 20rpx;
					display: flex;
					align-items: center;

					.shuo-label {
						width: 150rpx;
						color: rgba(16, 16, 16, 1);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						text-align: justify;
						text-align-last: justify;
						margin-right: 20rpx;
					}

					.shuo-cont {
						color: rgba(16, 16, 16, 1);
						font-size: 25rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						margin-left: 20rpx;
					}
				}

				.shuo-item {
					width: 50%;
					height: 100%;
					line-height: 20rpx;
					display: flex;
					align-items: center;

					.shuo-label {
						width: 180rpx;
						color: rgba(16, 16, 16, 1);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						text-align-last: justify;
					}

					.shuo-cont {
						color: rgba(16, 16, 16, 1);
						font-size: 25rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						margin-left: 10rpx;
					}

					.shuo-await {
						color: rgba(255, 191, 107, 1);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						margin-left: 20rpx;
					}

					.shuo-ready {
						color: rgba(162, 239, 77, 1);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-regular;
						margin-left: 20rpx;
					}
				}

				.shuo-one-cont {
					width: 60%;
				}

				.shuo-min {
					width: 33%;
				}

				.max-item {
					width: 68%;
					margin-left: 10rpx;

					.shuo-cont {
						font-size: 20rpx;
					}

				}
			}
		}
	}

	uni-page-body {
		width: 100%;
		height: 100%;
	}
</style>