<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-8">
						<span class="filter_label">人工分拣点位</span>
					</view>
					<view class="zd-col-15 filter_select">
						<zxz-uni-data-select v-model="index1" filterable :localdata="options1"></zxz-uni-data-select>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-8">
						<span class="filter_label">缓存货架点位</span>
					</view>
					<view class="zd-col-15 filter_select">
						<zxz-uni-data-select v-model="index2" filterable :localdata="options2"></zxz-uni-data-select>
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-7 button-default" @tap.stop="clearUp">清空</button>
			<button class="zd-col-7 button-primary" :class="{'button-info': !index1 || !index2}" :disabled="disabled1" @tap="_rgfjqlTask">叫料</button>
			<button class="zd-col-7 button-primary" :class="{'button-info': !index1}" :disabled="disabled2" @tap="_rgfjskTask">送空盘</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {rgfjPoint,hchjPoint,rgfjqlTask,rgfjskTask} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				options1: [],
				index1: '',
				options2: [],
				index2: '',
				disabled1: false,
				disabled2: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		created () {
			this._rgfjPoint()
			this._hchjPoint()
		},
		methods: {
			/** 下拉框*/
			async _rgfjPoint () {
				let res = await rgfjPoint()
				this.options1 = [...res]
			},
			async _hchjPoint () {
				let res = await hchjPoint()
				this.options2 = [...res]
			},
			clearUp () {
				this.index1 = ''
				this.index2 = ''
				this.disabled1 = false
				this.disabled2 = false
			},
			async _rgfjqlTask () {
				this.disabled1 = true
				if (!this.index1 || !this.index2) {
					this.disabled1 = false
					return
				}
				try {
					let res = await rgfjqlTask(this.index2, this.index1)
					this.disabled1 = false
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled1 = false
				}
			},
			async _rgfjskTask () {
				this.disabled2 = true
				if (!this.index1) {
					this.disabled2 = false
					return
				}
				try {
					let res = await rgfjskTask(this.index1)
					this.disabled2 = false
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled2 = false
				}
			}
		}
	}
</script>

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