<template>
	<view class="zd_container">
		<!-- <nav-bar title="异常出库解锁"></nav-bar> -->
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item is-required">
					<view class="filter_label_wraper">
						<span class="filter_label">{{$t('filter.box-no')}}</span>
					</view>
					<view class="filter_input_wraper">
						<search-box ref="scanChild" v-model="val1" @handleChange="handleChange1" 
						/>
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label_wraper">
						<span class="filter_label">{{$t('grid.point-code')}}</span>
					</view>
					<view class="filter_input_wraper">
						<search-box v-model="val2"  @handleChange="handleChange2" />
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submitbar">
			<button class="zd-col-22 btn-submit btn-success letter-30" :class="{'btn-info': !val1 && !val2}" :disabled="disabled1" @tap="handleConfirm">解锁</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import { confirmAction } from '@/utils/utils.js'
	import {abnormalOut} from '@/utils/getData1.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				val1: '',
				val2: '',
				disabled1: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		mounted () {
			this.$refs.scanChild.handleFocus()
		},
		methods: {
			handleChange1 (e) {
			},
			handleChange2 (e) {
			},
			async handleConfirm() {
				if (!this.val1 && !this.val2) {
					return
				}
				const isConfirmed = await confirmAction("确认操作", "确定要执行此操作吗？")
				if (isConfirmed) {
					this._abnormalOut()
				}
			},
			async _abnormalOut () {
				this.disabled1 = true
				try {
					let res = await abnormalOut(this.val1, this.val2)
					this.val1 = ''
					this.val2 = ''
					this.disabled1 = false
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled1 = false
				}
			}
		}
	}
</script>