<template>
	<view class="query-wrap">
		<view class="title-cont">
			<view class="search-view">
				<uni-easyinput prefixIcon="search" :value="value" placeholder="请输入任务名称" @iconClick="iconClick"
					@input="input">
				</uni-easyinput>
			</view>
			<!-- <v-tabs v-model="index" :tabs="tabList" @change="changeTab" :scroll="false"></v-tabs> -->
		</view>
		<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">
							盘点单号:
						</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">
						<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.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>
		</z-paging>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	import {
		debounce
	} from 'lodash';
	import moment from "moment";
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin.js';
	export default {
		mixins: [ZPMixin],
		data() {
			return {
				index: 0,
				value: "",
				dataList: [],
				inputVal: "",
				codeVal: "",
				confirmVal: "",
				changeVal: "",
				classes: [],
				listData: [],
				tabList: ['待盘点', '已盘点'],
				valueList: 0,
				beforeClose: true,
				datetimesingle: [],
			}
		},
		computed: {
			// ...mapState(['groundData'])
		},
		onShow() {
			if (this.$refs.paging) {
				this.$refs.paging.reload();
			}
			uni.$once('update', function(data) {
				// uni.redirectTo({
				// 	url: '/pages/grounding/grounding' //写你的路径
				// });
			})
		},
		mounted() {

		},
		methods: {
			...mapActions(['getInventoryData']),
			...mapMutations(['setAcceptDetaData']),
			async queryList(pageNo, pageSize) {
				await this.getInventoryData({
					pam: {
						current: pageNo,
						size: pageSize,
						taskName: this.value
					},
					that: this
				});
			},
			//日期格式化
			forMatTime(time) {
				return moment(time).format("YYYY-MM-DD");
			},
			//跳转盘点详情	 
			itemDetails(item) {
				uni.setStorage({
					key: 'Inventorydetails',
					data: item
				});
				if (item.stas == '待盘点' || item.stas == '盘点中') {
					uni.navigateTo({
						url: '/pages/Inventorydetails/index',
						success: function(res) {
							console.log(res, "res")
						}
					});
				}
				if (item.stas == '盘点结束') {
					uni.navigateTo({
						url: '/pages/inventyresult/index',
						success: function(res) {
							console.log(res, "res")
						}
					});
				}
			},
			input: debounce(function(e) {
				this.value = e;
				this.getInventoryData({
					pam: {
						taskName: this.value
					},
					that: this
				});
			}, 500),
			changeTab(index) {
				this.index = index;
				this.$refs.paging.reload();
			},
		},
		watch: {

		}

	}
</script>

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

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

		.title-cont {
			padding-top: 10rpx;
			width: 100%;
			background-color: #fff;

			.search-view {
				width: 100%;
				height: 100rpx;
				display: flex;
				align-items: center;
				padding: 0rpx 20rpx 0rpx 20rpx;
				box-sizing: border-box;

				.filter-text {
					width: 72rpx;
					height: 50rpx;
					line-height: 50rpx;
					color: rgba(1, 169, 146, 1);
					font-size: 36rpx;
					font-family: PingFangSC-bold;
					padding-left: 20rpx;
				}
			}
		}
	}

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