<template>
	<view class="zd_container">
		<!-- 入库组箱 -->
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">载具编码</span>
					</view>
					<view class="zd-col-18">
						<search-box v-model="code1"/>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">物料编码</span>
					</view>
					<view class="zd-col-13">
						<search-box v-model="code2"/>
					</view>
					<button class="mini-btn" type="primary" size="mini" @tap="toJump('material?title=物料维护')">查询</button>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label filter_input_disabled">物料名称</span>
					</view>
					<view class="zd-col-18">
						<input type="text" class="filter_input filter_input_disabled" disabled>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">供应商编码</span>
					</view>
					<view class="zd-col-13">
						<search-box v-model="code3"/>
					</view>
					<button class="mini-btn" type="primary" size="mini" @tap="toJump('supplier?title=供应商维护')">查询</button>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label filter_input_disabled">供应商名称</span>
					</view>
					<view class="zd-col-18">
						<input type="text" class="filter_input filter_input_disabled" disabled>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">批次</span>
					</view>
					<view class="zd-col-18">
						<input type="text" class="filter_input">
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">生产日期</span>
					</view>
					<view class="zd-col-18 filter_picker">
						<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
							<view class="uni-input">{{date}}</view>
						</picker>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">重量</span>
					</view>
					<view class="zd-col-16">
						<input type="number" class="filter_input">
					</view>
					<view class="zd-col-2"><span class="filter_unit">KG</span></view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">品质类型</span>
					</view>
					<view class="zd-col-18 filter_select">
						<uni-data-select v-model="index" :localdata="options"></uni-data-select>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">烘干次数</span>
					</view>
					<view class="zd-col-18">
						<input type="number" class="filter_input">
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
			<button class="zd-col-9 button-primary" :class="{'button-info': !code1}" :disabled="disabled">确认组箱</button>
			<button class="zd-col-9 button-primary" :class="{'button-info': !code1}" :disabled="disabled">标签打印</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {getDate} from '@/utils/utils.js'
	import {getStructCount, inStorageOrder, getBillNoInfo, storList, inStorageConfirm} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			const currentDate = getDate({
				format: true
			})
			return {
				title: '',
				code1: '',
				code2: '',
				code3: '',
				date: currentDate,
				options: [],
				index: '',
				disabled: false
			};
		},
		computed: {
			startDate() {
				return getDate('start');
			},
			endDate() {
				return getDate('end');
			}
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			toJump (name) {
				uni.navigateTo({
					url: `/pages/General/${name}`
				})
			},
			bindDateChange: function(e) {
				this.date = e.detail.value
			},
			/** 下拉框*/
			async _inStorageOrder () {
				let res = await inStorageOrder()
				this.options1 = [...res]
			},
			handleChange1 (e) {
				if (e) {
					this._getBillNoInfo(e)
				}
			},
			toEmpty () {
				this.code1 = ''
			},
			async _inStorageConfirm () {
				this.disabled = true
				if (!this.index) {
					this.disabled = false
					return
				}
				try {
					let res = await inStorageConfirm()
					if (res.code === '200') {
						this.index = ''
					}
					this.disabled = false
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>