<template>
	<view class="personal">
		<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.company_name"></u--input>
		</view>
		<view class="body-input u-flex-col u-row-center" @click="tohangye">
			<text class="input-title">公司行业</text>
			<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"></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.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" style="margin-top: 20rpx;">
				<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" >
			<text class="input-title">工作内容</text>
			<u--input  disabledColor="#fff" customStyle="padding:0 !important" type="text"
				placeholder="请填写您的工作内容" border placeholderClass='input-style'
				v-model="job_experience.work_content"></u--input>
		</view>
		<view class="body-input u-flex-col u-row-center">
			<view class="">选填内容</view>
			<text class="input-title">下属人数</text>
			<u--input disabledColor="#fff" customStyle="padding:0 !important" type="text" placeholder="请填写(选填)" border
				placeholderClass='input-style' v-model="job_experience.underling_count"></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.report_to"></u--input>
		</view>
		<view class="u-flex u-row-between">
			<view class="button1">
				删除
			</view>
			<view class="button" @click="next">
				保存
			</view>
		</view>
		<u-datetime-picker title="入职时间" :minDate="minDate1" @confirm="entryConfirm" :show="entryShow" mode="date"
			@cancel='entryShow = false'></u-datetime-picker>
		<u-datetime-picker title="离职时间" :minDate="minDate" @confirm="dimissionConfirm" :show="dimissionShow" mode="date"
			@cancel='dimissionShow = false'></u-datetime-picker>
	</view>
</template>

<script setup>
	import {
		get_category_industry
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				entryShow: false,
				dimissionShow: false,
				industryShow: false,
				minDate: "",
				minDate1: "",
				job_experience: {
					industry: "", //公司行业名称
					industry_id: "", //公司行业id
					company_name: "", //公司名称
					start_time: "", //在职时间
					end_time: "", //离职时间
					department: "", //所属部门
					job_name: "",//工作名称
					level_reason: "", //离职原因
					work_content: "", //工作内容
					underling_count:"",
					report_to:""
				}
			}
		},
		onLoad(opsition) {
			this.minDate = Number(new Date('2000-01-01'));
			this.minDate1 = Number(new Date('1980-01-01'));
		},
		methods: {
			getdata(item) {
				console.log(item);
			},
			tohangye() {
				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 = res[1].name
						}
					}
				})
			},
			async entryConfirm(e) {
				const timeFormat = uni.$u.timeFormat;
				console.log(e.value);
				let timeValue = await timeFormat(e.value, 'yyyy-mm-dd');
				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-dd');
				this.job_experience.end_time = timeValue;
				this.dimissionShow = false
			},
			return1() {
				uni.navigateBack()
			},
			next(){
				if (!this.job_experience.company_name) {
					this.$u.toast("请填写公司名称")
					return
				}
				if (!this.job_experience.industry) {
					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
				}
				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)
				console.log(this);
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('work', nObj);
				uni.navigateBack()
			}
		}
	}
</script>


<style lang="scss">
	.button1 {
		width: 256rpx;
		background: #F3F3F3;
		border-radius: 12rpx;
		margin-right: 24rpx;
		padding: 20rpx 50rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		text-align: center;
		height: 88rpx !important;
		box-sizing: border-box;
	}

	.btn {
		background: #0C66C2;
		border-radius: 16rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		width: 310rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		margin-top: 24rpx;
	}

	//个人信息
	.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;

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

		.titleb {
			font-size: 26rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #777777;
			margin-top: 20rpx;
		}

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

			.input-title {
				font-size: 26rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #888888;
				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;
			text-align: center;
		}
	}
</style>