chooseCoach.vue
9.56 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
<template>
<div class="app-container">
<div class="box ph-30">
<div class="panel">
<div class="panel-header">
<h3 class="panel-title">选择教练/领队/其他</h3>
</div>
<div class="panel-body">
<span class="tip">*至少选择一个教练或领队</span>
<div class="text-right">
<el-button type="success" @click="addCoach">新建教练</el-button>
</div>
<el-form
ref="ruleFormRef" label-width="120px" label-position="top" class="chooseForm" :model="form"
:rules="rules"
>
<el-form-item label="教练" prop="coachs">
<el-checkbox-group v-model="form.coachs" @change="changecoachs">
<el-checkbox v-for="c in coachList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="领队" prop="leader">
<el-checkbox-group v-model="form.leader">
<el-checkbox v-for="c in leaderList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="队医" prop="doctors">
<el-checkbox-group v-model="form.doctor">
<el-checkbox v-for="c in doctorList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="翻译" prop="translator">
<el-checkbox-group v-model="form.translator">
<el-checkbox v-for="c in translatorList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="官员" prop="official">
<el-checkbox-group v-model="form.official">
<el-checkbox v-for="c in officialList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="其他" prop="other">
<el-checkbox-group v-model="form.other">
<el-checkbox v-for="c in otherList" :label="c.id">
<el-avatar :size="60" :src="c.picUrl" />
<p class="name">{{ c.realName }}
<el-icon @click.stop="editPerson(c.id)">
<Edit />
</el-icon>
</p>
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
</div>
<div class="panel-footer text-center">
<el-button type="success" plain round @click="goPrev()">上一步</el-button>
<el-button v-if="signType!='2'" type="success" round @click="goNext()">下一步</el-button>
<el-button v-else type="success" round @click="chooseDone()">确定</el-button>
</div>
</div>
</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: '',
rules: {
// coachs: { required: true, message: '至少选择一个', trigger: 'change' },
// leader: { required: true, message: '至少选择一个', trigger: 'change' }
}
})
const { form, coachList, leaderList, otherList, doctorList, translatorList, officialList, rules, signType, groupId, hasChooseObj } = 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">
.app-container{ padding: 0;background: #F5F7F9;}
.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;}
}
</style>