<template>
	<view class="query-wrap">
		<qs-scanlistener @scan="scan"></qs-scanlistener>
		<view class="inner-item" v-for="(item,index) in listData" :key="index">
			<view class="item-stats">
				<span>{{item.stas}}</span>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						{{type=='3'?'订单号:':"申领单号:"}}
					</view>
					<view class="shuo-unit">
						{{type=='3'?item.ordNo:item.appyNo}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						申领品种数:
					</view>
					<view class="shuo-cont">
						{{item.catCnt}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						申领总数量:
					</view>
					<view class="shuo-cont">
						{{item.sumCnt}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						手术名称:
					</view>
					<view class="shuo-cont">
						{{item.oprnName}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						手术间:
					</view>
					<view class="shuo-cont">
						{{item.oprtRoom}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						主治医生:
					</view>
					<view class="shuo-cont">
						{{item.atddr}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						患者名称:
					</view>
					<view class="shuo-cont">
						{{item.patn}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						手术日期:
					</view>
					<view class="shuo-cont">
						{{item.oprtTime}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						患者年龄:
					</view>
					<view class="shuo-cont">
						{{item.age}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						住院号:
					</view>
					<view class="shuo-cont">
						{{item.iptNo}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						床位号:
					</view>
					<view class="shuo-cont">
						{{item.bedNo}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						供应商:
					</view>
					<view class="shuo-cont">
						{{item.splerName}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						申领人:
					</view>
					<view class="shuo-cont">
						{{item.crteUsrName}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						申领时间:
					</view>
					<view class="shuo-cont">
						{{item.crteTime}}
					</view>
				</view>
			</view>

		</view>
		<view class="inner-item" v-for="(item,idex) in detailsData" :key="idex" @click.stop="itemDetails(item,idex)"
			:style="[{background:(item.isUse=='0'?'#fff':'yellow')}]">
			<view class="text-title" v-if="idex=='0'">
				<view class="title-circ">

				</view>
				<span>耗材清单</span>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label-podnme">
						{{item.prodName}}
					</view>
					<view class="shuo-unit">
						<span>{{ item.unt }} ({{ item.pacCnt
			  			}}{{item.prcUnt}}/{{ item.unt }})</span>
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						使用数量:
					</view>
					<view class="shuo-unit">
						{{item.isUse}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						规格:
					</view>
					<view class="shuo-cont">
						{{item.spec}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						型号:
					</view>
					<view class="shuo-cont">
						{{item.mol}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						材质:
					</view>
					<view class="shuo-cont">
						{{item.matl}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						UDI码:
					</view>
					<view class="shuo-cont">
						{{item.udi}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						生产批次:
					</view>
					<view class="shuo-unit">
						{{item.lotNum}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						注册证号:
					</view>
					<view class="shuo-cont">
						{{item.regcertno}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						生产日期:
					</view>
					<view class="shuo-cont">
						{{item.manuDate?forMatTime(item.manuDate):""}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						有效日期:
					</view>
					<view class="shuo-cont">
						{{item.prodExpy?forMatTime(item.prodExpy):""}}
					</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="listData.length>0&&listData[0].stas=='待清台'">
			<button type="default" plain="true" style="width:240rpx;line-height: 70rpx;background: #01A992;color:#fff"
				@click.stop="orderAcept('')">清台</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 {
				listData: [],
				detailsData: [],
				type: ""
			}
		},
		computed: {
			...mapState(['acceptDetaData', 'acceptDetail'])
		},
		onShow() {
			let that = this;
			this.$forceUpdate();
			uni.getStorage({
				key: 'followplatdetail',
				success: function(res) {
					that.listData = [
						res.data.form
					];
					that.getData(
						res.data.form.oprnId,
						res.data.type
					);
					that.type = res.data.type;
				}
			});
		},
		mounted() {

		},
		methods: {
			...mapActions([]),
			...mapMutations(['setMentItemData', 'setRefusaData']),
			getData(
				id,
				type
			) {
				console.log(id,type,'rrrr');
				this.$http('followplat.detailsData', {
					oprnId: id,
					type: type
				}, '加载中', true).then((res) => {
					if (res.success == true) {
						this.detailsData = res.data;
					}
				})
			},
			//扫码清台
			scan(code) {
				let pam = {
					oprnId: this.listData[0].oprnId,
					code: code.trim(),
					isUse: "1"
				};
				this.$http('followplat.oprnMcsUse', pam, '加载中', true).then((res) => {
					if (res.success == true) {
						this.getData(
							this.listData[0].oprnId,
							this.type
						);
					}
				})
			},
			//确定清台
			dialogConfirm() {
				let url = this.type == '2' ? 'surgical.subMitData' : 'followplat.subMitData';
				this.$http(url, {
					oprnId: this.listData[0].oprnId,
				}, '加载中', true).then((res) => {
					if (res.success == true) {
						this.$refs.popup.close();
						if (this.type == '3') {
							uni.redirectTo({
								url: '/pages/followplat/index',
								success: function(res) {
									console.log(res, "res")
								}
							});
						}
						if (this.type == '2') {
							uni.redirectTo({
								url: '/pages/surgical/index',
								success: function(res) {
									console.log(res, "res")
								}
							});
						}

					}
				})
			},
			//验收按钮触发
			orderAcept() {
				this.$refs.popup.open();
			},
			dialogClose() {
				this.$refs.popup.close();
			},
			//日期格式化
			forMatTime(time) {
				return moment(time).format("YYYY-MM-DD");
			},
			//跳转拣货明细详情	 
			itemDetails(item, index) {
				uni.setStorage({
					key: 'followdetview',
					data: {
						...item
					}
				});
				uni.navigateTo({
					url: '/pages/followdetview/index',
					success: function(res) {
						console.log(res, "res")
					}
				});
			},
		},
		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;
		}

		.time-view {
			height: 350rpx;
			background-color: #fff;
			padding: 50rpx 50rpx 0 50rpx;
			box-sizing: border-box;

			.btn-view {
				width: 100%;
				height: 100rpx;
				margin-top: 100rpx;
				display: flex;
				justify-content: space-around;
			}
		}
	}

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