<template>
	<view class="query-wrap">
		<uni-easyinput prefixIcon="search" :value="value" placeholder="请输入采购单号" @iconClick="iconClick" @input="input">
		</uni-easyinput>
		<v-tabs v-model="index" :tabs="tabList" @change="changeTab" :scroll="false"></v-tabs>
		<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="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label-podnme">
							采购订单号
						</view>
						<view class="shuo-unit">
							{{item.id}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							采购品种数:
						</view>
						<view class="shuo-cont">
							{{item.detlCnt}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							采购总数量:
						</view>
						<view class="shuo-cont">
							{{item.qtySum}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							采购总金额:
						</view>
						<view class="shuo-cont">
							{{item.purcAmt}}
						</view>
					</view>
					<view class="shuo-item">
						<view class="shuo-label">
							来源机构:
						</view>
						<view class="shuo-cont">
							{{item.deptName||""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							采购描述:
						</view>
						<view class="shuo-cont">
							<span v-if="item.purcType == '2'">{{ item.oprn }}</span>
							<span v-if="item.purcType == '1'">普通采购</span>
						</view>
					</view>

					<view class="shuo-item">
						<view class="shuo-label">
							采购时间:
						</view>
						<view class="shuo-cont">
							{{forMatTime(item.docmkDate)}}
						</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,
				value1: "",
				value: "",
				dataList: [],
				inputVal: "",
				codeVal: "",
				confirmVal: "",
				changeVal: "",
				tabList: ['待确认', '已确认'],
				valueList: 0,
				beforeClose: true,
				itemData: {}
			}
		},
		computed: {
			...mapState(['instData', 'userData']),
		},
		onShow() {
			uni.$once('update', function(data) {
				// uni.redirectTo({
				// 	url: '/pages/grounding/grounding' //写你的路径
				// });
			})
		},
		mounted() {

		},
		methods: {
			...mapActions(['getTakingData']),
			async queryList(pageNo, pageSize) {
				let pamStas = this.index == "0" ? "A" : 'B';
				await this.getTakingData({
					pam: {
						current: pageNo,
						size: pageSize,
						spdId: this.instData.spdId,
						stas: pamStas,
						id: this.value
					},
					that: this
				})
			},
			forMatTime(row) {
				return moment(row).format("YYYY-MM-DD");
			},
			//跳转受理详情	 
			itemDetails(item) {
				uni.setStorage({
					key: 'orderTakDetailData',
					data: item
				});
				uni.navigateTo({
					url: '/subpkg/pages/mcs-order-taking/details',
					success: function(res) {
						console.log(res, "res")
					}
				});
			},
			input: debounce(function(e) {
				this.value = e;
				let pamStas = this.index == "0" ? "A" : 'B';
				this.getTakingData({
					pam: {
						spdId: this.instData.spdId,
						stas: pamStas,
						id: e
					},
					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>