<template>
	<view class="zd_container">
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="zd-row border-bottom">
					<view class="zd-col-5">
						<span class="filter_label">载具编码</span>
					</view>
					<view class="zd-col-19">
						<search-box
						v-model="val1"
						/>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-5">
						<span class="filter_label">地面点位</span>
					</view>
					<view class="zd-col-19">
						<search-box
						v-model="val2"
						/>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-5">
						<span class="filter_label">订单编码</span>
					</view>
					<view class="zd-col-19">
						<input type="number" class="filter_input" v-model="val3">
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-5">
						<span class="filter_label">物料数量</span>
					</view>
					<view class="zd-col-19">
						<input type="number" class="filter_input" v-model="val4">
					</view>
				</view>
				<view class="zd-row">
					<view class="zd-col-5">
						<span class="filter_label">当前工序</span>
					</view>
					<view class="zd-col-19 filter_select">
						<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
					</view>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th class="fontcol1">载具编码</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="toChose(e)" :class="{'checked': e.point_code === pkId}">
								<td class="fontcol1">{{e.vehicle_code}}</td>
								<td><view class="fontbg">{{e.vehicle_type}}</view></td>
								<td class="fontcol2">{{e.material_code}}</td>
								<td class="fontcol2">{{e.material_name}}</td>
								<td>{{e.point_code}}</td>
								<td>{{e.material_qty}}</td>
								<td>{{e.pcsn}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-7 button-default" @tap="clearUp">清空</button>
			<button class="zd-col-15 button-primary" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_fullVehicleIn">入库确认</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {fullVehicleIn} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				options1: [],
				index1: '',
				val1: '',
				val2: '',
				val3: '',
				val4: '',
				dataList: [],
				pkId: '',
				pkObj: {},
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			selectChange1(e) {
				this.index1 = e
			},
			async _getVehicleType () {
				let res = await getVehicleType()
				this.options1 = [...res]
			},
			
			clearUp () {
				this.index1 = ''
				this.val1 = ''
				this.val2 = ''
				this.val3 = ''
				this.val4 = ''
				this.disabled = false
			},
			toCheck (e) {
				e.checked = !e.checked
				this.checkArr = this.dataList1.filter(i => { return i.checked === true })
			},
			toChose (e) {
				this.pkId = this.pkId === e.point_code ? '' : e.point_code
				this.pkObj = this.pkId === e.point_code ? e : {}
			},
			/**  入库 */
			async _fullVehicleIn () {
				this.disabled = true
				if (!this.pkId) {
					this.disabled = false
					return
				}
				try {
					let res = await fullVehicleIn(this.pkId)
					this.clearUp()
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

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