update-education.vue 4.7 KB
<template>
	<view style=" width: 100%;height: 100%; display: flex;background-color: #F7F7F7;"  :style="vuex_theme">
		<view class="wrap_box">
			<view style="padding: 0 20rpx;">
				<u-form :model="form" :error-type="errorType" ref="uForm">
					<c-input-item label="学校名称" type="text1" name="school" v-model="form.school" :rightIcon="false">
					</c-input-item>
					<c-input-item label="专业名称" type="text1" name="speciality"	v-model="form.speciality" :rightIcon="false">
					</c-input-item>
					<c-input-item label="入学日期" type="date3" name="edu_start_time" v-model="form.edu_start_time"
						:rightIcon="true">
					</c-input-item>
					<c-input-item label="毕业日期" type="date3" name="edu_end_time" v-model="form.edu_end_time"
						:rightIcon="true">
					</c-input-item>
				</u-form>
			</view>
		</view>
		<view class="footer">
			<view style="width: 100%;height: 1rpx;border: 1rpx solid #f7f7f7;"></view>
			<view style="padding: 20rpx 40rpx">
				<view class="confirm" @click="confirm">确认</view>
				<view v-if="index!=-1" class="del" @click="goDel">删除</view>
				<view v-else style="height: 50rpx;width: 100%;"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index:-1,
				eduObj:{},
				form: {
					edu_start_time: "",
					edu_end_time: "",
					speciality: '',
					school: ''
				},
			}
		},
		
		onLoad(option) {
			console.log(option)
			if (option.index && option.eduObj) {
				this.index = option.index
				this.eduObj = JSON.parse(option.eduObj)
				this.form = this.eduObj
			}
		},
		
		methods: {
			timeFormat(value, format = 'yyyy-mm-dd') {
				return this.$u.timeFormat(value, format)
			},
			
			goDel() {
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2];
				
				if(prevPage.$vm.edu_exps&&prevPage.$vm.edu_exps.length>0&&this.index>-1){
					let array = []
					array=prevPage.$vm.edu_exps.filter((item,index)=>{
						if (this.index !=index ) {
							return item
						}
					})
					prevPage.$vm.edu_exps = array
				}
				
				prevPage.$vm.detailObj.edu_exps = prevPage.$vm.edu_exps
				console.log("del",prevPage.$vm.detailObj.edu_exps)
				
				uni.navigateBack({
					delta: 1
				})
			},
			
			confirm(){
				console.log("submit--",this.form)
				if (this.form.school && this.form.speciality && this.form.edu_end_time) {
					if(this.form.edu_end_time<this.form.edu_start_time){
						uni.showToast({
							title: "日期选择错误",
							icon:'none'
						})
						return;
					}
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 2];
					this.eduObj.school = this.form.school
					this.eduObj.speciality = this.form.speciality
					this.eduObj.edu_start_time = this.form.edu_start_time/1000
					this.eduObj.edu_end_time = this.form.edu_end_time/1000
				
					if(prevPage.$vm.edu_exps&&prevPage.$vm.edu_exps.length>0&&this.index>-1){//编辑
						let array = []
						array=prevPage.$vm.edu_exps.map((item,index)=>{
							if (this.index ==index ) {
								return this.eduObj
							}else{
								return item
							}
						})
						prevPage.$vm.edu_exps = array
					}else{//添加
						prevPage.$vm.edu_exps.push(this.eduObj)
					}
					prevPage.$vm.detailObj.edu_exps = prevPage.$vm.edu_exps
					
					console.log("confirm2", prevPage.$vm.detailObj.edu_exps)
					
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.showToast({
						title: "请完善教育经历",
						icon:"none"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap_box {
		padding: 40rpx;
		background-color: #fff;
		margin: 20rpx 20rpx 0 20rpx;
		width: 100%;

		.text_black_30 {
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #000000;
		}

		.text_gray_26 {
			font-size: 26rpx;
			font-family: PingFangSC-Light, PingFang SC;
			font-weight: 300;
			color: rgba(0, 0, 0, 0.65);
			margin-top: 16rpx;
		}

		.text_gray_30 {
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.45);
		}
	}

	.footer {
		width: 100%;
		background-color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 99;
	
		.del {
			width: 100%;
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.65);
			padding: 24rpx;
			text-align: center;
		}
	
		.confirm {
			width: 100%;
			background: linear-gradient(180deg, var(--primary-color000) 0%, var(--primary-color) 100%);
			box-shadow: 0px 2px 20px 0px var(--primary-color03);
			border-radius: 24px;
			padding: 24rpx;
			text-align: center;
			font-size: 34rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>