<template>
	<view class="query-wrap">
		<uni-easyinput prefixIcon="search" :value="value" placeholder="请输入耗材信息" @iconClick="iconClick" @input="input">
		</uni-easyinput>
		<z-paging ref="paging" @query="queryList" v-model="dataList" :use-page-scroll="true">
			<view class="inner-item" v-for="(item,indx) in dataList" :key="indx" @click="itemDetails(item)">
				<view class="item-stats">
					{{item.stas}}
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label-podnme">
							采购员
						</view>
						<view class="shuo-unit">
						    {{item.crteUsrName}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							计划单号:
						</view>
						<view class="shuo-cont">
							{{item.planNo}}
						</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.sumAmt?item.sumAmt:""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							采购时间:
						</view>
						<view class="shuo-cont">
							{{item.crteTime?item.crteTime:""}}
						</view>
					</view>
				</view>
				<uv-button text="确认" plain size="normal" type="primary" style="margin-top:20rpx;"
					@click.native.stop="itemDetails(item)" v-if="item.stas=='待确认'"></uv-button>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex';
	import {
		debounce
	} from 'lodash';
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin.js';
	export default {
		mixins: [ZPMixin],

		data() {
			return {
				index: 0,
				value1: "",
				value: "",
				dataList: [],
				inputVal: "",
				codeVal: "",
				confirmVal: "",
				changeVal: "",
				tabList: ['待确认', '已确认', '已退回'],
				valueList: 0,
				beforeClose: true,
				itemData: {}
			}
		},
		computed: {
			   
		},
		onShow() {
			uni.$once('update', function(data) {
				// uni.redirectTo({
				// 	url: '/pages/grounding/grounding' //写你的路径
				// });
			})
		},
		mounted() {

		},
		methods: {
			...mapActions(['getPlanData']),
			async queryList(pageNo, pageSize) {
				let pamStas = this.tabList[this.index] == "全部" ? "" : this.tabList[this.index];
				await this.getPlanData({
					pam: {
						current: pageNo,
						size: pageSize,
						stas: pamStas,
						planNo: this.value.trim()
					},
					that: this
				})
			},
			//跳转采购计划详情	 
			itemDetails(item) {
				uni.setStorage({
					key: 'planDetailData',
					data: item
				});
				uni.navigateTo({
					url: '/subpkg/pages/proplanconfirm/details',
					success: function(res) {
						console.log(res, "res")
					}
				});
			},
			input: debounce(function(e) {
				this.value = e;
				let pamStas = this.tabList[this.index] == "全部" ? "" : this.tabList[this.index];
				this.getPlanData({
					pam: {
						planNo: e,
						stas: pamStas,
					},
					that: this
				})
				this.$nextTick(() => {
					// this.value = e;
					// this.inputVal = e;
				})
			}, 500),
			iconClick(e) {
				console.log(e, '点击搜索拿到的数据');
			},
			blur(e) {
				this.$nextTick(() => {
					// this.value = e.target.value;
				})
			},
			changeTab(index) {
				this.index = index;
				this.$refs.paging.reload();
			},
			handleShelf(item) {

			},
			changeList(e) {
				// console.log(e)
			},
			onchange(e) {
				// console.log(e, 44)
			},
			onnodeclick(node) {
				console.log(node, "node");
			},
			onpopupclosed(e) {
				// console.log(e, 33)
			}
		},
		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;
	}

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