<template>
	<view>
		<view class="box">
			<view class="flex align-center justify-between" @click="getPost">
				<view class=" text-bold">岗位 </view>
				<view class="text-right flex align-center padding-tb-sm">
					<view class="">{{resumesPost?resumesPost:'请选择岗位'}}</view>
					<view class="margin-left-sm">
						<image src="../../static/images/my/right_icon.png" style="width: 12upx;height: 21upx;"></image>
					</view>
				</view>
			</view>
			<view class="margin-tb-sm" style="width: 100%;height: 1rpx;background: #F2F2F2;"></view>
			<view class="flex align-center justify-between" @click="getPostlist">
				<view class=" text-bold">专业</view>
				<view class="text-right flex align-center padding-tb-sm">
					<view>{{ rulePostName? rulePostName:'请选择专业'}}</view>
					<view class="margin-left-sm">
						<image src="../../static/images/my/right_icon.png" style="width: 12upx;height: 21upx;"></image>
					</view>
				</view>
			</view>

		</view>

		<!-- 求职岗位 -->
		<u-select v-model="postShow" :list="postlist" @confirm="postConfirm"></u-select>

		<!-- 求职岗位 -->
		<u-select v-model="show" :list="ErjiList" @confirm="postlistConfirm"></u-select>

		<view class="btn" @click="submit()">保存</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				resumesPost: '',
				rulePostId: '',
				postShow: false, //一级岗位
				postlist: [],
				ruleClassifyId: '',
				show: false, //二级岗位
				ErjiList: [],
				rulePostName:''
			}
		},
		onLoad() {

		},
		onShow() {

		},
		methods: {
			postConfirm(e) {
				this.resumesPost = e[0].label
				this.ruleClassifyId = e[0].value

			},
			getPost() {
				this.getClassifyList()
			},
			//获取求职岗位
			getClassifyList() {
				let data = {
					status: 1
				}
				this.$Request.get('/app/rule/selectRuleClassifyList', data).then(res => {
					if (res.code == 0) {
						var arr = []
						res.data.forEach((d, index) => {
							var data = {}
							data.label = d.ruleClassifyName
							data.value = d.ruleClassifyId
							arr.push(data)
						})
						this.postlist = arr
						this.postShow = true
					}
				})
			},
			postlistConfirm(e) {
				this.rulePostName = e[0].label
				this.rulePostId = e[0].value
			},
			getPostlist() {
				this.getPostList()
			},
			//获取岗位
			getPostList() {
				if (!this.ruleClassifyId) {
					uni.showToast({
						title: '请先选择岗位',
						icon: 'none',
						duration: 1000
					})
					return
				}
				let data = {
					ruleClassifyId: this.ruleClassifyId
				}
				this.$Request.post('/app/rule/selectRulePostList', data).then(res => {
					if (res.code == 0) {
						var arr = []
						res.data.forEach((d, index) => {
							var data = {}
							data.label = d.rulePostName
							data.value = d.rulePostId
							arr.push(data)
						})
						this.ErjiList = arr
						this.show = true
					}
				})
			},
			submit() {
				if (!this.resumesPost) {
					uni.showToast({
						title: '请选择岗位',
						icon: 'none',
						duration: 1000
					})
					return
				}
				if (!this.rulePostName) {
					uni.showToast({
						title: '请选择专业',
						icon: 'none',
						duration: 1000
					})
					return
				}
				let data = {
					resumesPost: this.resumesPost,
					rulePostId: this.rulePostId,
					rulePostName:this.rulePostName,
					ruleClassifyId:this.ruleClassifyId
				}
				uni.setStorageSync("resumes", data)
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="less">
	page {
		background: #F2F2F7;
	}

	.box {
		background: #FFFFFF;
		border-radius: 24upx;
		margin: 30upx;
		padding: 30upx;
	}

	.u-input__input {
		text-align: right !important;
	}

	.btn {
		background: #016BF6;
		border-radius: 10upx;
		text-align: center;
		// margin-top: 30upx;
		padding: 30upx 0upx;
		color: #FFFFFF;
		// font-weight: bold;
		// letter-spacing: 2rpx;
		margin: 30upx;
	}
</style>
