<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 filter_select">
						<zxz-uni-data-select v-model="index1" filterable :localdata="options1" @change="selectChange"></zxz-uni-data-select>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-5 button-default" @tap="clearUp">清空</button>
			<button class="zd-col-8 button-primary" :class="{'button-info': index1 === ''}" :disabled="disabled" @tap="_fullVehicleOut">锁定</button>
			<button class="zd-col-8 button-primary" :class="{'button-info': index1 === ''}" :disabled="disabled" @tap="_fullVehicleOut">释放</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {queryMaterial, queryLinkMaterial, fullVehicleOut} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				options1: [],
				index1: '',
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			async _queryMaterial (e) {
				let res = await queryMaterial(e)
				res.map(el => {
					this.$set(el, 'value', el.material_id)
					this.$set(el, 'text', el.material_name)
				})
				this.options1 = [...res]
			},
			selectChange (e) {
			},
			async _fullVehicleOut () {
				this.disabled = true
				if (this.index1 === '') {
					this.disabled = false
					return
				}
				try {
					let res = await fullVehicleOut(this.index1)
					this.clearUp()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			},
			clearUp () {
				this.index1 = ''
				this.disabled = false
			}
		}
	}
</script>

<style lang="stylus">
@import '../../common/style/mixin.styl';
</style>
