<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-24 filter_select">
						<search-box
						v-model="val2"
						/>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
			<button class="zd-col-18 button-primary" :class="{'button-info': !val2}" :disabled="disabled" @tap="_confirmCallMaterial">确认叫料</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {confirmCallMaterial} from '@/utils/getData3.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				val2: '',
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			toEmpty () {
				this.val2 = ''
				this.disabled = false
			},
			async _confirmCallMaterial () {
				this.disabled = true
				if (!this.val2) {
					this.disabled = false
					return
				}
				try {
					let res = await confirmCallMaterial(this.val2, '')
					if (res) {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
					this.toEmpty()
					this.disabled = false
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>