<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">{{$t('filter.sales-order-number')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val1">
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('grid.sub-roll-number')}}</view>
					<view class="filter_input_wraper">
						<search-box v-model="val2" />
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('filter.customer-number')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val3">
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('grid.customer-name')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val4">
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('grid.product-code')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val5">
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('grid.product-description')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val6">
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('grid.net-weight')}}</view>
					<view class="filter_input_wraper">
						<NumberInput
						v-model="val7"
						input-class="filter_input"
						mode="mixed"
						:decimalLength="3"
						/>
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('filter.product-thickness')}}(mm)</view>
					<view class="filter_input_wraper">
						<NumberInput
						v-model="val8"
						input-class="filter_input"
						mode="mixed"
						:decimalLength="3"
						/>
					</view>
				</view>
				<view class="filter_item is-required">
					<view class="filter_label">{{$t('filter.material-type')}}</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val9">
					</view>
				</view>
			</view>
		</view>
		<view class="zd-row submitbar">
			<button class="zd-col-6 btn-submit btn-default" @tap="clearUp">{{$t('button.clear')}}</button>
			<button class="zd-col-15 btn-submit btn-success" :class="{'btn-info': !val1 || !val2 || !val3 || !val4 || !val5 || !val6 || !val7 || !val8 || !val9}" :disabled="disabled" @tap="_packagerelation">{{$t('button.confirm')}}</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import NumberInput from '@/components/NumberInput.vue'
	import {packagerelation} from '@/utils/getData3.js'
	export default {
		components: {
			NavBar,
			SearchBox,
			NumberInput
		},
		data() {
			return {
				title: '',
				val1: '',
				val2: '',
				val3: '',
				val4: '',
				val5: '',
				val6: '',
				val7: '',
				val8: '',
				val9: '',
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			async _packagerelation () {
				this.disabled = true
				if (!this.val1 || !this.val2 || !this.val3 || !this.val4 || !this.val5 || !this.val6 || !this.val7 || !this.val8 || !this.val9) {
					this.disabled = false
					return
				}
				try {
					let res = await packagerelation(this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9)
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					this.disabled = false
				} catch (e) {
					this.disabled = false
				}
			},
			clearUp () {
				this.val1 = ''
				this.val2 = ''
				this.val3 = ''
				this.val4 = ''
				this.val5 = ''
				this.val6 = ''
				this.val7 = ''
				this.val8 = ''
				this.val9 = ''
			}
		}
	}
</script>