<template>
	<view class="zd_container">
		<nav-bar title="原材料入库"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="filter_item">
					<view class="filter_label">起始点位</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val1">
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">子托盘号</view>
					<view class="filter_input_wraper">
						<input type="text" class="filter_input" v-model="val2">
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">母托盘号</view>
					<view class="filter_input_wraper">
						<input type="number" class="filter_input" v-model="val3">
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">重量</view>
					<view class="filter_input_wraper">
						<input type="number" class="filter_input" v-model="val4">
					</view>
				</view>
			</view>
			<!-- <view class="item-wrapper">
				<view class="item-wrap" v-for="(e, i) in dataList" :key="i">
					<view class="zd-row mgb10">
						<view class="zd-col-4 item-font-1">点位1:</view>
						<view class="zd-col-9 item-font-2">{{e.point_name1}}</view>
						<view class="zd-col-1 item-line-1"></view>
						<view class="zd-col-9 item-font-3">{{e.point_name2}}</view>
					</view>
					<view class="zd-row mgb10">
						<view class="zd-col-4 item-font-1">点位2:</view>
						<view class="zd-col-9 item-font-2">{{e.point_name3}}</view>
						<view class="zd-col-1 item-line-1"></view>
						<view class="zd-col-9 item-font-3">{{e.point_name4}}</view>
					</view>
					<view class="zd-row">
						<view class="zd-col-3 item-font-1">备注:</view>
						<view class="zd-col-17 item-font-4">{{e.remark}}</view>
						<view class="zd-col-4 item-status" :class="'item-status-' + e.task_status">{{textState(e.task_status)}}</view>
					</view>
				</view>
			</view> -->
		</view>
		<view class="zd-row submit-bar_new">
			<button class="zd-col-5 submit-button_c" @tap="toClear">清空</button>
			<button class="zd-col-13 submit-button_new" :class="{'btn-disabled': !val1 || !val2}" :disabled="disabled" @tap="_coatedWireIntoStorageTask">确认</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {coatedWireIntoStorageTaskShow, coatedWireIntoStorageTask} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				dataList: [],
				disabled: false,
				val1: '',
				val2: '',
				val3: '',
				val4: ''
			};
		},
		created () {
			this._coatedWireIntoStorageTaskShow()
		},
		methods: {
			textState (e) {
				switch (e) {
					case '1':
						return '创建'
						break
					case '2':
						return '创建完成'
						break
					case '3':
						return '下发'
						break
					case '4':
						return '执行中'
						break
					default:
						return ''
						break
				}
			},
			/** grid查询 */
			async _coatedWireIntoStorageTaskShow () {
				let res = await coatedWireIntoStorageTaskShow()
				this.dataList = [...res]
			},
			toClear () {
				this.val1 = ''
				this.val2 = ''
			},
			async _coatedWireIntoStorageTask () {
				this.disabled = true
				if (!this.val1 || !this.val2) {
					this.disabled = false
					return
				}
				try {
					let res = await coatedWireIntoStorageTask(this.val1, this.val2)
					this.disabled = false
					this._coatedWireIntoStorageTaskShow()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

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