<template>
	<view class="zd_container">
		<nav-bar title="托盘绑定"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item">
					<view class="filter_label">木托盘编码</view>
					<view class="filter_input_wraper">
						<search-box v-model="val1" />
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label_wraper">
						<span class="filter_label">钢托盘编码</span>
					</view>
					<view class="filter_input_wraper">
						<search-box v-model="val2" />
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-11 submit-button" :class="{'btn-disabled': !val1 || !val2}" :disabled="disabled" @tap="toSure">确认</button>
			<button class="zd-col-11 submit-button" @tap="toCancle">清空</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {manualSortingBindingVehicle} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				val2: '',
				disabled: false
			};
		},
		methods: {
			/** 确定 */
			async toSure () {
				this.disabled = true
				if (!this.val1 || !this.val2) {
					this.disabled = false
					return
				}
				try {
					let res = await manualSortingBindingVehicle(this.val2, this.val1)
					this.disabled = false
					this.val1 = ''
					this.val2 = ''
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			},
			toCancle () {
				this.disabled = false
				this.val1 = ''
				this.val2 = ''
			}
		}
	}
</script>

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