<template>
	<view class="zd_container">
		<nav-bar :title="title"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="zd-row mgb20 border-bottom">
					<uni-icons type="arrow-up" size="18" color="#ff6a00"></uni-icons>
					<view class="zd-col-6 filter_label">任务起点</view>
					<view class="zd-col-18 relative">
						<input type="text" class="filter_input" value="A1">
					</view>
				</view>
				<view class="zd-row mgb20">
					<uni-icons type="arrow-down" size="18" color="#ff6a00"></uni-icons>
					<view class="zd-col-6 filter_label">任务终点</view>
					<view class="zd-col-18 relative">
						<input type="text" class="filter_input" value="B1">
					</view>
				</view>
				<view class="zd-row">
					<button class="zd-col-24 button-primary" :disabled="disabled" @tap="toSure('A1', 'B1', '1')">搬运物料任务</button>
				</view>
			</view>
			<view class="zd_wrapper">
				<view class="zd-row mgb20 border-bottom">
					<uni-icons type="arrow-up" size="18" color="#ff6a00"></uni-icons>
					<view class="zd-col-6 filter_label">任务起点</view>
					<view class="zd-col-18 relative">
						<input type="text" class="filter_input" value="B2">
					</view>
				</view>
				<view class="zd-row mgb20">
					<uni-icons type="arrow-down" size="18" color="#ff6a00"></uni-icons>
					<view class="zd-col-6 filter_label">任务终点</view>
					<view class="zd-col-18 relative">
						<input type="text" class="filter_input" value="A2">
					</view>
				</view>
				<view class="zd-row">
					<button class="zd-col-24 button-primary" :disabled="disabled" @tap="toSure('B2', 'A2', '2')">补空托盘任务</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import {callTask2} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				title: '',
				disabled: false
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			toSure (code1, code2, type) {
				this.disabled = true
				uni.showModal({
					title: '提示',
					cancelText: '取消',
					confirmText: '确定',
					content: type === '1' ? '是否进行搬运物料任务？' : '是否进行补空托盘任务？',
					success: (res) => {
						if (res.confirm) {
							this._callTask(code1, code2, type)
						} else if (res.cancel) {
							this.disabled = false
						}
					}
				})
			},
			async _callTask (code1, code2, type) {
				try {
					let res = await callTask2(code1, code2, type)
					this.disabled = false
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (err) {
					this.disabled = false
				}
			}
		}
	}
</script>

<style lang="stylus" scoped>
@import '../../common/style/mixin.styl';
.item-font-6
	color #fff
.filter_label
	padding-left 0
.pop_point_content_up
	top -200rpx
</style>
