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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<template>
<div>
<a-form-model ref="form" :model="formModel">
<a-row>
<a-col :span="24" style="border-top: 0px; text-align: center">
<div class="main-title">
<span>申报人才简历</span>
</div>
</a-col>
</a-row>
<a-row type="flex" class="row_center">
<a-col :span="4" class="bg-gray">
<div class="special-middle">
<span>学历(高中以上)</span>
</div>
</a-col>
<a-col :span="20">
<!-- 学历表格 -->
<a-row type="flex" class="row_center">
<a-col :span="8" class="bg-gray">
<div class="special-middle">
<div>起止日期</div>
</div>
</a-col>
<a-col :span="6" class="bg-gray">
<div class="special-middle">
<div>学校</div>
</div>
</a-col>
<a-col :span="8" class="bg-gray">
<div class="special-middle">
<div>备注(限20字)</div>
</div>
</a-col>
<a-col :span="2" class="bg-gray">
<div class="special-middle">
<div>操作</div>
</div>
</a-col>
</a-row>
<a-row v-for="(item, index) in educationList" :key="'educationList'+index" type="flex" class="row_center">
<a-col :span="8">
<a-form-model-item :prop="`educationList.${index}.resumeRange`" :rules="{ required: true, validator: checkDateRange, trigger: 'blur' }">
<a-range-picker v-model="item.resumeRange" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD HH:mm:ss" @change="(dates, dateStrings) => educationDateChange(dates, dateStrings, index)" :placeholder="['开始时间', '结束时间']" />
</a-form-model-item>
</a-col>
<a-col :span="6">
<a-form-model-item :prop="`educationList.${index}.orgName`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.orgName" :maxLength="100" placeholder="学校" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="8">
<a-form-model-item :prop="`educationList.${index}.resumeRemark`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.resumeRemark" :maxLength="50" placeholder="备注" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="2">
<div class="special-middle">
<a-popconfirm title="确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="deleteEducationArray(item)">
<a-button type="link" size="small">删除</a-button>
</a-popconfirm>
</div>
</a-col>
</a-row>
<a-row type="flex">
<a-col :span="24" style="text-align: center">
<div class="special-middle">
<a-button type="dashed" style="width: 20%" @click="addEducationArray()">
<a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
</a-button>
</div>
</a-col>
</a-row>
</a-col>
</a-row>
<a-row type="flex" class="row_center">
<a-col :span="4" class="bg-gray">
<div class="special-middle">
<span>研修经历</span>
</div>
</a-col>
<a-col :span="20">
<!-- 研修经历表格 -->
<a-row type="flex" class="row_center">
<a-col :span="8" class="bg-gray">
<div class="special-middle">
<div>起止日期</div>
</div>
</a-col>
<a-col :span="6" class="bg-gray">
<div class="special-middle">
<div>机构(国别)</div>
</div>
</a-col>
<a-col :span="8" class="bg-gray">
<div class="special-middle">
<div>研修内容(限20字)</div>
</div>
</a-col>
<a-col :span="2" class="bg-gray">
<div class="special-middle">
<div>操作</div>
</div>
</a-col>
</a-row>
<a-row v-for="(item, index) in studyList" :key="'studyList'+index" type="flex" class="row_center">
<a-col :span="8">
<a-form-model-item :prop="`studyList[${index}].resumeRange`" :rules="{ required: true, validator: checkDateRange, trigger: 'blur' }">
<a-range-picker v-model="item.resumeRange" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD HH:mm:ss" @change="(dates, dateStrings) => studyDateChange(dates, dateStrings, index)" :placeholder="['开始时间', '结束时间']" />
</a-form-model-item>
</a-col>
<a-col :span="6">
<a-form-model-item :prop="`studyList[${index}].orgName`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.orgName" :maxLength="100" placeholder="机构" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="8">
<a-form-model-item :prop="`studyList[${index}].resumeRemark`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.resumeRemark" :maxLength="50" placeholder="研修内容" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="2">
<div class="special-middle">
<a-popconfirm title="确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="deleteStudyArray(item)">
<a-button type="link" size="small">删除</a-button>
</a-popconfirm>
</div>
</a-col>
</a-row>
<a-row type="flex">
<a-col :span="24" style="text-align: center">
<div class="special-middle">
<a-button type="dashed" style="width: 20%" @click="addStudyArray()">
<a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
</a-button>
</div>
</a-col>
</a-row>
</a-col>
</a-row>
<a-row type="flex" class="row_center">
<a-col :span="4" class="bg-gray">
<div class="special-middle">
<span>工作经历</span>
</div>
</a-col>
<a-col :span="20">
<!-- 工作经历表格 -->
<a-row type="flex" class="row_center">
<a-col :span="6" class="bg-gray">
<div class="special-middle">
<div>起止日期</div>
</div>
</a-col>
<a-col :span="5" class="bg-gray">
<div class="special-middle">
<div>机构</div>
</div>
</a-col>
<a-col :span="4" class="bg-gray">
<div class="special-middle">
<div>职务</div>
</div>
</a-col>
<a-col :span="7" class="bg-gray">
<div class="special-middle">
<div>承担的主要工作(限20字)</div>
</div>
</a-col>
<a-col :span="2" class="bg-gray">
<div class="special-middle">
<div>操作</div>
</div>
</a-col>
</a-row>
<a-row v-for="(item, index) in workList" :key="'workList'+index" type="flex" class="row_center">
<a-col :span="6">
<a-form-model-item :prop="`workList[${index}].resumeRange`" :rules="{ required: true, validator: checkDateRange, trigger: 'blur' }">
<a-range-picker v-model="item.resumeRange" format="YYYY-MM-DD" valueFormat="YYYY-MM-DD HH:mm:ss" @change="(dates, dateStrings) => workDateChange(dates, dateStrings, index)" :placeholder="['开始时间', '结束时间']" />
</a-form-model-item>
</a-col>
<a-col :span="5">
<a-form-model-item :prop="`workList[${index}].orgName`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.orgName" :maxLength="100" placeholder="机构" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="4">
<a-form-model-item :prop="`workList[${index}].positionName`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.positionName" :maxLength="50" placeholder="职务" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="7">
<a-form-model-item :prop="`workList[${index}].resumeRemark`" :rules="{ required: true, message: '*', trigger: 'blur',}">
<a-input v-model="item.resumeRemark" :maxLength="50" placeholder="工作内容" style="width:85%" />
</a-form-model-item>
</a-col>
<a-col :span="2">
<div class="special-middle">
<a-popconfirm title="确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="deleteWorkArray(item)">
<a-button type="link" size="small">删除</a-button>
</a-popconfirm>
</div>
</a-col>
</a-row>
<a-row type="flex">
<a-col :span="24" style="text-align: center">
<div class="special-middle">
<a-button type="dashed" style="width: 20%" @click="addWorkArray()">
<a-icon type="plus" /> 添加 <span style="color:red;margin-left:10px"></span>
</a-button>
</div>
</a-col>
</a-row>
</a-col>
</a-row>
</a-form-model>
</div>
</template>
<script>
import moment from 'moment'
import { isEmptyParams, checkDateRange } from '@/views/utils/common'
//学历
const Education = { id: null, talentId: null, resumeType: 'e76f5097-fe28-11ef-b6cb-0c42a1380f01', resumeStart: null, resumeEnd: null, orgName: null, positionName: null, resumeRemark: null, showIndex: null, resumeRange: [] }
//研修经历
const Study = { id: null, talentId: null, resumeType: 'e76f5097-fe28-11ef-b6cb-0c42a1380f02', resumeStart: null, resumeEnd: null, orgName: null, positionName: null, resumeRemark: null, showIndex: null, resumeRange: [] }
//工作经历
const Work = { id: null, talentId: null, resumeType: 'e76f5097-fe28-11ef-b6cb-0c42a1380f03', resumeStart: null, resumeEnd: null, orgName: null, positionName: null, resumeRemark: null, showIndex: null, resumeRange: [] }
export default {
name: "resumeEdit",
props: {
resumeList: {
type: Array,
default: () => {
return [];
},
},
},
data() {
return {
educationList: [],
studyList: [],
workList: [],
formModel: {
educationList: [],
studyList: [],
workList: [],
}
};
},
created() {
// 根据 resumeType 分类并排序
if (this.resumeList && this.resumeList.length > 0) {
// 学历记录
this.educationList = this.resumeList
.filter(item => item.resumeType === 'e76f5097-fe28-11ef-b6cb-0c42a1380f01')
.sort((a, b) => a.showIndex - b.showIndex)
.map(item => ({
...item,
resumeRange: item.resumeStart && item.resumeEnd ?
[moment(item.resumeStart), moment(item.resumeEnd)] : []
}))
// 研修经历
this.studyList = this.resumeList
.filter(item => item.resumeType === 'e76f5097-fe28-11ef-b6cb-0c42a1380f02')
.sort((a, b) => a.showIndex - b.showIndex)
.map(item => ({
...item,
resumeRange: item.resumeStart && item.resumeEnd ?
[moment(item.resumeStart), moment(item.resumeEnd)] : []
}))
// 工作经历
this.workList = this.resumeList
.filter(item => item.resumeType === 'e76f5097-fe28-11ef-b6cb-0c42a1380f03')
.sort((a, b) => a.showIndex - b.showIndex)
.map(item => ({
...item,
resumeRange: item.resumeStart && item.resumeEnd ?
[moment(item.resumeStart), moment(item.resumeEnd)] : []
}))
this.formModel.educationList = this.educationList
this.formModel.studyList = this.studyList
this.formModel.workList = this.workList
}
},
methods: {
moment,
checkDateRange,
educationDateChange(dates, dateStrings, index) {
if (dateStrings[0] && dateStrings[1]) {
this.educationList[index].resumeStart = dateStrings[0]
this.educationList[index].resumeEnd = dateStrings[1]
}
},
studyDateChange(dates, dateStrings, index) {
if (dateStrings[0] && dateStrings[1]) {
this.studyList[index].resumeStart = dateStrings[0]
this.studyList[index].resumeEnd = dateStrings[1]
}
},
workDateChange(dates, dateStrings, index) {
if (dateStrings[0] && dateStrings[1]) {
this.workList[index].resumeStart = dateStrings[0]
this.workList[index].resumeEnd = dateStrings[1]
}
},
addEducationArray() {
const newItem = {
...Education,
showIndex: this.educationList.length + 1,
resumeRange: []
}
this.educationList.push(newItem)
this.$nextTick(() => {
this.$refs.form && this.$refs.form.clearValidate()
})
},
deleteEducationArray(item) {
let index = this.educationList.indexOf(item)
if (index !== -1) {
this.educationList.splice(index, 1)
}
},
addStudyArray() {
const newItem = {
...Study,
showIndex: this.studyList.length + 1,
resumeRange: []
}
this.studyList.push(newItem)
this.$nextTick(() => {
this.$refs.form && this.$refs.form.clearValidate()
})
},
deleteStudyArray(item) {
let index = this.studyList.indexOf(item)
if (index !== -1) {
this.studyList.splice(index, 1)
}
},
addWorkArray() {
const newItem = {
...Work,
showIndex: this.workList.length + 1,
resumeRange: []
}
this.workList.push(newItem)
this.$nextTick(() => {
this.$refs.form && this.$refs.form.clearValidate()
})
},
deleteWorkArray(item) {
let index = this.workList.indexOf(item)
if (index !== -1) {
this.workList.splice(index, 1)
}
},
mergeResumeList() {
// 清空原有数据
this.resumeList.length = 0
// 合并三个数组
const allLists = [
...this.educationList.map((item, index) => {
// 创建一个新对象,避免直接修改原对象
const newItem = { ...item }
// 安全地添加时间部分
if (newItem.resumeStart) {
newItem.resumeStart = newItem.resumeStart + " 00:00:00"
}
if (newItem.resumeEnd) {
newItem.resumeEnd = newItem.resumeEnd + " 23:59:59"
}
newItem.showIndex = index + 1
return newItem
}),
...this.studyList.map((item, index) => {
const newItem = { ...item }
if (newItem.resumeStart) {
newItem.resumeStart = newItem.resumeStart + " 00:00:00"
}
if (newItem.resumeEnd) {
newItem.resumeEnd = newItem.resumeEnd + " 23:59:59"
}
newItem.showIndex = index + 1
return newItem
}),
...this.workList.map((item, index) => {
const newItem = { ...item }
if (newItem.resumeStart) {
newItem.resumeStart = newItem.resumeStart + " 00:00:00"
}
if (newItem.resumeEnd) {
newItem.resumeEnd = newItem.resumeEnd + " 23:59:59"
}
newItem.showIndex = index + 1
return newItem
})
]
// 移除 resumeRange 字段,因为后端不需要
const cleanedList = allLists.map(item => {
const newItem = { ...item }
delete newItem.resumeRange
return newItem
})
// 更新 resumeList
this.resumeList.push(...cleanedList)
//console.log('合并后的简历列表:', this.resumeList)
return this.resumeList
}
},
watch: {
educationList: {
handler(val) {
this.formModel.educationList = val
},
deep: true,
immediate: true
},
studyList: {
handler(val) {
this.formModel.studyList = val
},
deep: true,
immediate: true
},
workList: {
handler(val) {
this.formModel.workList = val
},
deep: true,
immediate: true
},
}
};
</script>