<template>
	<view>
		<view class="uni-form-item uni-column">
			<view class="uni-flex uni-row">
				<view class="title">交验单号:</view>
				<input class="uni-input" style="-webkit-flex: 1;flex: 1;margin-right: 5px;" v-model="deliverNo" :focus="foucusIndex === 0" placeholder="请输入交验单号" @confirm="foucusChange0"/>
			</view>
			<view class="uni-flex uni-row" style="margin-top: 3px;margin-bottom: 3px;">
				<view class="title">生产令号:</view>
				<input class="uni-input" style="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>
		<uni-section title="交验单数据：" type="line" style="margin-bottom: 3px;padding: 3px;">
			<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.deliverNo}}</text>
				<text class="uni-navigate-icon uni-icon">&#xe470;</text>
			</view>
			<view v-if="!isShowTips" style="text-align: center; margin-top: 10px;">
				<text class="example-info">数据总量：{{ total }}条，每页数据：{{ pageSize }}</text>
			</view>
			<uni-pagination :total="total" :current="current" :pageSize="pageSize" @change="pageChange" title="标题文字" v-if="!isShowTips" style="margin: 10px;"/>
		</uni-section>
		<!-- <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.deliverNo}}</text>
				<text class="uni-navigate-icon uni-icon">&#xe470;</text>
			</view>
			<view v-if="!isShowTips" style="text-align: center; margin-top: 10px;">
				<text class="example-info">数据总量：{{ total }}条，每页数据：{{ pageSize }}</text>
			</view>
			<uni-pagination :total="total" :current="current" :pageSize="pageSize" @change="pageChange" title="标题文字" v-if="!isShowTips" style="margin: 10px;"/>
		</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: '没有查询到校验单数据......',
				deliverNo : '',
				bomNo: '',
				isShowTips: true,
				deliverList:[],
				foucusIndex: 0,
				current: 1,
				total: 0,
				pageSize: 10
			}
		},
        onLoad() {
			this.queryFun()
			uni.$on('QueryInspect01', this.QueryInspect01)
        },
		onUnload() {
			uni.$off('QueryInspect01', this.QueryInspect01)
		},
		methods: {
			async queryFun() {
				uni.showLoading({
					title: "正在查询...",
					mask: true,
				})
				this.deliverList = []
				let parm = {
					url : '/business/SapDeliverRecord/QuerySapDeliverData',
					data: {
						DeliverNo: this.deliverNo,
						BomNo: this.bomNo,
						IsPrintQuery: false,
						PageNum: this.current,
						PageSize: this.pageSize
					},
					method: 'POST',
					isHaveToken : true
				}
				let retData = await getApp().RequestData(parm)
				if(retData.isSuccess) {
					if(retData.data.code == 200) {
						let len = retData.data.data.result.length
						this.total = retData.data.data.totalNum
						for (let i = 0; i < len;  i++) {
							this.deliverList.push({
									deliverid: i + 1,
									deliverNo: retData.data.data.result[i].deliverNo
							});
						}
						if(len > 0) {
							this.isShowTips = false
						}
						else {
							this.isShowTips = true
						}
					}
					else {
						this.isShowTips = true
					}
				}
				else {
					this.isShowTips = true
				}
				
				uni.hideLoading()
			},
			resetCondition() {
				this.deliverNo = ''
				this.bomNo = ''
				this.foucusIndex = 0
			},
			goDetailPage(item) {
				// let urlStr = '/pages/Inspect/inspectDtl?deliverNo=' + item.deliverNo;
				// let urlStr = '/pages/Inspect/inspectOperateNew?deliverNo=' + item.deliverNo;
				let urlStr = '/pages/Inspect/inspectDtlNew?deliverNo=' + item.deliverNo;
				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
				}
			},
			pageChange(e) {
				this.current = e.current
				this.queryFun()
			},
			QueryInspect01() {
				this.queryFun()
			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/uni-nvue.css';
	.uni-navigate-icon-01 {
		color: #999999;
		font-size: 14px;
		font-weight: normal;
	}
	.uni-navigate-item1 {
		align-items: center;
		background-color: #f5f5f5;
		border-top-style: solid;
		border-top-color: #f0f0f0;
		border-top-width: 1px;
		padding: 12px;
		cursor: pointer;
		margin-bottom: 1px;
	}
	.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>
