<template>
	<view>
		
		<view>
			<uni-row>
				<uni-col :span="18" style="padding-right: 5px; padding-top: 5px;">
					<view>
						<ftm-airplane @changevalue="changevalueAirplane" :zindex="ftmAirplanezindex" :tval="acNo">

						</ftm-airplane>
					</view>
				</uni-col>
				<uni-col :span="6">
					<button class="btn" type="primary" @click="check()">查询</button>
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="12" style="padding-right: 5px; padding-top: 5px;">
					<view >
						<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
					</view>
				</uni-col>
				<uni-col :span="12" style="padding-right: 5px; padding-top: 5px;">
					<view>
						<input class="uni_input" type="number" placeholder="DD/FC单号" placeholder-style="font-size:14px"
							v-model="deferId" />
					</view>
				</uni-col>
			</uni-row>

		</view>

		<view style="display: flex;" v-for="(item,index) in list" :key="index">
			<view style="width: 92%; margin-left: 10px; margin-bottom: 5px;font-size: 20rpx;" @click="gotoDetail(item)">
				<uni-row class="line_height" >
					<uni-col :span="12">
						<uni-col :span="10">
							<view>机号：</view>
						</uni-col>
						<uni-col :span="14">
							<view class="font_color">
								{{item.acNo}}
							</view>
						</uni-col>
					</uni-col>
					<uni-col :span="12">
						<uni-col :span="10">
							<view>DD单号：</view>
						</uni-col>
						<uni-col :span="14">
							<view class="font_color">
								{{item.deferId}}
							</view>
						</uni-col>
					</uni-col>
				</uni-row>
				<uni-row class="line_height">
					<uni-col :span="12">
						<uni-col :span="10">
							<view>
								类型：
							</view>
						</uni-col>
						<uni-col :span="14">
							<view>
								{{item.deferType}}
							</view>
						</uni-col>
					</uni-col>
					<uni-col :span="12">
						<uni-col :span="10">
							<view>
								航站：
							</view>
						</uni-col>
						<uni-col :span="14">
							<view>
								{{item.station}}
							</view>
						</uni-col>
					</uni-col>
				</uni-row>
				<uni-row class="line_height">
					<uni-col :span="12">
						<view>
							<uni-col :span="10">
								办理日期：
							</uni-col>
							<uni-col :span="14">
								{{item.creationDate}}
							</uni-col>
						</view>

					</uni-col>
					<uni-col :span="12">
						<view>
							<uni-col :span="10">
								到期日期：
							</uni-col>
							<uni-col :span="14">
								{{item.deadlineDate}}
							</uni-col>
						</view>
					</uni-col>
				</uni-row>
				<uni-row class="line_height">
					<uni-col :span="12">
						<view>
							<uni-col :span="16">
								<view>
									是否有运行限制：
								</view>
							</uni-col>
							<uni-col :span="8">
								<view>
									{{item.flLimited}}
								</view>
							</uni-col>
						</view>
					
					</uni-col>
					<uni-col :span="12">
						<view>
							<uni-col :span="10">
								保留原因：
							</uni-col>
							<uni-col :span="14">
								{{item.deferReason}}
							</uni-col>
						</view>
					</uni-col>				
				</uni-row>
				<uni-row class="line_height">
					<uni-col :span="24">
						<view>
							<uni-col :span="24">
								缺陷描述：{{item.description}}
							</uni-col>
						</view>
					</uni-col>						
				</uni-row>
				<uni-row>
					<view style="background-color: #cccccc; height: 1px;margin-top: 5px;"></view>
				</uni-row>
			</view>
			<view style="width: 8%;text-align: center; margin: auto;">
				<view>
					<uni-icons type="right" size="18" color="#000000"></uni-icons>
				</view>
			</view>

		</view>
		<view v-if="total">
			<paginations :pageNum="pageNum" :pageSize="pageSize" :total="total" :current= "current"   @changevalue ="changepaginations"></paginations>
		</view>
		


	</view>
</template>

<script>
	import {
		engDeDeferList,
		logins
	} from "@/utils/requestahm.js"
	import ftmAirplane from '@/pages/components/ahm/ftmAirplane.vue';
	import paginations from '@/pages/components/ahm/paginations.vue';
	export default {
		name: "ddfcInfoForms",
		data() {
			return {
				tval:[],//飞机号信息，回显用
				loding: false,
				ftmAirplanezindex: 999,
				list: [],
				acNo: [],
				deferId: '',
				deferType: '',
				param: {},
				//tailnumber: '',

				value: '0',
				range: [{
						value: 1,
						text: "DD"
					},
					{
						value: 2,
						text: "FC"
					},
				],

				current: 1,//当前页
				total: '', //总页数
				pageSize: 10, //每页条数
				pageNum: 1, //默认当前页
			};
		},
		props:{
			tailnumber:{
				type:String,
			}
		},
		components: {
			ftmAirplane,paginations
		},
		created() {
			
		},
		mounted() {
			this.acNo.push(this.tailnumber)
			this.init();
		},
		onLoad(option) {

		},
		methods: {
			//全局关闭下拉框
			closeAll(){
				uni.$emit('selectclose',{loing:false})
			},
			
			changepaginations(item){
				this.pageNum = item
				this.current = item
				this.init();
			},
			//监听页数变化
			changePage(e) {
			
			},
			//查询
			check() {
				if (!/^[0-9]*$/.test(this.deferId)) {
					uni.showToast({
						title: 'DD/FC单号：请输入数字',
						icon: 'none'
					})
					return;
				}
				this.closeAll()
				this.checkres()
			},
			change(e) {
				
				let i = e;
				this.deferType = ''
				if (i) {
					this.deferType = this.range[i - 1].text
				}
	

			},
			//机号选择
			changevalueAirplane(item) {
				this.acNo = item
				
			},
			//排序
			sortlist() {
				this.list.sort((a, b) => {
					return b.creationDate.toString().localeCompare(a.creationDate.toString())
				})
			},
			//详情信息
			gotoDetail(item) {
				uni.navigateTo({
					url: '/pages/modules/ahm/fraMonitoring/ddfcInfoDetail?item=' +
						encodeURIComponent(JSON.stringify(item))
				})
			},
			//查询dd/fc
			checkres(){
				//显示加载框
				uni.showLoading({
				    title: '加载中...'
				});
				this.loding = true,
				this.pageNum = 1;
				this.pageSize = 10;
				let param = {
					acNo: this.acNo,
					deferId: this.deferId,
					deferType: this.deferType,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}
				engDeDeferList(param).then(res => {
					uni.hideLoading();
					if (res.code == 200) {
						if (res.data) {
							this.list = res.data.list
							this.total = res.data.total
							this.pageNum = res.data.pageNum
							this.pageSize = res.data.pageSize
							this.current =res.data.pageNum
							this.sortlist()
							if (this.list.length == 0) {
								uni.showToast({
									title: '无DD/FF清单数据',
									icon: 'none'
								})
							}
						}
				
					}
				})
			},
			
			//初始化数据
			init() {
				//显示加载框
				uni.showLoading({
				    title: '加载中...'
				});
				let param = {
					acNo: this.acNo,
					deferId: this.deferId,
					deferType: this.deferType,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}
				engDeDeferList(param).then(res => {
					uni.hideLoading();
					if (res.code == 200) {
						if (res.data) {
							this.list = res.data.list
							this.total = res.data.total
							this.pageNum = res.data.pageNum
							this.pageSize = res.data.pageSize
							this.sortlist()
							if (this.list.length == 0) {
								uni.showToast({
									title: '无DD/FC清单数据',
									icon: 'none'
								})
							}
						}

					}
				})
			},
			//回退到上一页面
			clickLeft() {
				uni.navigateBack()
			},
			//进入详情
			flightDetail(v) {
			
				delete this.airPlane['nextFlightLegs']
				console.log("删除完字段的数据：***", this.airPlane);
				uni.navigateTo({
					url: '/pages/modules/ahm/fraMonitoring/flightDetail?item=' +
						encodeURIComponent(JSON.stringify(v)) + '&airplane=' + encodeURIComponent(JSON.stringify(
							this.airPlane))
				})
			}
		},

	};
</script>
<style scoped lang="less">
	.line_height{
		line-height:30rpx;
		font-size: 18rpx;
		padding-top: 5px;
	}
	.uni_input {
		font-size: 14px;
		height: 35px;
		line-height: 35px;
		border-radius: 5px;
		border: 1px solid #f0f0f0;
	}

	.btn {
		font-size: 14px;
		width: 70px;
		height: 30px;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 20rpx;
	}
</style>
