<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">起始点位</view>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">子托盘号</view>
					<view class="filter_input_wraper">
						<search-box
						v-model="val2"
						/>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">母托盘号</view>
					<view class="filter_input_wraper">
						<search-box
						v-model="val3"
						/>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">重量</view>
					<view class="filter_input_wraper">
						<input type="number" class="filter_input" v-model="val4">
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar_new">
			<button class="zd-col-7 submit-button_c" @tap="toClear">清空</button>
			<button class="zd-col-15 submit-button_new" :class="{'btn-disabled': !index1 || !val2 || !val4}" :disabled="disabled" @tap="_yclrk">确认</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {pointSearch, yclrk} from '@/utils/getData1.js'
	import SearchBox from '@/components/SearchBox.vue'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				dataList: [],
				disabled: false,
				options1: [],
				index1: '',
				val2: '',
				val3: '',
				val4: ''
			};
		},
		created () {
			this._pointSearch('SSX')
		},
		methods: {
			selectChange1 (e) {
				this.index1 = e
			},
			/** 点位查询 下拉框显示 */
			async _pointSearch (a) {
				let res = await pointSearch(a, '', '1')
				this.options1 = [...res]
				this.options1.map(el => {
				this.$set(el, 'value', el.point_code)
				this.$set(el, 'text', el.point_name)
				})
			},
			toClear () {
				this.index1 = ''
				this.val2 = ''
				this.val3 = ''
				this.val4 = ''
			},
			async _yclrk () {
				this.disabled = true
				if (!this.index1 || !this.val2 || !this.val4) {
					this.disabled = false
					return
				}
				try {
					let res = await yclrk(this.index1, this.val2, this.val3, this.val4)
					if (res.code === '1') {
						this.toClear()
					}
					this.disabled = false
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

<style lang="stylus">
</style>
