<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">
					<view class="filter_label_wraper">
						<span class="filter_label">关键字</span>
					</view>
					<view class="filter_input_wraper">
						<search-box
						v-model="val1"
						/>
					</view>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th>任务号</th>
								<th>任务状态</th>
								<th>起点1</th>
								<th>终点1</th>
								<th>起点2</th>
								<th>终点2</th>
								<th>载具号1</th>
								<th>载具号2</th>
								<th>车间</th>
								<th>创建者</th>
								<th>创建时间</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(e, i) in dataList" :key="i">
								<td>{{e.task_code}}</td>
								<td>{{options | findByValue(e.task_status)}}</td>
								<td>{{e.point_code1}}</td>
								<td>{{e.point_code2}}</td>
								<td>{{e.point_code3}}</td>
								<td>{{e.point_code4}}</td>
								<td>{{e.vehicle_code}}</td>
								<td>{{e.vehicle_code2}}</td>
								<td>{{e.product_area}}</td>
								<td>{{e.create_name}}</td>
								<td>{{e.create_time}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
		<view class="zd-row submitbar">
			<button class="zd-col-22 btn-submit btn-success letter-30" @tap="_seeTaskByPoint">查询</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {seeTaskByPoint} from '@/utils/getData3.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				val1: '',
				dataList: [],
				options: [{value: '01', text: '生成'}, {value: '02', text: '确定起点'}, {value: '03', text: '确定终点'}, {value: '04', text: '起点终点确认'}, {value: '05', text: '下发'}, {value: '06', text: '执行中'}, {value: '07', text: '完成'}, {value: '071', text: '取货完成，执行中'}]
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		methods: {
			/** 初始化查询 */
			async _seeTaskByPoint () {
				try {
					let res = await seeTaskByPoint(this.val1)
					if (res && res.length > 0) {
						this.dataList = [...res]
					} else {
						this.dataList = []
					}
				} catch (e) {
					this.dataList = []
				}	
			}
		}
	}
</script>