<!--
 * @Date: 2024-10-08 14:29:36
 * @LastEditors: shirlwang
 * @LastEditTime: 2025-12-16 17:50:03
-->
<template>
	<view class="page" style="background-image: url('../../../packageRc/static/pageBg.png');">
		<!-- 需求新增 -->
		<view class="tab-list" v-if="showTab != 1">
			<view class="tab" :class="{active: activeType == 1}" @click="canChangeType ? changeType(1, options) : ''">求职<br>需求
			</view>
			<view class="tab" :class="{active: activeType == 3}" @click="canChangeType ? changeType(3, options) : ''">创业<br>需求
			</view>
			<view class="tab" :class="{active: activeType == 4}" @click="canChangeType ? changeType(4, options) : ''">培训<br>需求
			</view>
			<view class="tab" :class="{active: activeType == 5}" @click="canChangeType ? changeType(5, options) : ''">其他<br>需求
			</view>
		</view>
		<jobService v-if="activeType == 1" :needId="id" :name="name" ref="type1" />
		<entrepreneurshipService :needId="id" :name="name" v-if="activeType == 3" ref="type3" />
		<trainService v-if="activeType == 4" :needId="id" :name="name" ref="type4" />
		<otherService v-if="activeType == 5" :needId="id" :name="name" ref="type5" />
		<!-- 社区端 - 显示隐藏退出组件 -->
		<!-- <exitPopup /> -->
	</view>
</template>

<script>
	import jobService from './components/jobService.vue';
	import entrepreneurshipService from './components/entrepreneurshipService.vue';
	import trainService from './components/trainService.vue';
	import otherService from './components/otherService.vue';
	export default {
		components: {
			jobService,
			entrepreneurshipService,
			trainService,
			otherService,
		},
		data() {
			return {
				isAdd: true,
				activeType: 1,
				canChangeType: true,
				id: '',
				name:"",
				options: {}
			}
		},
		onLoad(options) {
			this.showTab = options.showTab
			this.id = options.id
			this.name = options.name
			this.options=options
			if (options.id && options.type) {
				this.isAdd = false
				this.activeType = options.type
				this.canChangeType = false;
				this.$nextTick(() => {
					this.$refs['type' + options.type].getDetail(options.id)
				})
			} else {
				// 添加需求的时候根据传入的类型 判断对应的表单
				this.changeType(options.activeType || 1, options)
			}

		},
		methods: {
			changeType(type, options) {
				this.activeType = type
				this.$nextTick(() => {
					this.$refs['type' + type].addOne(options.userId)
				})
			},
			goBack() {
				uni.navigateBack();
			},
		}
	}
</script>

<style lang="scss">
@import "/packageRc/static/scss/index.scss";
	.page {
		background-color: #f4f4f4 !important;
		height: 100vh;
		background-repeat: no-repeat;
		padding-top: 32rpx;
		background-size: 100% auto;
	}

	.button-area {
		padding: 24rpx 32rpx 68rpx;
		background: #fff;
		display: flex;
		box-sizing: border-box;
		margin-top: 40rpx;
		border-radius: 16px 16px 0px 0px;
		box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);

		.btn {
			line-height: 72rpx;
			width: 176rpx;
			margin-right: 16rpx;
			font-size: 28rpx;
			border: 1px solid #B8C5D4;
			color: #282828;
			text-align: center;
			border-radius: 8rpx;
		}

		.reset {
			background: #DCE2E9;
		}

		.save {
			background: linear-gradient(103deg, #1D64CF 0%, #1590D4 99%);
			color: #fff;
			border: 0;
			flex-grow: 1;
		}
	}

	.noValue {
		color: rgb(192, 196, 204);
	}

	.disabledLine {
		background: rgb(245, 247, 250);
		cursor: not-allowed;
	}

	.tab-list {
		display: flex;
		width: calc(100% - 64rpx);
		margin: 16rpx auto 30rpx;
		text-align: center;
		border-radius: 16rpx;
		background: #fff;
		;

		.tab {
			width: 25%;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 4rpx solid #FFFFFF;
			background: #fff;
			border-radius: 16rpx;
			font-size: 28rpx;
			color: #878787;
			height: 106rpx;

			&.active {
				background: #1A62CE;
				color: #fff;
				position: relative;
				font-weight: bold;

				&::before {
					content: '';
					position: absolute;
					bottom: -13rpx;
					border-top: 14rpx solid #1A62CE;
					border-left: 12rpx solid transparent;
					border-right: 12rpx solid transparent;
					left: calc(50% - 7rpx);
					z-index: 2;
				}

				&::after {
					content: '';
					position: absolute;
					z-index: 1;
					bottom: -18rpx;
					border-top: 14rpx solid #fff;
					border-left: 12rpx solid transparent;
					border-right: 12rpx solid transparent;
					left: calc(50% - 7rpx);
				}
			}
		}
	}
</style>
