update-education.vue
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<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>