<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-7">
						<span class="filter_label">木托盘编码</span>
					</view>
					<view class="zd-col-17 filter_select">
						<search-box
						v-model="val1"
						/>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-5 button-default" @tap.stop="clearUp">清空</button>
			<button class="zd-col-8 button-primary" :class="{'button-info': !val1}" :disabled="disabled1" @tap="toSure1">入库</button>
			<button class="zd-col-8 button-primary" :class="{'button-info': !val1}" :disabled="disabled2" @tap="toSure2">出库</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {pdaSmck} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				val1: '',
				disabled1: false,
				disabled2: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			clearUp () {
				this.val1 = null
				this.disabled1 = false
				this.disabled2 = false
			},
			toSure1 () {
				this.disabled1 = true
				if (!this.val1) {
					this.disabled1 = false
					return
				}
				this._pdaSmck('1')
			},
			toSure2 () {
				this.disabled2 = true
				if (!this.val1) {
					this.disabled2 = false
					return
				}
				this._pdaSmck('2')
			},
			async _pdaSmck (type) {
				try {
					let res = await pdaSmck(this.val1, type)
					this.disabled1 = false
					this.disabled2 = false
					this.val1 = ''
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled1 = false
					this.disabled2 = false
				}
			}
		}
	}
</script>

<style lang="stylus">
@import '../../common/style/mixin.styl';
.msg_wrapper
	height auto
	min-height 30%
</style>
