<template>
	<view class="index-page">
		<!-- 顶部 -->
		<view class="index-navbar">
			<view style="position: relative;height: 392rpx;">
				<image class="index-bg" src="@/static/images/bg.png" mode=""></image>
				<u-navbar bgColor='rgba(0,0,0,0)' placeholder @leftClick="return1">
				</u-navbar>
				<view class="header-down " :style="{marginTop:height+'rpx'}"
					style="padding: 28rpx 0 0 32rpx;box-sizing: border-box;">
					<view class="mingpianfont">
						工作经历
					</view>
					<view class="explain">
						<text>完善的工作经历会让HR和猎头更了解你</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 个人信息 -->
		<view class="personal" v-if="radiovalue1==2 &&job_experience3.length>0 ">
			<view class="" v-for="(item,index) in job_experience3" :key="index">
				<view class="body-input u-flex-col u-row-center ">
					<text class="input-title">公司名称</text>
					<u--input :value="item.company_name" customStyle="padding:0 !important" type="text"
						placeholder="请填写您的公司名称" border placeholderClass='input-style'
						v-model="job_experience3[index].company_name"></u--input>
				</view>
				<view class="body-input u-flex-col u-row-center" @click="tohangye(index)">
					<text class="input-title">公司行业</text>
					<view class="">
						<u--input :value="item.industry_name" :disabled="true" disabledColor="#fff"
							customStyle="padding:0 !important" type="text" placeholder="请选择您的公司行业" border
							placeholderClass='input-style' suffixIcon="arrow-right"
							suffixIconStyle="font-size: 32rpx;font-weight: 400;color: #CACACA;"
							v-model="job_experience3[index].industry_name"></u--input>
					</view>
				</view>
				<view class="body-input u-flex-col u-row-center">
					<text class="input-title">所属部门</text>
					<u--input :value="department" disabledColor="#fff" customStyle="padding:0 !important" type="text"
						placeholder="请填写您的的所属部门" border placeholderClass='input-style'
						v-model="job_experience3[index].department"></u--input>
				</view>
				<view class="body-input u-flex-col u-row-center">
					<text class="input-title">职业名称</text>
					<u--input :value="job_name" disabledColor="#fff" customStyle="padding:0 !important" type="text"
						placeholder="请填写您的职业名称" border placeholderClass='input-style'
						v-model="job_experience3[index].job_name"></u--input>
				</view>
				<view class="body-input u-flex-col u-row-center">
					<text class="input-title">在职时间</text>
					<view class="u-flex u-row-between">
						<view class="" @click="entryShow = true">
							<u--input :value="start_time" :disabled="true" disabledColor="#fff"
								customStyle="padding:0 !important" type="text" placeholder="入职时间" border
								placeholderClass='input-style' v-model="job_experience3[index].start_time"></u--input>
						</view>
						<view class="">-</view>
						<view class="" @click="dimissionShow = true">
							<u--input :value="item.end_time" :disabled="true" disabledColor="#fff"
								customStyle="padding:0 !important" type="text" placeholder="离职时间" inputAlign="center"
								border placeholderClass='input-style'
								v-model="job_experience3[index].end_time"></u--input>
						</view>
					</view>
				</view>
				<view class="body-input u-flex-col u-row-center">
					<text class="input-title">离职原因</text>
					<u--input :value="level_reason" disabledColor="#fff" customStyle="padding:0 !important" type="text"
						placeholder="请填写离职原因" border placeholderClass='input-style'
						v-model="job_experience3[index].level_reason"></u--input>
				</view>
				<view class="body-input u-flex-col u-row-center" @click="toworktion">
					<text class="input-title">工作内容</text>
					<u--input :disabled="true" :value="item.work_content" customStyle="padding:0 !important" type="text"
						placeholder="请填写工作内容" border placeholderClass='input-style'
						v-model="job_experience3[index].work_content"></u--input>
				</view>
			</view>
			<view class="button" @click="next">
				下一步
			</view>
		</view>
		<view class="personal" v-else>
			<view class="body-input u-flex-col u-row-center ">
				<text class="input-title">公司名称</text>
				<u--input customStyle="padding:0 !important" type="text" placeholder="请填写您的公司名称" border
					placeholderClass='input-style' v-model="job_experience.company_name"></u--input>
			</view>
			<view class="body-input u-flex-col u-row-center" @click="tohangye">
				<text class="input-title">公司行业</text>
				<view class="">
					<u--input :disabled="true" disabledColor="#fff" customStyle="padding:0 !important" type="text"
						placeholder="请选择您的公司行业" border placeholderClass='input-style' suffixIcon="arrow-right"
						suffixIconStyle="font-size: 32rpx;font-weight: 400;color: #CACACA;"
						v-model="job_experience.industry_name"></u--input>
				</view>
			</view>
			<view class="body-input u-flex-col u-row-center">
				<text class="input-title">所属部门</text>
				<u--input disabledColor="#fff" customStyle="padding:0 !important" type="text" placeholder="请填写您的的所属部门"
					border placeholderClass='input-style' v-model="job_experience.department"></u--input>
			</view>
			<view class="body-input u-flex-col u-row-center">
				<text class="input-title">职业名称</text>
				<u--input disabledColor="#fff" customStyle="padding:0 !important" type="text" placeholder="请填写您的职业名称"
					border placeholderClass='input-style' v-model="job_experience.job_name"></u--input>
			</view>
			<view class="body-input u-flex-col u-row-center">
				<text class="input-title">在职时间</text>
				<view class="u-flex u-row-between">
					<view class="" @click="entryShow = true">
						<u--input :disabled="true" disabledColor="#fff" customStyle="padding:0 !important" type="text"
							placeholder="入职时间" border placeholderClass='input-style'
							v-model="job_experience.start_time"></u--input>
					</view>
					<view class="">-</view>
					<view class="" @click="dimissionShow = true">
						<u--input :disabled="true" disabledColor="#fff" customStyle="padding:0 !important" type="text"
							placeholder="离职时间" inputAlign="center" border placeholderClass='input-style'
							v-model="job_experience.end_time"></u--input>
					</view>
				</view>
			</view>
			<view class="body-input u-flex-col u-row-center">
				<text class="input-title">离职原因</text>
				<u--input disabledColor="#fff" customStyle="padding:0 !important" type="text" placeholder="请填写离职原因"
					border placeholderClass='input-style' v-model="job_experience.level_reason"></u--input>
			</view>
			<view class="body-input u-flex-col u-row-center" @click="toworktion">
				<text class="input-title">工作内容</text>
				<u--input :disabled="true" disabledColor="#fff" customStyle="padding:0 !important" type="text" placeholder="请填写工作内容" border
					placeholderClass='input-style' v-model="job_experience.work_content"></u--input>
			</view>
			<view class="button" @click="next">
				下一步
			</view>
		</view>
		<!-- 选择器 -->
		<u-datetime-picker title="入职时间" :minDate="minDate1" @confirm="entryConfirm" :show="entryShow" mode="year-month"
			@cancel='entryShow = false'></u-datetime-picker>
		<u-datetime-picker title="离职时间" :minDate="minDate" @confirm="dimissionConfirm" :show="dimissionShow"
			mode="year-month" @cancel='dimissionShow = false'></u-datetime-picker>
	</view>
</template>

<script>
	import {
		get_category_industry,
		index
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				entryShow: false,
				dimissionShow: false,
				industryShow: false,
				minDate: "",
				radiovalue1: "",
				minDate1: "",
				job_experience3: [],
				job_experience: {
					industry_name: "", //公司行业名称
					industry_id: "", //公司行业id
					company_name: "", //公司名称
					start_time: "", //在职时间
					end_time: "", //离职时间
					department: "", //所属部门
					job_name: "",
					level_reason: "", //离职原因
					work_content: "", //工作内容
				}
			}
		},
		onLoad() {
			this.minDate = Number(new Date('2000-01-01'));
			this.minDate1 = Number(new Date('1980-01-01'));
			if (uni.getStorageSync("job_experience1")) {
				this.job_experience = uni.getStorageSync("job_experience1")
			}
			if (uni.getStorageSync("job_experience3")) {
				this.job_experience3 = uni.getStorageSync("job_experience3")
			}
			if (uni.getStorageSync("radiovalue1")) {
				this.radiovalue1 = uni.getStorageSync("radiovalue1")
			}
		},
		methods: {
			getdata(item) {
				console.log(item);
			},
			toworktion(index) {
				if (this.radiovalue1 == 2) {
					uni.navigateTo({
						url: '../pagesA/worktion?concent=' + this.job_experience[index].work_content,
						events:{
							todcp:res=>{
								this.job_experience[index].work_content = res
							}
						}
					})
				} else {
					uni.navigateTo({
						url: '../pagesA/worktion?concent=' + this.job_experience.work_content,
						events:{
							todcp:res=>{
								this.job_experience.work_content = res
							}
						}
					})
				}
			},
			tohangye(index) {
				uni.navigateTo({
					url: "../pagesA/change-hangye1",
					events: {
						changehangye: (res) => {
							// this.job_experience.industry_first = res[0].id
							this.job_experience.industry_id = res[1].id
							this.job_experience.industry_name = res[1].name
							if (this.radiovalue1 == 2) {
								this.job_experience3[index].industry_name = res[1].name
							}
						}
					}
				})
			},
			async entryConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				console.log(e.value);
				let timeValue = await timeFormat(e.value, 'yyyy-mm');
				this.job_experience.start_time = timeValue;
				this.entryShow = false
			},
			async dimissionConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				let timeValue = await timeFormat(e.value, 'yyyy-mm');
				this.job_experience.end_time = timeValue;
				this.dimissionShow = false
			},
			return1() {
				uni.navigateBack()
			},
			next() {
				if (this.radiovalue1 == 2) {
					var tongguo = true
					this.job_experience3.forEach((item) => {
						console.log('导入', item);
						for (var key in item) {
							console.log('key', key);
							console.log('key', item[key]);
							if (key == "company_name" && item[key] == "") {
								this.$u.toast("请填写公司名称")
								tongguo = false
								return
							}
							if (key == "industry_name" && !item[key]) {
								tongguo = false
								this.$u.toast("请选择您的公司行业")
								return
							}
							if (key == "department" && item[key] == "") {
								tongguo = false
								this.$u.toast("请填写您的所属部门")
								return
							}
							if (key == "job_name" && item[key] == "") {
								tongguo = false
								this.$u.toast("请填写您的职业名称")
								return
							}
							if (key == "start_time" && item[key] == "") {
								tongguo = false
								this.$u.toast("请选择入职时间")
								return
							}
							if (key == "end_time" && item[key] == "") {
								tongguo = false
								this.$u.toast("请选择离职时间")
								return
							}
							if (key == "level_reason" && item[key] == "") {
								tongguo = false
								this.$u.toast("请填写离职原因")
								return
							}
							if (key == "work_content" && item[key] == "") {
								tongguo = false
								this.$u.toast("请填写工作内容")
								return
							}
						}
					})
					if (tongguo) {
						uni.navigateTo({
							url: "/pagesA/Project "
						})
					}
				} else {

					if (!this.job_experience.company_name) {
						this.$u.toast("请填写公司名称")
						return
					}
					if (!this.job_experience.industry_name) {
						this.$u.toast("请选择您的公司行业")
						return
					}
					if (!this.job_experience.department) {
						this.$u.toast("请填写您的所属部门")
						return
					}
					if (!this.job_experience.job_name) {
						this.$u.toast("请填写您的职业名称")
						return
					}
					if (!this.job_experience.start_time) {
						this.$u.toast("请选择入职时间")
						return
					}
					if (!this.job_experience.end_time) {
						this.$u.toast("请选择离职时间")
						return
					}
					if (!this.job_experience.level_reason) {
						this.$u.toast("请填写离职原因")
						return
					}
					if (!this.job_experience.work_content) {
						this.$u.toast("请填写工作内容")
						return
					}
					uni.navigateTo({
						url: "/pagesA/Project "
					})
				}
				let pre = "job_experience"
				let nObj = Object.keys(this.job_experience).reduce((a, c) => (a[`${pre}.${c}`] = this.job_experience[c],
					a), {});
				uni.setStorageSync("job_experience", nObj)
				uni.setStorageSync("job_experience1", this.job_experience)
				uni.setStorageSync("job_experience3", this.job_experience3)
				return

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F3F3F3;
	}

	.index-page {
		overflow: hidden;
		background-color: #fff;

		.mingpianfont {
			height: 50rpx;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 50rpx;
		}

		.explain {
			margin-top: 24rpx;
			width: 528rpx;
			height: 36rpx;
			font-size: 26rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 36rpx;
		}


		//个人信息
		.personal {
			width: 750rpx;
			background: #FFFFFF;
			border-radius: 28rpx 28rpx 0rpx 0rpx;
			margin-top: -40rpx;
			position: relative;
			z-index: 99;
			padding: 40rpx 32rpx 0;
			// margin-bottom: 60rpx;
			box-sizing: border-box;

			.body-input {
				height: 170rpx;
				border-bottom: 2rpx solid #F4F4F4;

				.input-title {
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #888888;
					margin-bottom: 20rpx;
					margin-top: 30rpx;
					box-sizing: border-box;
				}

				.input-style {
					font-size: 32rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #CACACA;
				}
			}

			.button {
				width: 686rpx;
				height: 88rpx !important;
				background: #0C66C2;
				border-radius: 12rpx;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 88rpx;
				margin: 10rpx 0 0rpx 0;
				display: flex;
				justify-content: center;
				margin-bottom: 30rpx;
				margin-top: 20rpx;
			}
		}

		.index-item {
			// width: 702rpx;
			// background: #FFFFFF;
			// border-radius: 20rpx;
			// margin: 20rpx auto;
			// padding: 0 20rpx 24rpx 10rpx;

			.item-down {
				text:first-child {
					font-size: 22rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #666666;
				}

				text:last-child {
					font-size: 22rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
				}
			}

			.item-gongsi {
				margin-bottom: 16rpx;

				.text2 {
					font-size: 24rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #666666;
				}

				.logo {
					width: 42rpx;
					height: 42rpx;
					border-radius: 10rpx;
					margin-right: 16rpx;
				}

				.text1 {
					max-width: 192rpx;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #444444;
					margin-right: 12rpx;
				}
			}

			.item-label {
				margin-bottom: 20rpx;

				text {
					margin-right: 16rpx;
					line-height: 46rpx;
					background: #F7F7F7;
					border-radius: 4rpx;
					padding: 0 14rpx;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #5F5F5F;
				}
			}

			.item-top {
				height: 88rpx;

				.text1 {
					font-size: 32rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
					margin-right: 16rpx;
				}

				.text2 {
					width: 50rpx;
					line-height: 32rpx;
					background: rgba(255, 83, 53, 0.1);
					border-radius: 4rpx;
					text-align: center;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FF5335;
					margin-right: 12rpx;
				}

				.text3 {
					width: 90rpx;
					line-height: 32rpx;
					background: #FFF2E8;
					border-radius: 4rpx;
					text-align: center;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FF8620;
					margin-right: 12rpx;
				}

				.text4 {
					line-height: 32rpx;
					background: #E6EFF8;
					border-radius: 4rpx;
					padding: 0 4rpx;
					text-align: center;
					font-size: 20rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #0C66C2;
				}

				.text5 {
					font-size: 32rpx;
					font-family: JDZhengHT-Regular, JDZhengHT;
					font-weight: 400;
					color: #0C66C2;
				}
			}
		}

		.index-navbar {
			position: sticky;
			top: 0;
			left: 0;
			width: 750rpx;
			z-index: 10;

			.header-down {
				height: 92rpx;
				padding: 20rpx 24rpx;
				box-sizing: border-box;

				.font {
					font-size: 40rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}

				.right-item {
					padding: 0 16rpx;
					height: 52rpx;
					background: #F3F3F3;
					border-radius: 4rpx;
					margin-left: 20rpx;

					.text {
						margin-right: 4rpx;
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #666666;
					}
				}

				.down-left {
					.text {
						margin-right: 4rpx;
						font-size: 26rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
				}
			}

			.index-bg {
				position: absolute;
				top: 0;
				left: 0;
				z-index: -1;
				width: 750rpx;
				height: 392rpx;
			}
		}

		.index-header {
			flex: 1;
			padding: 0 32rpx;
			height: 50rpx;

			.index-search {
				width: 200rpx;
				height: 64rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				padding: 0 28rpx;

				.text1 {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					margin-left: 16rpx;
				}
			}

			.index-tabs {
				text:first-child {
					font-size: 36rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #222222;
				}

				text:last-child {
					width: 76rpx;
					height: 12rpx;
					background: linear-gradient(270deg, #208EFF 0%, rgba(28, 159, 227, 0) 100%);
					margin-top: -20rpx;
					border-radius: 100rpx;
				}
			}
		}
	}

	::v-deep .u-navbar__content__left {
		padding: 0 !important;
	}

	::v-deep .u-subsection {
		width: 312rpx !important;
	}
</style>