chooseCoach.vue
11.8 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
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
<template>
<div class="">
<div class="box ph-30">
<el-card>
<el-steps :active="activeStep" align-center>
<el-step title="团队信息"/>
<el-step title="教练/领队/其他"/>
<el-step title="选手报名"/>
<el-step title="提交审核"/>
</el-steps>
</el-card>
<el-row class="mt20" :gutter="20">
<el-col :lg="12">
<el-card>
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag01.png"/>
教练<span class="tip">(教练/领队,至少选择一项)</span>
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.coachs" @change="changecoachs">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in coachList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card>
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag02.png"/>
领队<span class="tip">(教练/领队,至少选择一项)</span>
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.leader">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in leaderList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card class="mt20">
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag03.png"/>
队医
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.doctor">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in doctorList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card class="mt20">
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag04.png"/>
翻译
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.translator">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in translatorList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card class="mt20">
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag05.png"/>
官员
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.official">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in officialList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card class="mt20">
<template #header>
<div class="card-header">
<img src="@/assets/sign/tag06.png"/>
其他
</div>
</template>
<div class="chooseForm">
<el-checkbox-group v-model="form.other">
<div class="addBttn" @click="addCoach(0)">+</div>
<el-checkbox v-for="c in otherList" :label="c.id">
<el-avatar fit="cover" :size="60" :src="fillImgUrl(c.picUrl)"/>
<p class="name">{{ c.shortName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit/>
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</div>
</el-card>
</el-col>
</el-row>
<el-card class="mt20">
<div class="text-center">
<el-button type="primary" class="w200px" plain round @click="goPrev()">上一步</el-button>
<el-button type="primary" class="btn-lineG w200px" round @click="goNext()">下一步</el-button>
</div>
</el-card>
</div>
<dialogAddCoach ref="dialogAddCoachRef" @submitForm="getList"/>
</div>
</template>
<script setup>
import {ref, reactive} from 'vue'
import {getCurrentInstance, onMounted} from '@vue/runtime-core'
import * as match from '@/apiPc/match'
import dialogAddCoach from './components/addCoach'
const {proxy} = getCurrentInstance()
const router = useRouter()
const route = useRoute()
import {ElMessage} from 'element-plus'
import {useRoute, useRouter} from 'vue-router'
const data = reactive({
form: {
coachs: [],
leader: []
},
coachList: [],
leaderList: [],
otherList: [],
doctorList: [],
translatorList: [],
officialList: [],
hasChooseObj: {},
groupId: '0',
signType: '',
activeStep: 1
})
const {
form,
coachList,
leaderList,
otherList,
doctorList,
translatorList,
officialList,
rules,
signType,
groupId,
hasChooseObj,activeStep
} = toRefs(data)
let matchId = ''
onMounted(() => {
matchId = route.query.matchId
groupId.value = route.query.groupId
signType.value = route.query.signType || ''
getList()
})
function getList() {
if (signType.value == '0') {
geren()
} else {
tuandui()
}
}
function changecoachs(e) {
console.log(e)
}
// 获取报名时是否已选过
let hasChooseId
function tuandui() {
Promise.all([
match.getMyGroupForCpt(groupId.value, matchId),
match.getChooseDoneGroupCoachs(matchId, groupId.value)
]).then((res) => {
coachList.value = res[0].data.coaches
leaderList.value = res[0].data.leaders
doctorList.value = res[0].data.teamDoctors
translatorList.value = res[0].data.translators
officialList.value = res[0].data.officials
otherList.value = res[0].data.others
if (res[1].data.id != null) {
hasChooseObj.value = res[1].data
hasChooseId = res[1].data.id
if (hasChooseObj.value.coachIds) {
form.value.coachs = hasChooseObj.value.coachIds.split(',')
} else {
form.value.coachs = []
}
if (hasChooseObj.value.leaderIds) {
form.value.leader = hasChooseObj.value.leaderIds.split(',')
} else {
form.value.leader = []
}
form.value.other = hasChooseObj.value.otherIds.split(',')
form.value.doctor = hasChooseObj.value.teamDoctorIds.split(',')
form.value.translator = hasChooseObj.value.translatorIds.split(',')
form.value.official = hasChooseObj.value.officialIds.split(',')
}
})
}
function geren() {
Promise.all([
match.getMyPersonInfoWithcptId(matchId),
match.getChooseDoneSingleCoachs(matchId)
]).then((res) => {
coachList.value = res[0].data.coaches
leaderList.value = res[0].data.leaders
otherList.value = res[0].data.others
doctorList.value = res[0].data.teamDoctors
translatorList.value = res[0].data.translators
officialList.value = res[0].data.officials
if (res[1].data.id != null) {
hasChooseObj.value = res[1].data
hasChooseId = res[1].data.id
form.value.coachs = hasChooseObj.value.coachIds.split(',')
form.value.leader = hasChooseObj.value.leaderIds.split(',')
form.value.other = hasChooseObj.value.otherIds.split(',')
form.value.doctor = hasChooseObj.value.doctorIds.split(',')
form.value.translator = hasChooseObj.value.translatorIds.split(',')
form.value.official = hasChooseObj.value.officialIds.split(',')
}
})
}
function chooseDone() {
// 返回团队报名
router.go(-1)
}
function goNext() {
console.log(form.value)
if ((form.value.coachs.length < 1) && (form.value.leader.length < 1)) {
ElMessage.error('至少选一个教练或领队')
return
}
var obj = {
cptId: matchId,
coachIds: form.value.coachs?.toString() || '',
leaderIds: form.value.leader?.toString() || '',
otherIds: form.value.other?.toString() || '',
teamDoctorIds: form.value.doctor?.toString() || '',
translatorIds: form.value.translator?.toString() || '',
officialIds: form.value.official?.toString() || ''
}
if (hasChooseId) {
obj.id = hasChooseId
}
if (groupId.value && groupId.value != 0) {
obj.unitId = groupId.value
}
if (signType.value == '0') {
// 个人报名
match.singleSignSavePerson(obj).then(res => {
console.log(res)
router.push({
name: 'chooseProject',
query: {
matchId: matchId
}
})
})
} else if (signType.value == '1') {
// 团队报名
match.groupSignSavePerson(obj).then(res => {
router.push({
name: 'chooseSportsman',
query: {
matchId: matchId,
groupId: groupId.value,
signType: signType.value
}
})
})
}
console.log(form.value)
}
function goPrev() {
router.back()
}
function editPerson(id) {
proxy.$refs['dialogAddCoachRef'].open({
title: '编辑人员',
id: id,
groupId: groupId.value
})
}
function addCoach() {
proxy.$refs['dialogAddCoachRef'].open({
title: '新建人员',
id: 0,
groupId: groupId.value
})
}
</script>
<style scoped lang="scss">
.addBttn {margin-right: 20px;
width: 60px;
color: #7B7F83;
font-size: 20px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
background: #FFFFFF;
border: 1px dashed #95A1A6;
border-radius: 50%;
&:hover {
cursor: pointer;
color: var(--el-color-primary);
border-color: var(--el-color-primary);
}
}
.card-header {
display: flex;
align-items: center;color: var(--el-color-primary);
img {
margin-right: 8px;
flex: 0 0 auto;
}
}
.panel-footer .el-button--success {
padding: 0 40px;
}
.chooseForm{
:deep(.el-form-item__content){background: rgba(245, 247, 249, 0.38);
padding: 20px 40px 10px;}
.el-checkbox{height: auto;}
:deep(.el-checkbox__input){position: absolute;right: 0;top: 0;}
.name{text-align: center;}
}
:deep(.el-avatar)>img{width: 100%;}
</style>