<template>
	<view class="mixWork">
		<view class="container">
			<view class="tabsList">
				<view class="tabsBox" v-for="(item,index) in tabsList" :key="index" :class="{active:tabsIndex == index}"
					@click="tabsClick(item,index)">{{item}}</view>
			</view>
			<!-- 人员信息列表 -->
			<view class="ul" v-if="tabsType == 1">
				<view class="li" v-for="(item,index) in peopleInfo" :key="index" @click="add('look',item,index)">
					<view class="title">航次：{{item.vvyName}}</view>
					<p>贸易类型：{{item.tradeTypeName}}</p>
					<p>进出口：{{item.importExportFlagName}}</p>
					<p>作业组数：{{item.workSuite}}</p>
					<p>单船人数：{{item.shipPerson}}</p>
					<p>状态：未上传</p>
				</view>
			</view>
			<!-- 工班信息列表 -->
			<view class="ul" v-if="tabsType == 2">
				<view class="li" v-for="(item,index) in shiftInfo" :key="index" @click="lookShift">
					<view class="title">航次：{{item.vvyName}}</view>
					<view class="shift" v-for="(item2,index2) in item.workMessageDetailReqDTOS" :key="index2">
						<p>{{item2.wkdId}}</p>
						<span>作业时间：{{item2.workTime}}</span>
					</view>
					<view class="state">状态：未上传</view>
				</view>
			</view>
			<view class="addBtn" @click="add('add')">+ 新增</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				shipInfo: [],
				tabsList: ["人员信息", "工班信息"],
				tabsType: 1, // 1是人员信息  2是工班信息
				tabsIndex: 0,
				// 人员信息列表
				peopleInfo: [],
				// 工班信息列表
				shiftInfo: [{
					vvyName: "511I",
					workMessageDetailReqDTOS: [{
						wkdId: "一工班",
						workTime: "2023/09/09 13:00:00"
					}, {
						wkdId: "二工班",
						workTime: "2023/09/09 13:00:00"
					}, {
						wkdId: "三工班",
						workTime: "2023/09/09 13:00:00"
					}]
				}, ]

			}
		},
		mounted() {
			this.shipInfo = uni.getStorageSync('shipInfo')
			this.peopleInfo = uni.getStorageSync('addPeopleArr');
		},
		methods: {
			tabsClick(item, index) {
				this.tabsIndex = index;
				if (item == "人员信息") {
					this.tabsType = 1;
				} else {
					this.tabsType = 2;
				}
			},
			add(state, item, index) {
				uni.setStorageSync('peopleRow', item);
				uni.setStorageSync('peopleRowIndex', index);
				let obj = {
					state: state
				}
				const params = encodeURIComponent(JSON.stringify(obj));
				if (this.tabsType == 1) {
					uni.navigateTo({
						url: `/pages/shipWork/peopleAdd?params=${params}`
					})
				} else {
					uni.navigateTo({
						url: `/pages/shipWork/shiftAdd?params=${params}`
					})
				}
			},
			lookShift() {
				uni.navigateTo({
					url: `/pages/shipWork/shiftDetails`
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.mixWork {
		.container {
			padding: 30px 20px;

			.tabsList {
				display: flex;
				justify-content: center;

				.tabsBox {
					width: 100px;
					height: 50px;
					border-radius: 4px;
					margin: 0px 10px;
					border: 1px solid #ccc;
					text-align: center;
					line-height: 50px;
				}

				.active {
					background: #2979ff;
					color: #fff;
				}
			}

			.ul {
				padding: 20px 0;

				.li {
					display: flex;
					justify-content: space-between;
					border-bottom: 1px solid #ccc;
					padding: 20px;

					.title {
						font-size: 16px;
						font-weight: bold;
						display: flex;
						flex-direction: column;
						justify-content: center;
					}

					.shift {
						p {
							font-size: 16px;
						}
					}

					.state {
						display: flex;
						flex-direction: column;
						justify-content: center;
					}
				}
			}

			.addBtn {
				position: fixed;
				right: 50px;
				bottom: 50px;
				width: 100px;
				height: 100px;
				border-radius: 50%;
				background-color: #2979ff;
				color: #fff;
				font-size: 24px;
				text-align: center;
				line-height: 100px;
				font-weight: bold;
			}
		}
	}
</style>