<template>
	<view class="query-wrap">
		<view class="inner-item" v-for="(item,index) in listData" :key="index">
			<view class="item-stats">
				{{item.stas}}
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						盘点单号:
					</view>
					<view class="shuo-unit">
						{{item.intrNo}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						任务名称:
					</view>
					<view class="shuo-cont">
						{{item.taskName}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						任务类型:
					</view>
					<view class="shuo-cont">
						{{item.type}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						目标仓库:
					</view>
					<view class="shuo-cont">
						{{item.stroomName}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						盘点品种数:
					</view>
					<view class="shuo-cont">
						{{item.catCnt}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item">
					<view class="shuo-label">
						应盘总数:
					</view>
					<view class="shuo-cont">
						{{item.sumCnt}}
					</view>
				</view>
				<view class="shuo-item">
					<view class="shuo-label">
						实盘总数:
					</view>
					<view class="shuo-cont">
						{{item.intrCnt}}
					</view>
				</view>
			</view>
			<view class="inventory-item">
				<view class="shuo-item-name">
					<view class="shuo-label">
						盘点时间:
					</view>
					<view class="shuo-cont">
						{{forMatTime(item.startDate)}}
					</view>
				</view>
			</view>
		</view>
		<v-tabs v-model="index" :tabs="tabList" @change="changeTab" :scroll="false" style="margin-top:20rpx"></v-tabs>
		<z-paging ref="paging" @query="queryList" v-model="dataList" :use-page-scroll="true">
			<view class="inner-item" v-for="(item,index) in dataList" :key="index" @click="itemDetails(item)">
				<view class="item-stats">
					{{item.stas}}
				</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">
						<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-blue">
							<span v-if="item.mcsType == '0'"> 普通耗材 </span>
							<span v-if="item.mcsType == '1'"> 高值耗材 </span>
							<span v-if="item.mcsType == '2'"> 试剂 </span>
							<span v-if="item.mcsType == '3'"> 总务耗材 </span>
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							生产来源:
						</view>
						<view class="shuo-cont-blue">
							<span v-if="item.prodSouc == '1'" type="success"> 国产 </span>
							<span v-if="item.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">
							{{item.prodEntp}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							所在库房:
						</view>
						<view class="shuo-cont">
							{{stromName}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							所在货位:
						</view>
						<view class="shuo-cont">
							{{item.cgoLocName}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							应在库:
						</view>
						<view class="shuo-label-green">
							{{item.invCnt}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							实在库:
						</view>
						<view class="shuo-label-green">
							 {{item.intrCnt}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							盈:
						</view>
						<view class="shuo-label-green">
							{{item.profitCnt}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							亏:
						</view>
						<view class="shuo-label-green">
							 {{item.lsCnt}}
						</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	import moment from "moment";
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin.js';
	const paging = {
		current: 1,
		size: 10000
	};
	export default {
		mixins: [ZPMixin],
		data() {
			return {
				index: 0,
				tabList: ['盈', '亏', '对平'],
				listData: [],
				detailsData: [],
				type: 2,
				dataList: []
			}
		},
		computed: {
			...mapState([])
		},
		onShow() {
			let that = this;
			this.$forceUpdate();
			uni.getStorage({
				key: 'Inventorydetails',
				success: function(res) {
					that.listData = [
						res.data
					];
				}
			});
		},
		mounted() {

		},
		methods: {
			...mapActions(['getInvenResultData']),
			...mapMutations(['']),
			async queryList(pageNo, pageSize) {
				await this.getInvenResultData({
					pam: {
						current: pageNo,
						size: pageSize,
						intrNo: this.listData[0].intrNo,
						intrType: this.type
					},
					that: this
				});
			},
			//日期格式化
			forMatTime(time) {
				return moment(time).format("YYYY-MM-DD");
			},
			changeTab(e) {
				let intype = null;
				if (e == 0) {
					intype = 2
				}
				if (e == 1) {
					intype = 3
				}
				if (e == 2) {
					intype = 1
				}
				this.type = intype;
				this.$refs.paging.reload();
			}
		},
		watch: {

		}

	}
</script>

<style lang="scss" scoped>
	.query-wrap {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background-color: #F1F1F1;
		position: relative;

		.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>