<template>
	<view class="content">
		<nav-bar title="缓存线-详情"></nav-bar>
		<view class="search-confirm-wrap">
			<view class="search-wrap">
				<view class="search-item">
					<label class="search-label">料箱码</label>
					<view class="filter_input_wraper">
						<search-box
						v-model="val1"
						/>
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">工序</label>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">物料</label>
					<view class="filter_input_wraper">
						<input type="text" class="search-input-l" v-model="val2">
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">名称</label>
					<view class="filter_input_wraper">
						<input type="text" class="search-input-l" v-model="val3">
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">规格</label>
					<view class="filter_input_wraper">
						<input type="text" class="search-input-l" v-model="val4">
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">数量</label>
					<view class="filter_input_wraper">
						<input type="number" class="search-input-l" v-model="val5">
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">重量</label>
					<view class="filter_input_wraper">
						<input type="number" class="search-input-l" v-model="val6">
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">层</label>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index2" :localdata="options2" @change="selectChange2"></uni-data-select>
					</view>
				</view>
				<view class="search-item">
					<label class="search-label">位置</label>
					<view class="filter_input_wraper">
						<uni-data-select v-model="index3" :localdata="options3" @change="selectChange3"></uni-data-select>
					</view>
				</view>
			</view>
			<view class="confirm-button-wrap">
				<button class="confirm-button" @tap="toSearch()">设为满框</button>
				<button class="confirm-button" :disabled="disabled" @tap="toSure()">设为空框</button>
				<button class="confirm-button" :disabled="disabled" @tap="toSure()">设为空位</button>
			</view>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {queryInstraction, instOperation} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				options1: [],
				index1: '',
				options2: [],
				index2: '',
				options3: [],
				index3: '',
				val1: '',
				val2: '',
				val3: '',
				val4: '',
				val5: '',
				val6: '',
				dataList: [],
				pkId: '',
				disabled: false
			};
		},
		methods: {
			/** 选择器1 */
			selectChange1(e) {
				this.index1 = e
			},
			/** 选择器3 */
			selectChange2(e) {
				this.index2 = e
			},
			/** 选择器3 */
			selectChange3(e) {
				this.index3 = e
			},
			toSearch () {
			  this.dataList = []
			  this._queryInstraction()
			},
			async _queryInstraction () {
				let res = await queryInstraction()
				this.dataList = [...res.data]
			},
			toSure () {
			  this.disabled = true
			  if (!this.pkId) {
				uni.showToast({
					title: '请选择',
					icon: 'none'
				})
				this.disabled = false
				return
			  }
			  this._instOperation()
			},
			async _instOperation () {
				let res = await instOperation()
				this.dataList = [...res.data]
			},
			toRadio (e) {
			  this.pkId = this.pkId === e.instruct_uuid ? '' : e.instruct_uuid
			}
		}
	}
</script>
