<template>
	<view class="query-wrap">
		<view class="inner-item">
			<view class="inventory-item">
				<view class="shuo-item-name its">
					<view class="shuo-label-podnme">
						{{formData.prodName||"" }}
					</view>
					<view class="shuo-unit">
						<span>{{ formData.unt }} ({{ formData.pacCnt
						}}{{formData.prcUnt}}/{{ formData.unt }})</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">
						UDI码:
					</view>
					<view class="shuo-cont">
						{{formData.udi}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						生产批次:
					</view>
					<view class="shuo-cont">
						{{formData.lotNum}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						生产日期:
					</view>
					<view class="shuo-cont">
						{{formData.manuDate}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						有效期至:
					</view>
					<view class="shuo-cont">
						{{formData.prodExpy}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						注册证号:
					</view>
					<view class="shuo-cont">
						{{formData.regcertno}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						耗材类别:
					</view>
					<view class="shuo-label-blue">
						<span v-if="formData.mcsType == '0'"> 普通耗材 </span>
						<span v-if="formData.mcsType == '1'"> 高值耗材 </span>
						<span v-if="formData.mcsType == '2'"> 试剂 </span>
						<span v-if="formData.mcsType == '3'"> 总务耗材 </span>
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						生产来源:
					</view>
					<view class="shuo-label-blue">
						<span v-if="formData.prodSouc == '1'" type="success"> 国产 </span>
						<span v-if="formData.prodSouc == '2'" type="danger"> 进口 </span>
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						生产企业:
					</view>
					<view class="shuo-cont">
						{{formData.prodEntp}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						是否集采:
					</view>
					<view class="shuo-cont">
						<span v-if="formData.isFas == '1'" type="success"> 是 </span>
						<span v-if="formData.isFas == '0'" type="danger"> 否 </span>
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						集采批次:
					</view>
					<view class="shuo-cont">
						{{formData.fasBtch}}
					</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-cont">
					{{ listData.isBarc == "0" ? "否" : " 是" }}
					</view>
				</view>
			</view> -->
		</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
			}
		},
		computed: {
			...mapState(['refusaData', 'udiData'])
		},
		onShow() {
			let that = this;
			this.$forceUpdate();
			uni.getStorage({
				key: 'followdetview',
				success: function(res) {
					//soucStroomId
					that.formData = res.data;
				}
			});
		},
		mounted() {
			if (this.type != 'outbond') {
				this.getData();
			}
		},
		methods: {
			getData() {
				this.$http('delivery.getPickData', {
					prodCode: this.formData.prodCode,
					size: 1000,
					stooutId: this.formData.stooutId
				}, '加载中', true).then((res) => {
					if (res.success == true) {
						this.listData = res.data.records;
					}
				})
			},
			//确定删除
			clickItem(idx) {
				this.delIndex = idx;
				this.$refs.popup.open();
			},
			dialogClose() {
				this.$refs.popup.close();
			},
			//拣货查询
			input(e) {
				if (!e) return;
				this.$http('outbound.outbQueryData', {
					prodCode: this.formData.prodCode,
					soucStroomId: this.formData.soucStroomId,
					stooutId: this.formData.stooutId,
					sn: e
				}, '加载中', true).then((res) => {
					if (res.success == true) {
						res.data.records.length > 0 &&
							res.data.records.forEach((item) => {
								item["stooutId"] = this.formData.stooutId;
								item["sn"] = item.id;
							});
						let filterData = this.listData.filter((item) => {
							return item.id == res.data.records[0].id;
						});
						if (filterData.length <= 0) {
							this.listData = [...this.listData, ...res.data.records]
						} else {
							uni.showToast({
								title: '重复数据',
								icon: 'none',
								duration: 1000,
							});
						}
					}
				})

			},
			// 确定删除当前记录
			dialogConfirm() {
				let delData = [...this.listData];
				delData.splice(this.delIndex, 1);
				this.listData = delData;
				this.$refs.popup.close();
			},
			//拣货确认 
			subMitData() {
				this.$http('outbound.confrimPickIng', this.listData, '加载中', true).then((res) => {
					if (res.success == true) {
						uni.showToast({
							title: '拣货成功',
							icon: 'none',
							duration: 1000,
						});
						uni.redirectTo({
							url: '/pages/outbounddetail/index'
						});
					}
				})
			}

		},
		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;
		}
	}

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