<template>
	<view class="zd_container">
		<nav-bar title="发货区解绑" :inner="true" :show="false"></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" @handleChange="handleChange"/>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">单据号</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input filter_input_disabled" v-model="val2" disabled>
					</view>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th class="fontcol2">木箱号</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" @tap="_twoPdaIvtbBoxDtlQuery(e.package_box_sn)">
								<td class="fontcol2">{{e.package_box_sn}}</td>
								<td>{{e.point_code}}</td>
								<td>{{e.point_name}}</td>
								<td>{{e.box_weight}}</td>
								<td>{{e.product_name}}</td>
								<td>{{e.product_description}}</td>
								<td>{{e.sale_order_name}}</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': dataList.length === 0}" :disabled="disabled" @tap="_twoPdaOutConfirm">确认</button>
			<button class="zd-col-8 btn-submit btn-success letter-30" @tap="_twoPdaIvtDtlQuery(val1)">查询</button>
		</view>
		<view class="msg_wrapper" :class="show ? 'popshow' : 'pophide'">
			<view class="pop-line"></view>
			<view class="msg_content">
				<view class="zd_wrapper grid-wraper">
					<view class="slide_new">
						<table>
							<thead>
								<tr>
									<th class="fontcol1">木箱号</th>
									<th>子卷号</th>
									<th>sap批次</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 in dtlList" :key="e.package_box_sn">
									<td class="fontcol1">{{e.package_box_sn}}</td>
									<td>{{e.container_name}}</td>
									<td>{{e.sap_pcsn}}</td>
									<td>{{e.net_weight}}</td>
									<td>{{e.status}}</td>
									<td>{{e.sale_order_name}}</td>
									<td>{{e.customer_name}}</td>
									<td>{{e.customer_description}}</td>
									<td>{{e.width}}</td>
									<td>{{e.thickness}}</td>
									<td>{{e.length}}</td>
									<td>{{e.width_standard}}</td>
									<td>{{e.thickness_request}}</td>
									<td>{{e.quality_guaran_period}}</td>
									<td>{{e.date_of_production}}</td>
									<td>{{e.date_of_fG_inbound}}</td>
								</tr>
							</tbody>
						</table>
					</view>
				</view>
			</view>
			<view class="zd-row submitbar">
				<button class="zd-col-22 btn-submit btn-success letter-30" @tap.stop="show = false">返回</button>
			</view>
		</view>
		<view v-if="show" class="msg_mask"></view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {twoPdaIvtDtlQuery, twoPdaIvtbBoxDtlQuery, twoPdaOutConfirm} from '@/utils/getData3.js'
	// import {twoPdaIvtDtlQuery, twoPdaIvtbBoxDtlQuery} from '@/utils/mork2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				val2: '',
				dataList: [],
				dtlList: [],
				show: false,
				disabled: false
			};
		},
		onLoad (options) {
			this.val2 = options.code
		},
		methods: {
			handleChange (e) {
				this._twoPdaIvtDtlQuery(e)
			},
			async _twoPdaIvtDtlQuery (e) {
				let res = await twoPdaIvtDtlQuery(e, this.val2)
				this.dataList = [...res.data]
			},
			async _twoPdaIvtbBoxDtlQuery (e) {
				let res = await twoPdaIvtbBoxDtlQuery(e)
				this.dtlList = [...res.data]
				this.show = true
			},
			async _twoPdaOutConfirm () {
				this.disabled = true
				if (this.dataList.length === 0) {
					this.disabled = false
					return
				}
				try {
					let res = await twoPdaOutConfirm(this.val1)
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					this.disabled = false
				} catch (e) {
					this.disabled = false
				}
			},
			clearUp () {
				this.val1 = ''
				this.dataList = []
			}
		}
	}
</script>

<style lang="stylus">
</style>
