dialogMates.vue
11.5 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<template>
<el-dialog
v-model="show" destroy-on-close :title="title" width="800px" append-to-body
draggable
:close-on-click-modal="false" @close="mateClose"
>
<div class="mb20">
<span v-if="mateConfig.minCount!=mateConfig.maxCount">请选择{{ mateConfig.minCount }}~{{
mateConfig.maxCount
}}个队友</span>
<span v-else-if="mateConfig.minCount=='-1'&&mateConfig.maxCount=='-1'">请至少选择1个队友</span>
<span v-else>请选择{{ mateConfig.minCount }}个队友</span>
<span v-if="mateConfig.minMaleCount!=-1||mateConfig.maxMaleCount!=-1" style="margin:0 20px;">男子:
<span v-show="mateConfig.minMaleCount!=mateConfig.maxMaleCount&&mateConfig.minMaleCount!=-1"> 最少{{ mateConfig.minMaleCount }}人 </span>
<span v-show="mateConfig.minMaleCount!=mateConfig.maxMaleCount&&mateConfig.maxMaleCount!=-1"> 最多{{ mateConfig.maxMaleCount }}人</span>
<span v-show="mateConfig.minMaleCount==mateConfig.maxMaleCount&&mateConfig.maxMaleCount!=-1">{{ mateConfig.maxMaleCount }}人</span>
</span>
<span v-if="mateConfig.minFemaleCount!=-1||mateConfig.maxFemaleCount!=-1" style="margin:0 20px;">女子:
<span v-show="mateConfig.minFemaleCount!=mateConfig.maxFemaleCount&&mateConfig.minFemaleCount>0"> 最少{{ mateConfig.minFemaleCount }}人 </span>
<span v-show="mateConfig.minFemaleCount!=mateConfig.maxFemaleCount&&mateConfig.maxFemaleCount>0"> 最多{{ mateConfig.maxFemaleCount }}人</span>
<span v-show="mateConfig.minFemaleCount==mateConfig.maxFemaleCount&&mateConfig.minFemaleCount>0">{{ mateConfig.minFemaleCount }}人</span>
</span>
</div>
<!-- <el-button v-if="teammateList.length<minCount" type="text" @click="addTeamMate">新增队友</el-button>-->
<el-empty v-if="teammateList.length==0" description="暂无可选队友" />
<div class="teammateList" style="max-height:60vh;overflow: auto;">
<el-checkbox-group v-model="form.mates" class="ml-4" @change="changeTeammates">
<el-checkbox disabled checked :label="personal.sex+'_'+personal.id" size="large">
<div class="optionFlex" style="width: auto;">
<el-avatar v-show="personal.picUrl" :size="40" :src="personal.picUrl" />
<p class="name" style="width: 200px">{{ personal.realName }}
<span v-show="personal.sex=='0'">(女)</span>
<span v-show="personal.sex=='1'">(男)</span>
</p>
<el-select v-show="sonLevelList.length>0" v-model="personal.sonlevel" clearable>
<el-option v-for="son in sonLevelList" :value="son.id" :label="son.name">{{ son.name }}</el-option>
</el-select>
</div>
</el-checkbox>
<div v-for="item in teammateList" :key="item.id" class="mb20">
<el-checkbox :label="item.sex+'_'+item.id" size="large" :disabled="item.cantchosemate">
<div class="optionFlex" style="width: auto;">
<el-avatar v-show="item.picUrl" :size="40" :src="item.picUrl" />
<p class="name" style="width: 200px">{{ item.realName }}
<span v-if="item.sex=='0'">(女)</span>
<span v-else>(男)</span>
</p>
<el-select v-show="sonLevelList.length>0" v-model="item.sonlevel" clearable>
<el-option v-for="son in sonLevelList" :value="son.id" :label="son.name">{{ son.name }}</el-option>
</el-select>
</div>
</el-checkbox>
<el-button v-if="noPhotoCanSign=='0'&&(!item.picUrl)" class="ml20" type="text" @click="editPersonInfo(item.id,nowMan.groupId)">
上传照片
</el-button>
</div>
</el-checkbox-group>
</div>
<template #footer>
<div class="dialog-footer text-center">
<el-button type="primary" @click="chooseMateDone">确定</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref, toRefs, watch } from 'vue'
import { getCurrentInstance, nextTick, onMounted } from '@vue/runtime-core'
import * as match from '@/apiPc/match'
import { ElMessage } from 'element-plus'
const { proxy } = getCurrentInstance()
const emit = defineEmits(['submitForm'])
import dialogPersonInfo from '../components/addCoach'
import _ from 'lodash'
const data = reactive({
show: false,
title: '选择队友',
signType: '',
form: {
levelId: [],
mates: []
},
athletesList: [],
signProjectList: [],
signGroupList: [],
showMateList: false,
showBtn: false,
teammateList: [],
rankId: '0',
treeData: [],
loading: false,
mateConfig: {},
noPhotoCanSign: null,
coachOrLeaderFlag: null,
personal: {},
activeNames: [0]
})
const {
signType,
form,
rules,
loading,
activeNames,
athletesList,
show,
title,
personal,
rankId,
showMateList,
showBtn,
teammateList,
mateConfig,
noPhotoCanSign,
coachOrLeaderFlag
} = toRefs(data)
let matchId
let groupId
let levelId
let noLevelId
const open = (params) => {
show.value = true
matchId = params.matchId
levelId = params.levelId
groupId = params.groupId
signType.value = params.signType
title.value = params.title
rankId.value = params.rankId || ''
noPhotoCanSign.value = params.noPhotoCanSign
coachOrLeaderFlag.value = params.coachOrLeaderFlag
if (params.personal) {
form.value.manId = params.personal.id
personal.value = params.personal
}
if (groupId !== 0) {
}
getTeammate(levelId)
}
defineExpose({
open
})
const nowMan = ref({})
const sonLevelList = ref([])
let sonLevelIds = []
function editPersonInfo(id, groupId) {
const params = {
id: id,
groupId: groupId
}
proxy.$refs['editPersonInfoRef'].open(params)
}
function addTeamMate() {
const params = {
id: 0,
groupId: groupId
}
proxy.$refs['editPersonInfoRef'].open(params)
}
const getTeammate = (levelId) => {
const obj = {
levelId: levelId,
groupId: groupId,
personId: form.value.manId
}
match.getCanSignLevelPerson(obj).then(res => {
mateConfig.value = res.data
teammateList.value = res.data.personList
for (const p of teammateList.value) {
p.cantchosemate = false
if (mateConfig.value.maxMaleCount == 0 && p.sex == '1') {
p.cantchosemate = true
}
if (mateConfig.value.maxFemaleCount == 0 && p.sex == '0') {
p.cantchosemate = true
}
}
getSonLevels(levelId)
showMateList.value = true
form.value.mates = []
sonLevelIds = []
personal.value.sonlevel = ''
}).catch(error => {
})
}
function getSonLevels(level) {
sonLevelList.value = []
match.querySonLevel(level).then(res => {
sonLevelList.value = res.data
})
}
let manNum = 0
let femaleNum = 0
let mates = []
const changeTeammates = (e) => {
mates = []
manNum = 0
femaleNum = 0
for (const m of e) {
const arr = m.split('_')
mates.push(arr[1])
if (personal.value.id == arr[1]) {
continue
}
if (arr[0] == '1') {
manNum++
} else {
femaleNum++
}
}
// console.log(mates, mateConfig.value)
for (const p of teammateList.value) {
if (mateConfig.value.maxMaleCount != -1 && manNum == mateConfig.value.maxMaleCount && p.sex == '1' && mates.indexOf(p.id) == -1) {
p.cantchosemate = true
} else if (mateConfig.value.maxFemaleCount != -1 && femaleNum == mateConfig.value.maxFemaleCount && p.sex == '0' && mates.indexOf(p.id) == -1) {
p.cantchosemate = true
} else if (mates.indexOf(p.id) == -1 && mateConfig.value.maxCount != -1 && (mates.length - 1) == mateConfig.value.maxCount) {
p.cantchosemate = true
} else {
p.cantchosemate = false
}
}
}
const mateClose = () => {
mates = []
form.value.mates = []
sonLevelIds = []
teammateList.value = []
}
function chooseMateDone() {
if (mateConfig.value.minMaleCount != '-1' && manNum < mateConfig.value.minMaleCount) {
ElMessage.warning(`至少选择${mateConfig.value.minMaleCount}个男队友`)
return
}
if (mateConfig.value.maxMaleCount != '-1' && manNum > mateConfig.value.maxMaleCount) {
ElMessage.warning(`最多选择${mateConfig.value.maxMaleCount}个男队友`)
return
}
if (mateConfig.value.minFemaleCount != '-1' && femaleNum < mateConfig.value.minFemaleCount) {
ElMessage.warning(`至少选择${mateConfig.value.minFemaleCount}个女队友`)
return
}
if (mateConfig.value.maxFemaleCount != '-1' && femaleNum > mateConfig.value.maxFemaleCount) {
ElMessage.warning(`最多选择${mateConfig.value.maxFemaleCount}个女队友`)
return
}
if ((mates.length < mateConfig.value.minCount) && mateConfig.value.minCount > 0) {
ElMessage.warning(`至少选择${mateConfig.value.minCount}个队友`)
return
}
const athleteIds = []
console.log('mates', mates)
for (const p of teammateList.value) {
if (mates.indexOf(p.id) != -1) {
if (sonLevelList.value.length > 0 && !p.sonlevel) {
ElMessage.warning(`请分配级别`)
return
}
sonLevelIds.push(p.sonlevel)
athleteIds.push(p.id)
}
}
if (sonLevelList.value.length > 0 && !personal.value.sonlevel) {
ElMessage.warning(`请分配级别`)
return
}
sonLevelIds.push(personal.value.sonlevel)
athleteIds.push(personal.value.id)
if (sonLevelList.value.length == 0) {
sonLevelIds = []
}
const obj = {
levelId: noLevelId,
athleteIds: athleteIds.toString(),
sonLevelIds: sonLevelIds.toString() || '',
groupId: groupId,
teamId: rankId.value || ''
}
// 半提交
saveOne(obj)
}
const saveOne = (obj) => {
loading.value = true
match.sportsmanDone(obj).then(res => {
if (res.msg.indexOf('Exception:') > -1) {
const msg = res.msg.slice(10)
ElMessage({
type: 'warning',
message: msg
})
// form.value.mates = []
sonLevelIds = []
return
}
sonLevelIds = []
// form.value.mates = []
showMateList.value = false
sonLevelList.value = []
emit('submitForm')
}).catch(err => {
// 取消这个勾
sonLevelIds = []
})
}
</script>
<style lang="scss" scoped>
.optiontitle {
font-size: 14px;
padding: 0 10px;
line-height: 1;
margin: 10px 0;
border-left: 2px solid #1ab394;
}
.optionFlex {
display: flex;
align-items: center;
padding: 10px 0;
width: 200px;
.name {
margin: 0 20px;
font-size: 16px;
}
}
.el-radio-group {
width: 100%;
display: block;
}
.athleteBox {
height: 80px;
display: flex;
align-items: center;
:deep(.el-radio__label) {
display: flex;
align-items: center;
margin: 0 20px;
}
.el-radio__inner {
scale: 1.5;
}
.name {
margin: 0 20px;
font-size: 16px;
}
}
.athleteBox:hover {
background: #efefef;
}
.tip {
font-size: 13px;
color: #999;
margin: 10px 0;
i {
color: red;
margin: 0 4px 0 0;
}
}
p.title {
font-size: 16px;
margin: 0 0 15px;
}
:deep(.el-collapse-item) {
background: #FBFCFD;
margin: 0 0 16px;
padding: 0 15px;
}
:deep(.el-collapse-item__wrap) {
background: #FBFCFD;
border: none;
padding: 0 10px;
}
:deep(.el-collapse) {
border: none;
}
:deep(.el-collapse-item__header) {
border: none;
background: #ececec;
padding: 0 0 0 10px; font-size: 15px;
}
:deep(.el-collapse-item__content) {
padding-bottom: 0;
}
:deep(.el-checkbox__input.is-disabled+span.el-checkbox__label) {
color: #4C5359;
}
.fake-collapse-item {
background: #FBFCFD;
margin: 0 0 16px;
padding: 0 15px;
}
:deep(.el-checkbox.el-checkbox--large .el-checkbox__label){
font-size: 16px;
}
.teammateList :deep(.el-checkbox.el-checkbox--large) {
height: auto;
}
</style>