<template>
	<view class="zd_container">
		<nav-bar title="混碾搬运"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item">
					<view class="filter_label_wraper">
						<span class="filter_label">载具编码</span>
					</view>
					<view class="filter_input_wraper">
						<search-box v-model="val1" />
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">混碾位置</view>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
					</view>
				</view>
			</view>
		</view>
		<view class="submit-bar">
			<button class="submit-button" :class="{'btn-disabled': !val1 || !index1}" :disabled="disabled1" @tap="toSure">确认</button>
			<button class="submit-button" @tap="toCancle">取消</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {getBlendingCode, sendTask} from '@/utils/getData1.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				options1: [],
				index1: '',
				disabled1: false
			};
		},
		created () {
			this._getBlendingCode()
			this._deviceStatus()
		},
		methods: {
			/** 选择器 */
			selectChange1(e) {
				this.index1 = e
			},
			/** 下拉框-混碾位置 */
			async _getBlendingCode () {
				let res = await getBlendingCode()
				this.options1 = [...res]
			},
			/** 确定 */
			async toSure () {
				this.disabled1 = true
				if (this.val1 || !this.index1) {
					this.disabled1 = false
					return
				}
				try {
					let res = await sendTask(this.val1, this.index1)
					this.disabled1 = false
					this.val1 = ''
					this.index1 = ''
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled1 = false
				}
			},
			toCancle () {
				this.disabled1 = false
				this.val1 = ''
				this.index1 = ''
			}
		}
	}
</script>

<style lang="stylus" scoped>
.filter_item_1, .filter_input_wraper_1
	align-items: flex-start
	height 210rpx
</style>
