<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-cont">
							{{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.retnCnt}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item">
						<view class="shuo-label">
							退货总金额:
						</view>
						<view class="shuo-cont">
							{{item.retnAmt||""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label-podnme">
							来源机构:
						</view>
						<view class="shuo-cont">
							{{item.branchName||""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label-podnme">
							供应商名称:
						</view>
						<view class="shuo-cont">
							{{item.supplierName||""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							退货人:
						</view>
						<view class="shuo-cont">
							{{item.docmker||""}}
						</view>
					</view>
				</view>
				<view class="inventory-item">
					<view class="shuo-item-name">
						<view class="shuo-label">
							退货时间:
						</view>
						<view class="shuo-cont">
							{{forMatTime(item.docmkDate)}}
						</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 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: ['待确认', '已确认'],
				tabIndex: ['A', 'B'],
				valueList: 0,
				beforeClose: true,
				itemData: {}
			}
		},
		computed: {
			...mapState(['instData']),
		},
		onShow() {
			uni.$once('update', function(data) {
				// uni.redirectTo({
				// 	url: '/pages/grounding/grounding' //写你的路径
				// });
			})
		},
		mounted() {

		},
		methods: {
			...mapActions(['getRetData']),
			async queryList(pageNo, pageSize) {
				let pamStas = this.tabIndex[this.index];
				await this.getRetData({
					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 HH:mm");
			},
			//跳转退货详情	 
			itemDetails(item) {
				uni.setStorage({
					key: 'depDetailData',
					data: item
				});
				uni.navigateTo({
					url: '/subpkg/pages/mcs-depart-return/details',
					success: function(res) {
						console.log(res, "res")
					}
				});
			},
			input: debounce(function(e) {
				this.value = e;
				let pamStas = this.tabIndex[this.index];
				this.getRetData({
					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>