<template>
	<view class="container">
		<nav-bar title="点位管理"></nav-bar>
		<view class="content">
			<view class="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"
						@input="handleChange1"
						/>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label_wraper">
						<span class="filter_label">空轴/母卷</span>
					</view>
					<view class="filter_input_wraper">
						<search-box 
						v-model="val2"
						@input="handleChange2"
						/>
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">是否有货</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val3" disabled>
					</view>
				</view>
			</view>
		</view>
		<view class="submit-bar">
			<button class="submit-button" :class="{'btn-disabled': !val1 || !val2}" :disabled="disabled" @tap="_pointOperate">绑定</button>
			<button class="submit-button" :class="{'btn-disabled': !val1 || !val2}" :disabled="disabled" @tap="_pointOperate">解绑</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {pointOperate, pointStatusQuery} from '@/utils/getData1.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				val2: '',
				val3: '',
				disabled: false
			};
		},
		methods: {
			handleChange1 (e) {
				console.log(e)
				// this._pointStatusQuery()
			},
			handleChange2 (e) {
				console.log(e)
				// this._pointStatusQuery()
			},
			/** 查询 */
			async _pointStatusQuery () {
				if (!this.val1) {
					return
				}
				let res = await pointStatusQuery(this.val1)
				this.dataList = [...res.rows]	
			},
			async _pointOperate () {
				this.disabled = true
				if (!this.val1 || !this.val2) {
					this.disabled = false
					return
				}
				try {
					let res = await pointOperate(this.val1, this.val2)
					uni.showToast({
						title: res.desc,
						icon: 'none'
					})
					this.disabled = false
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

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