<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">
						<search-box v-model="val1" />
					</view>
				</view>
				<view class="filter_item">
					<view class="filter_label">物料数量</view>
					<view class="filter_input_wraper">
						<input type="number" class="filter_input" v-model="val2">
					</view>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th>起点</th>
								<th>终点</th>
								<th>任务状态</th>
								<th>备注</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(e, i) in dataList" :key="i">
								<td>{{e.point_name1}}</td>
								<td>{{e.point_name2}}</td>
								<td>{{e.task_status}}</td>
								<td>{{e.remark}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
		<view class="zd-row submit-bar">
			<button class="zd-col-11 submit-button" @tap="_forcedRestingShow">刷新</button>
			<button class="zd-col-11 submit-button" :class="{'btn-disabled': !val1 || !val2}" :disabled="disabled" @tap="toSure">确认</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {callingResidueMaterialTaskShow, callingResidueMaterialTask} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				val1: '',
				val2: '',
				dataList: [],
				disabled: false
			};
		},
		created () {
			this._callingResidueMaterialTaskShow()
		},
		methods: {
			/** grid查询 */
			async _callingResidueMaterialTaskShow () {
				let res = await callingResidueMaterialTaskShow()
				this.dataList = [...res]
			},
			/** 确认 */
			async toSure () {
				this.disabled = true
				if (!this.val1 || !this.val2) {
					this.disabled = false
					return
				}
				try {
					let res = await callingResidueMaterialTask(this.val1, this.val2)
					this.disabled = false
					this.val1 = ''
					this.val2 = ''
					this._callingResidueMaterialTaskShow()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			}
		}
	}
</script>

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