<template>
	<view>
		<view class="uni-form-item uni-column">
			<view class="uni-flex uni-row">
				<view class="title" style="width: 180rpx;">出库任务单号:</view>
				<input class="uni-input" style="-webkit-flex: 1;flex: 1;margin-right: 5px;" v-model="outTaskNo" :focus="foucusIndex === 0" placeholder="请输入出库任务单号" @confirm="foucusChange0"/>
			</view>
			<view class="uni-flex uni-row" style="margin-top: 3px;margin-bottom: 3px;">
				<view class="title" style="width: 180rpx;">生产令号:</view>
				<input class="uni-input" style="-webkit-flex: 1;flex: 1;margin-right: 5px;" :focus="foucusIndex === 1" v-model="bomNo" placeholder="请输入生产令号" @confirm="foucusChange1"/>
			</view>
			<view class="uni-flex uni-row">
				<button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;" @click="queryFun">查询</button>
				<button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;margin-right: 5px;" @click="resetCondition">重置条件</button>
			</view>
		</view>
		<view style="margin-left: 5px;margin-right: 5px;">
			<view style="margin-left: 10px;margin-bottom: 5px;">出库任务单数据：</view>
			<view class="my-tips-view" v-if="isShowTips">没有查询到出库任务单数据......</view>
			<view class="uni-navigate-item1 uni-flex uni-row" style="-webkit-justify-content: space-between;justify-content: space-between;" 
			v-for="(item,key) in deliverList" :key="key" @click="goDetailPage(item)">
				<text class="uni-navigate-text">{{item.outTaskNo}}</text>
				<text class="uni-navigate-icon uni-icon">&#xe470;</text>
			</view>
		</view>
	</view>
</template>

<script>
	// TODO 修复Android v3 加载过慢问题 
	// #ifdef APP-PLUS
	var domModule = weex.requireModule('dom');
	domModule.addRule('fontFace', {
		'fontFamily': "uniicons",
		'src': "url('/static/uni.ttf')"
	});
	// #endif
	export default {
		data() {
			return {
				title: '没有查询到校验单数据......',
				outTaskNo : '',
				bomNo: '',
				isShowTips: true,
				deliverList:[],
				foucusIndex: 0
			}
		},
		methods: {
			async queryFun() {
				uni.showLoading({
					title: "正在查询...",
					mask: true,
				})
				this.deliverList = []
				let parm = {
					url : '/SapInterface/QuerySapOutTaskList',
					data: {
						OutTaskNo: this.outTaskNo,
						BomNo: this.bomNo
					},
					method: 'POST',
					isHaveToken : true
				}
				let retData = await getApp().RequestData(parm)
				// console.log(retData)
				if(retData.isSuccess) {
					if(retData.data.code == 200) {
						let len = retData.data.data.length
						for (let i = 0; i < len;  i++) {
							this.deliverList.push({
									deliverid: i + 1,
									outTaskNo: retData.data.data[i].outTaskNo
							});
						}
						if(len > 0) {
							this.isShowTips = false
						}
						else {
							this.isShowTips = true
						}
					}
					else {
						this.isShowTips = true
					}
				}
				else {
					this.isShowTips = true
				}
				uni.hideLoading()
			},
			resetCondition() {
				this.outTaskNo = ''
				this.bomNo = ''
				this.foucusIndex = 0
			},
			goDetailPage(item) {
				let urlStr = '/pages/Outstore/outstoreDtlNew?outTaskNo=' + item.outTaskNo;
				uni.navigateTo({
					url: urlStr
				});
			},
			foucusChange0(event) {
				let str = event.detail.value
				if(str.length !== 0) {
					this.foucusIndex = 1
				}
			},
			foucusChange1(event) {
				let str = event.detail.value
				if(str.length !== 0) {
					this.foucusIndex = 2
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/uni-nvue.css';
	.uni-navigate-icon-01 {
		//margin-left: 200px;
		// margin-right: 5px;
		color: #999999;
		font-size: 14px;
		font-weight: normal;
	}
	.uni-navigate-item1 {
		align-items: center;
		background-color: #FFFFFF;
		border-top-style: solid;
		border-top-color: #f0f0f0;
		border-top-width: 1px;
		padding: 12px;
		cursor: pointer;
	}
	.uni-navigate-item1:active {
		background-color: #007AFF;
	}
	.my-tips-view {
		margin-top: 50px;
		text-align: center;
		color: #999999;
		font-size: 20px;
		font-weight: normal;
	}
</style>
