<template>
	<view class="app">
		<head-info></head-info>
		<view class="container">
			<side-bar path='3'></side-bar>
			<view class="content">
				<view class="form">
					<view class="select">
						<uni-data-select v-model="pamValue" :localdata="pamList" @change="pamChange"
							placeholder="请选择港口">
						</uni-data-select>
					</view>
					<view class="select">
						<uni-data-select v-model="shipValue" :localdata="shipList" @change="shipChange"
							placeholder="请选择船名航次">
						</uni-data-select>
					</view>
					<van-button type="default" @click="search">搜索</van-button>
				</view>
				<view class="itemList">
					<view v-for="(item, index) in ltemList" :key="index" class="item" @click="toGo">
						<view class="title">
							<view class="name">
								{{item.spmName}}
							</view>
						</view>
						<view class="table">
							<view class="row">
								<view class="nitem">
									进口航次: <text>{{item.inVvyName}}</text>
								</view>
								<view class="nitem">
									进口贸易类型: <text>{{item.inTradeTypeName}}</text>
								</view>
							</view>
							<view class="row">
								<view class="nitem">
									出口航次: <text>{{item.outVvyName}}</text>
								</view>
								<view class="nitem">
									出口贸易类型: <text>{{item.outTradeTypeName}}</text>
								</view>
							</view>
							<view class="row">
								<view class="nitem">
									计划泊位: <text>{{item.planBerthageName}}</text>
								</view>
								<view class="nitem">
									实际泊位: <text>{{item.actualBerthageName}}</text>
								</view>
							</view>
							<view class="row">
								<view class="nitem">
									<text>{{item.uploadStatusDesc}}</text>
									<text>{{item.uploadTime}}</text>
								</view>
								<!-- <view class="nitem" v-if="item==1">
									<text class="green">●</text> 已下载
									<text>2023/09/21 12:00</text>
								</view>
								<view class="nitem" v-if="item==2">
									<text>●</text> 未下载
								</view>
								<view class="nitem" v-if="item==1">
									<text class="green">●</text> 已上传
									<text>2023/09/21 12:00</text>
								</view>
								<view class="nitem" v-if="item==2">
									<text>●</text> 未上传
								</view> -->
							</view>
							<view class="footer">
								<view class="fitem" @click="download(item)">
									下载
								</view>
								<view class="fitem" @click="upload">
									上传
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import SideBar from '@/components/sider-bar/slider-bar';
	import HeadInfo from '@/components/head-info/head-info';
	export default {
		data() {
			return {
				// 港口
				pamValue: "",
				pamList: [],
				// 船名航次
				shipValue: '',
				shipList: [],
				ltemList: [],
			}
		},
		onLoad() {

		},
		components: {
			SideBar,
			HeadInfo,
		},
		mounted() {
			this.getPam();
			this.getShip();
		},
		methods: {
			// 获取船的数据
			initData() {
				uni.request({
					url: this.$local + '/api/shipOperate/select?pamId=' + this.pamValue + "&vvyId=" + this
						.shipValue,
					header: {
						'Content-Type': 'application/json' //自定义请求头信息
					},
					method: 'GET', //请求方式，必须为大写
					success: (res) => {
						console.log('接口返回------', res);
						if (res.statusCode === 200) {
							this.ltemList = res.data.data.records
						}
					}
				})
			},
			// 获取港区下拉数据
			getPam() {
				uni.request({
					url: this.$local + '/api/shipOperate/queryPortArea',
					header: {
						'Content-Type': 'application/json' //自定义请求头信息
					},
					method: 'GET', //请求方式，必须为大写
					success: (res) => {
						console.log('接口返回------', res);
						if (res.statusCode === 200) {
							let arr = res.data.data;
							arr.forEach((v, index) => {
								this.pamList.push({
									text: v.pamName,
									value: v.pamId
								})
							})
						}
					}
				})
			},
			// 获取船名航次下拉数据
			getShip() {
				uni.request({
					url: this.$local + '/api/shipOperate/queryShipmentVoyageData?key=阳',
					header: {
						'Content-Type': 'application/json' //自定义请求头信息
					},
					method: 'GET', //请求方式，必须为大写
					success: (res) => {
						console.log('接口返回------', res);
						if (res.statusCode === 200) {
							// this.shipList = res.data.data
							let arr = res.data.data;
							arr.forEach((v, index) => {
								this.shipList.push({
									text: v.spmName,
									value: v.vvyId
								})
							})
						}
					}
				})
			},
			// 港区下拉
			pamChange(event) {},
			// 船名航次下拉
			shipChange(e) {},
			// 点击搜索
			search() {
				this.initData()
			},
			// 点击下载
			download(item) {
				let ids = [item.outVvyName, item.inVvyName]
				console.log(ids)
				uni.request({
					url: this.$local + '/api/shipOperate/download?vvyIds=' + ids,
					header: {
						'Content-Type': 'application/json' //自定义请求头信息
					},
					method: 'GET', //请求方式，必须为大写
					success: (res) => {
						console.log('接口返回------', res);
						if (res.statusCode === 200) {}
					}
				})
			},
			// 点击上传
			upload() {},
			toGo() {
				uni.navigateTo({
					url: `/pages/shipWork/documentList`
				})
			}
		}
	};
</script>

<style lang="less" scoped>
	.container {
		background-color: #f5f6fa;
		display: flex;
		min-height: calc(100vh - 44px - 40px);
	}

	.content {
		padding: 20px;
		min-height: calc(100vh - 44px - 40px);

		.form {
			display: flex;

			.select {
				width: 200px;
				margin-right: 20px;
			}

			.input {
				width: 200px;
				height: 35px;
				line-height: 35px;
				margin-left: 15px;
			}

			/deep/.van-button {
				height: 35px;
				line-height: 35px;
			}
		}

		.itemList {
			width: 100%;
			display: flex;
			justify-content: flex-start;
			flex-wrap: wrap;

			.item {
				width: 49%;
				margin-top: 15px;
				margin-right: 2%;
				border: 1px solid #c9cacb;

				.title {
					display: flex;
					justify-content: space-between;
					font-size: 21px;
					padding: 10px 20px;
					font-weight: 700;
				}

				.row {
					display: flex;
					justify-content: space-between;
					font-size: 18px;
					padding: 10px 20px;

					.nitem {
						width: 46%;

						.text {
							color: #929292;
						}
					}
				}

				.footer {
					display: flex;
					justify-content: space-between;
					height: 60px;
					line-height: 60px;
					font-size: 21px;
					background-color: #f7f9fa;
					color: #8d8f8f;

					.fitem {
						width: 50%;
						text-align: center;
					}
				}
			}

			.item:nth-child(2n) {
				margin-right: 0;
			}
		}
	}
</style>