update-experience.vue
8.4 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<template>
<view style=" width: 100%;height: 100%; display: flex;background-color: #F7F7F7;" :style="vuex_theme">
<view class="wrap_box">
<view>
<u-form :model="form" :error-type="errorType" ref="uForm">
<c-input-item label="公司名称" type="text1" name="company" v-model="form.company" :rightIcon="false">
</c-input-item>
<c-input-item label="职位名称" type="text1" name="job" v-model="form.job" :rightIcon="false">
</c-input-item>
<!-- <c-input-item label="工作起止时间" type="date2" name="job_start_time" v-model="form.job_start_time" :rightIcon="true">
</c-input-item> -->
<view class="event_box" style="margin: 30rpx 0;" @click="calendarPicker">
<text class="text1">工作起止日期</text>
<view class="" style="display: flex;margin-top: 40rpx; align-items: center;">
<view v-if='job_start_time' class="text2" style="text-align: center;" @click="showCalendar('start')">{{job_start_time}}</view>
<view v-else class="text3" @click="showCalendar('start')">请选择开始日期</view>
<view class="text1" style="flex: 1;text-align: center;">至</view>
<view v-if='job_end_time' class="text2" style="flex: 3;" @click="showCalendar('end')">{{job_end_time}}</view>
<view v-else class="text3" @click="showCalendar('end')">请选择结束日期</view>
</view>
</view>
<view style="width: 100%;height: 1rpx;background-color: ;"></view>
<view style="margin-top: 30rpx;">
<view class="text_gray_26">工作内容</view>
<view style="min-height: 300rpx;width: 100%;padding: 20rpx 0;">
<u-input v-model="form.job_content" type="textarea" :maxlength='maxLength'
placeholder="请输入内容" :custom-style="text_black_30" :placeholder-style="text_gray_30"/>
</view>
<!-- <view class="text_gray_30" style="text-align: right;">
{{form.job_content?form.job_content.length:0}}/{{maxLength}}
</view> -->
<view style="height: 2rpx;margin: 30rpx 0;background-color: #e5e5e5;"></view>
</view>
</u-form>
</view>
</view>
<!-- <u-calendar v-model="show" :mode="'range'" :active-bg-color="''" range-color=""
:btn-type="'success'" @change="change" :toolTip="'请选择工作起止时间'"></u-calendar> -->
<u-calendar v-model="show" :mode="mode" :active-bg-color="'var(--primary-color)'" range-color="var(--primary-color)"
:btn-type="'success'" @change="change">
<view slot="tooltip">
<view v-if="showBtn" class="btn_calendar" @click="setEndDate(data)">至今</view>
<view class="title">{{calendar_title}}</view>
</view>
</u-calendar>
<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 {
show: false,
maxLength: 300,
curLength: 0,
index: -1,
experienceObj: {},
job_start_time: "",
job_end_time: "",
form: {
company: "",
job_content: "",
job: "",
job_start_time: 0,
job_end_time:0,
},
mode:'date',
calendar_title:"",
showBtn:false
}
},
onLoad(option) {
console.log("option", option)
if (option.index && option.experienceObj) {
this.index = option.index
this.experienceObj = JSON.parse(option.experienceObj)
this.form = this.experienceObj
this.job_start_time = this.timeFormat(this.form.job_start_time)
this.job_end_time = this.form.job_end_time==0?"至今":this.timeFormat(this.form.job_end_time)
}
},
methods: {
timeFormat(value, format = 'yyyy-mm-dd') {
return this.$u.timeFormat(value, format)
},
showCalendar(type){
console.log(type)
this.show = true
this.showBtn = (type=='end'?true:false)
this.calendar_title = (type=='end'?'结束日期':'开始日期')
},
change(e) {
console.log(e);
if(this.showBtn){
this.job_end_time = e.result
this.form.job_end_time = (new Date(e.result)).getTime() / 1000;
}else{
this.job_start_time = e.result
this.form.job_start_time = (new Date(e.result)).getTime() / 1000;
}
this.show = false
},
calendarPicker() {
this.show = true
console.log("show--", this.show)
},
setEndDate(data){
console.log("至今..",data)
this.show = false
this.job_end_time = '至今'
this.form.job_end_time = 0
},
goDel() {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
console.log("del1",prevPage.$vm.work_exps,prevPage.$vm.detailObj.work_exps)
if(prevPage.$vm.work_exps&&prevPage.$vm.work_exps.length>0&&this.index>-1){
let array = []
array=prevPage.$vm.work_exps.filter((item,index)=>{
if (this.index !=index ) {
return item
}
})
prevPage.$vm.work_exps = array
}
prevPage.$vm.detailObj.work_exps = prevPage.$vm.work_exps
console.log("del2",prevPage.$vm.detailObj.work_exps)
uni.navigateBack({
delta: 1
})
},
confirm() {
console.log("confirm1", this.form)
if (this.form.company && this.form.job && this.form.job_content && this.form.job_start_time&& this.form.job_end_time>-1) {
if(this.form.job_end_time!=0&&this.form.job_end_time<this.form.job_start_time){
uni.showToast({
title: "工作起止日期错误",
icon:'none'
})
return;
}
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
this.experienceObj.company = this.form.company
this.experienceObj.job = this.form.job
this.experienceObj.job_content = this.form.job_content
this.experienceObj.job_start_time = this.form.job_start_time
this.experienceObj.job_end_time = this.form.job_end_time
if(prevPage.$vm.work_exps&&prevPage.$vm.work_exps.length>0&&this.index>-1){//编辑
let array = []
array=prevPage.$vm.work_exps.map((item,index)=>{
if (this.index ==index ) {
return this.experienceObj
}else{
return item
}
})
prevPage.$vm.work_exps = array
}else{//添加
prevPage.$vm.work_exps.push(this.experienceObj)
}
prevPage.$vm.detailObj.work_exps = prevPage.$vm.work_exps
console.log("confirm2", prevPage.$vm.detailObj.work_exps)
uni.navigateBack({
delta: 1
})
} else {
uni.showToast({
title: "请完善工作经历",
icon:'none'
})
}
}
}
}
</script>
<style lang="scss" scoped>
.wrap_box {
padding: 20rpx;
background-color: #fff;
margin: 20rpx 20rpx 0 20rpx;
width: 100%;
.text_black_30 {
font-size: 30rpx;
font-family:' PingFangSC-Regular, PingFang SC';
font-weight: 500;
color: #000000;
}
.text_gray_26 {
font-size: 26rpx;
line-height: 26rpx;
color: #000000;
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);
}
}
.event_box {
display: flex;
flex-direction: column;
width: 100%;
.text1 {
font-size: 26rpx;
line-height: 26rpx;
color: #000000;
}
.text2 {
font-size: 30rpx;
font-family:' PingFangSC-Regular, PingFang SC';
font-weight: 500;
color: #000000;
line-height: 30rpx;
}
.text3{
font-size: 30rpx;
color:rgba(0,0,0,0.45);
line-height: 30rpx;
}
}
.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;
}
}
.btn_calendar{
position: absolute;
width: fit-content;
padding: 20rpx 40rpx;
text-align: left;
font-size: 34rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 400;
color: var(--primary-color);
}
.title{
color: #333;
text-align: center;
padding: 20rpx 0 0 0;
}
</style>