<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_wraper">
						<span class="filter_label">搬运起点</span>
					</view>
					<view class="filter_input_wraper">
						<zxz-uni-data-select v-model="index2" filterable :localdata="options2" @inputChange="inputChange" @change="change"></zxz-uni-data-select>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label_wraper">
						<span class="filter_label">砖块数量</span>
					</view>
					<view class="filter_input_wraper">
						<input type="number" class="filter_input" v-model="val2">
					</view>
				</view>
			</view>
		</view>
		<view class="submit-bar">
			<button class="submit-button" :class="{'btn-disabled': !index2}" :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 {getPressCode, groupmanual} from '@/utils/getData1.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				val2: '',
				options2: [],
				index2: '',
				disabled1: false
			};
		},
		created () {
			this._getPressCode()
			this._getVehicleType()
		},
		methods: {
			change(e) {
				// console.log('e:', e);
			},
			inputChange(e) {
				// console.log(e);
			},
			// selectChange2(e) {
			// 	this.index2 = e
			// },
			/** 获取点位编码下拉框 */
			async _getPressCode () {
				let res = await getPressCode()
				this.options2 = [...res]
			},
			/** 确定 */
			async toSure () {
				this.disabled1 = true
				if (!this.index2) {
					this.disabled1 = false
					return
				}
				try {
					let res = await groupmanual(this.val1, this.index2, this.val2)
					this.disabled1 = false
					this.val1 = ''
					this.val2 = ''
					this.index2 = ''
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled1 = false
				}
			},
			toCancle () {
				this.disabled1 = false
				this.val1 = ''
				this.val2 = ''
				this.index2 = ''
			}
		}
	}
</script>

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