<template>
	<view class="zd_container">
		<!-- <nav-bar title="发货区解绑"></nav-bar> -->
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item">
					<view class="filter_label_wraper">
						<span class="filter_label">木箱号</span>
					</view>
					<view class="filter_input_wraper">
						<search-box v-model="val1" />
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">单据号</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val2">
					</view>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th>单据号</th>
								<th>状态</th>
								<th>总重量</th>
								<th>明细数</th>
								<th>客户编码</th>
								<th>客户名称</th>
								<th>交货单</th>
								<th>备注</th>
								<th>创建人</th>
								<th>创建时间</th>
								<th>分配人</th>
								<th>分配时间</th>
								<th>确认人</th>
								<th>确认时间</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(e, i) in dataList" :key="i" @click="toCheck(e)" :class="{'checked': e.bill_code === pkId}">
								<td>{{e.bill_code}}</td>
								<td>{{e.bill_status}}</td>
								<td>{{e.total_qty}}</td>
								<td>{{e.detail_count}}</td>
								<td>{{e.cust_code}}</td>
								<td>{{e.cust_name}}</td>
								<td>{{e.source_id}}</td>
								<td>{{e.remark}}</td>
								<td>{{e.input_optname}}</td>
								<td>{{e.input_time}}</td>
								<td>{{e.dis_optname}}</td>
								<td>{{e.dis_time}}</td>
								<td>{{e.confirm_optname}}</td>
								<td>{{e.confirm_time}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
		<view class="zd-row submitbar">
			<button class="zd-col-5 btn-submit btn-default letter-30" @tap="clearUp">清空</button>
			<button class="zd-col-8 btn-submit btn-success letter-30" :class="{'btn-info': !pkId}" @tap="toSure">确认</button>
			<button class="zd-col-8 btn-submit btn-success letter-30" @tap="_twoPdaIvtQuery">查询</button>
		</view>
		<up-top ref="UT" :scrollTop="top"></up-top>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import UpTop from '@/components/upTop.vue'
	import {twoPdaIvtQuery} from '@/utils/getData3.js'
	// import {twoPdaIvtQuery} from '@/utils/mork2.js'
	export default {
		components: {
			NavBar,
			SearchBox,
			UpTop
		},
		data() {
			return {
				title: '',
				top: 0,
				val1: '',
				val2: '',
				dataList: [],
				pkId: '',
				pkObj: {}
			};
		},
		onPageScroll(e) {
			this.$refs.UT.topData(e.scrollTop)
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			async _twoPdaIvtQuery () {
				let res = await twoPdaIvtQuery(this.val1, this.val2)
				this.dataList = [...res.data]
			},
			toCheck (e) {
				this.pkId = this.pkId === e.bill_code ? '' : e.bill_code
				this.pkObj = this.pkId === e.bill_code ? e : {}
			},
			toSure () {
				if (this.pkId) {
					uni.navigateTo({
						url: '/pages/SecondPhase/DeliveryUnbindConfirm?code=' + this.pkObj.bill_code
					})
				}
			},
			clearUp () {
				this.val1 = ''
				this.val2 = ''
				this.dataList = []
				this.pkId = ''
			}
		}
	}
</script>