<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"
						@handleChange="handleChange"
						/>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-7">
						<span class="filter_label">物料编码</span>
					</view>
					<view class="zd-col-17 filter_select">
						<view class="filter_input" style="color: #E9B451; font-weight: 700;">{{code}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-6 button-default" @tap.stop="clearUp">清空</button>
			<button class="zd-col-15 button-primary" :class="{'button-info': !val1}" :disabled="disabled" @tap="_hnlgcx(val1)">查询</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {hnlgcx} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				val1: '',
				code: null,
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			clearUp () {
				this.val1 = null
				this.code = null
				this.disabled = false
			},
			handleChange (e) {
				if (e) {
					this._hnlgcx(e)
				}
			},
			async _hnlgcx (e) {
				this.disabled = true
				try {
					let res = await hnlgcx(e)
					this.disabled = false
					if (res) {
						this.code = res.material_code
					}
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

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