<template>
	<view class="padding-bottom-xl">
		<!-- <view class="text-white padding margin bg" v-if="form.isRecommend==2">
			<view class="flex align-center justify-between" style="color: red;">
				<view class=" text-bold">已录入人才库</view>
			</view>
		</view> -->
		<view class="text-white padding margin bg" v-if="form.status==3">
			<view class="flex align-center justify-between" style="color: red;">
				<view class=" text-bold">拒绝理由</view>
				<view class="text-right ">
					{{form.auditContent}}
				</view>
			</view>
		</view>
		<!-- <view>{{form.auditContent}}</view> -->
		<view class="text-white padding margin bg">
			<!-- <view class="flex align-center justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold">拒绝理由</view>
				<view class="text-right margin-bottom-sm">
					<u-input v-model="form.auditContent" disable placeholder="请输入真实姓名" placeholder-style="color:#999999;" />
				</view>
			</view> -->
			<view class="flex align-center justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">姓名</view>
				<view class="text-right margin-bottom-sm">
					<u-input :disabled="true" v-model="form.resumesName" placeholder="请输入真实姓名"
						placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">年龄</view>
				<view class="text-right flex align-center margin-tb-sm">
					<u-input :disabled="true" v-model="form.resumesAge" placeholder="请输入年龄"
						placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">家庭住址</view>
				<view class="text-right flex align-center margin-tb-sm">
					<u-input v-model="form.address" placeholder="请输入家庭住址" placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">性别</view>
				<view class="text-right flex align-center margin-tb-sm">
					<view>{{resumesSex?resumesSex:'请选择性别'}}</view>
					<!-- <u-input v-model="form.resumesSex" placeholder="请输入年龄" placeholder-style="color:#999999;" /> -->
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">手机号</view>
				<view class="text-right flex align-center margin-bottom-sm">
					<u-input :disabled="true" v-model="form.resumesPhone" placeholder="请输入手机号" type="number"
						maxlength="11" placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm  justify-between padding-bottom padding-top-sm"
				style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">学历</view>
				<view class="flex align-center ">
					<view>{{form.resumesEducation?form.resumesEducation:'请选择学历'}}</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="flex align-center margin-bottom-sm justify-between padding-bottom padding-top-sm"
				style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">婚姻状况</view>
				<view class=" flex align-center ">
					<view>{{form.resumesMarriage?form.resumesMarriage:'请选择婚姻状况'}}</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="flex align-center margin-bottom-sm justify-between padding-bottom-sm"
				style="border-bottom: 1rpx solid #F2F2F2;" @click="MoneyShow=true">
				<view class=" text-bold" style="width: 150rpx;">期望薪资</view>
				<view class=" flex align-center ">
					<u-input v-model="form.resumesCompensation" :disabled="true" type="number" placeholder="请输入期望薪资"
						placeholder-style="color:#999999;" :clearable="false" />
					<view class="margin-left-sm">
						<image src="../../static/images/my/right_icon.png" style="width: 12upx;height: 21upx;"></image>
					</view>
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">电子邮箱</view>
				<view class="text-right flex align-center margin-bottom-sm">
					<u-input :disabled="true" v-model="form.resumesEmail" placeholder="请输入电子邮箱"
						placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center margin-bottom-sm justify-between padding-bottom padding-top-sm"
				style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">工作经验</view>
				<view class=" flex align-center ">
					<view>{{form.resumesWorkExperience?form.resumesWorkExperience:'请选择工作经验'}}</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="flex align-center  justify-between" style="border-bottom: 1rpx solid #F2F2F2;">
				<view class=" text-bold" style="width: 150rpx;">毕业院校</view>
				<view class="text-right flex align-center ">
					<u-input v-model="form.school" :disabled="true" placeholder="请填写毕业院校"
						placeholder-style="color:#999999;" />
				</view>
			</view>
			<view class="flex align-center  justify-between">
				<view class=" text-bold" style="width: 150rpx;">所学专业</view>
				<view class="text-right flex align-center ">
					<u-input v-model="form.major" :disabled="true" placeholder="请输入所学专业"
						placeholder-style="color:#999999;" />
				</view>
			</view>
		</view>

		<view class="text-white padding margin bg radius ">
			<view>
				<view class="flex align-center justify-between">
					<view class=" text-bold" style="width: 150rpx;">求职岗位</view>
				</view>
				<view class="flex align-center label" v-if="form.resumesPost">
					<view v-if="form.resumesPost">{{form.resumesPost}}</view>
					<!-- <view v-if="form.rulePostName">-</view>
					<view v-if="form.rulePostName" class="">{{form.rulePostName}}</view> -->
				</view>
				<view class="margin-top-sm text-sm" style="color: #999999;" v-else>添加岗位会根据你的岗位需求为你推荐</view>
			</view>

			<view class="margin-tb-sm" style="width: 100%;height: 1rpx;background: #F2F2F2;"></view>
			<view>
				<view class="flex align-center justify-between">
					<view class=" text-bold" style="width: 150rpx;">工作经历</view>
				</view>
				<view class="margin-top-sm text-sm" style="color: #999999;" v-if="form.resumesCompanyList.length==0">
					添加工作经历向企业全面展示你的能力</view>
				<view v-for="(item,index) in form.resumesCompanyList" class="gzjl" :key="index" v-else>
					<view class="flex justify-between" style="color: #121212;">
						<view class="text-bold">
							{{item.resumesTitle}}
						</view>
					</view>
					<view>{{item.projectTitle}}</view>
					<view class="flex align-center margin-tb-xs" style="color: #999999;">
						<view>{{item.resumesTime}}</view>
						<view class="margin-left">{{item.resumesPost}}</view>
					</view>
					<view>{{item.resumesContent}}</view>
				</view>
			</view>
			<view class="margin-tb-sm" style="width: 100%;height: 1rpx;background: #F2F2F2;"></view>
			<view>
				<view class="flex align-center justify-between">
					<view class=" text-bold" style="width: 150rpx;">个人优势</view>
				</view>
				<view class=" padding-xs radius margin-top-sm" style="background: #F5F5F5;">
					<u-input :disabled="true" v-model="form.resumesDetails" type="textarea" height="300"
						placeholder="详细的个人信息与工作经历会让企业更加感兴趣" inputAlign="text-alight:left" />

				</view>

			</view>
			<view style="margin-top: 20rpx;">
				<view class="flex align-center justify-between">
					<view class=" text-bold">证书名称</view>
				</view>
				<view class="" style="margin-top: 10rpx;">
					<u-checkbox-group >
						<u-checkbox disabled v-model="item.checked" v-for="(item, index) in nameList"
							:key="index" :name="item.name">{{item.name}}</u-checkbox>
					</u-checkbox-group>
				</view>
			
			</view>
			<view class="margin-top" v-if="resumesImage.length>0">
				<view class=" text-bold" style="width: 150rpx;">资质证书<text class="text-df">（最多6张）</text></view>
				<view class="flex" style="overflow: hidden;flex-direction: initial;flex-wrap: wrap;">
					<view v-if="resumesImage.length">
						<view class="margin-top flex margin-right-sm flex-wrap">
							<view class="flex"
								style="width: 200rpx;height: 200rpx;margin-right: 5rpx;position: relative;margin-bottom: 5rpx;"
								v-for="(image,index) in resumesImage" :key="index">
								<image :src="image" style="width: 100%;height: 100%;"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>


		<view class="margin-lr">
			<u-button v-if="form.status==2 || form.status==3" @click="submit" class="margin-top"
				:custom-style="customStyle" shape="square" :hair-line="false">
				修改简历</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nameList: [],
				customStyle: {
					backgroundColor: '#016BF6',
					color: '#FFFFFF',
					border: 0
				},
				form: {
					resumesName: '', //姓名
					resumesAge: '', //年龄
					resumesPhone: '', //电话
					resumesEducation: '', //学历
					resumesMarriage: '', //婚姻状态
					resumesCompensation: '', //期望薪资
					resumesEmail: '', //电子邮箱
					resumesWorkExperience: '', //工作经验
					resumesIntention: '', //意向位置
					city: '', //意向位置
					resumesMajor: '', //专业
					resumesPost: '', //求职岗位
					resumesDetails: '', //自我介绍
					resumesCompanyList: [], //工作经历
					resumesWorkList: [], //项目经验
					resumesImage: [], //证书
					school: '',
					major:'', //所学专业
					rulePostId: '',
					rulePostName: '',
					resumesSex: '', //性别
				},
				resumesImage: [],
				Marriagelist: [],
				Intentionlist: [],
				//岗位
				postlist: [],
				Majorlist: [],
				resumesId: '',
				resumes: {},
				resumesSex: '',
				Sexlist: [{
						value: '1',
						label: '男'
					},
					{
						value: '2',
						label: '女'
					}
				],
			}
		},
		onLoad(option) {
			this.getbookName();
			if (option.resumesId) {
				this.resumesId = option.resumesId
				uni.setStorageSync("resumesId", option.resumesId)
				this.getDetails()
			}
		},
		onHide() {
			uni.removeStorageSync('resumesCompanyList')
			uni.removeStorageSync('resumesWorkList')
		},
		onUnload() {
			uni.removeStorageSync('resumesCompanyList')
			uni.removeStorageSync('resumesWorkList')
		},
		methods: {
			//证书名称
			getbookName() {
				this.$Request.get('/app/dict/list', {
					type: '证书名称'
				}).then(res => {
					if (res.code == 0) {
						let arr = []
						res.data.map(item=>{
							let obj = {
								name:item.code,
								checked:false,
								disabled:false
							}
							arr.push(obj)
						})
						this.nameList = arr
					}
				})
			},
			// 发布
			submit() {
				uni.navigateTo({
					url: '/my/publish/editor?resumesId=' + this.resumesId
				})

			},
			getDetails() {
				this.$Request.get('/app/resumes/selectResumesByUserId').then(res => {
					if (res.code == 0) {
						this.form = res.data
						if (this.form.resumesSex == 1) {
							this.form.resumesSex = 1
							this.resumesSex = '男'
						} else {
							this.form.resumesSex = 2
							this.resumesSex = '女'
						}
						if (res.data.resumesImage && res.data.resumesImage != '') {
							this.resumesImage = res.data.resumesImage.split(',')
						}else{
							this.resumesImage = []
						}

						//初始化为对象否则会出现无法在字符串上创建属性的错误（原因是在onshow中有赋值）
						// this.resumes = {}
						// this.resumes.rulePostId = res.data.rulePostId
						// this.resumes.resumesPost = res.data.resumesPost
						// this.resumes.rulePostName = res.data.rulePostName
						this.form.resumesPost = res.data.resumesPost
						this.form.ruleClassifyId = res.data.ruleClassifyId
						uni.setStorageSync("resumesWorkList", this.form.resumesWorkList)
						uni.setStorageSync("resumesCompanyList", this.form.resumesCompanyList)
						//证书名称回显
						if(res.data.resumesImageName){
							res.data.resumesImageName.split(',').map(item=>{
								this.nameList.map(re=>{
									if(item===re.name){
										re.checked = true
									}
								})
								
							})
						}
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}

	.gzjl {
		width: 100%;
		background-color: rgb(247, 247, 247);
		border-radius: 10rpx;
		margin-top: 10rpx;
		padding: 25rpx;
	}

	.bg {
		background-color: #FFFFFF;
		border-radius: 24upx;
	}

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

	.label {
		background: #DDFFF7;
		border-radius: 4upx;
		color: #016BF6;
		display: inline-flex;
		padding: 14upx 23upx;
		margin-top: 20rpx;
	}
</style>
