allSportsmanListForPersonal.vue
12.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
<template>
<el-dialog
v-model="show" :title="title" append-to-body center width="1000px"
@close="close"
>
<div class="funcBtns">
<el-button type="primary" @click="addMember">
{{ language == 0 ? '添加选手' : 'Add Player' }}
</el-button>
</div>
<div class="from-Card">
<el-form :inline="true" :model="query" class="mt20" label-width="60" size="small">
<el-form-item :label="language==0?'姓名':'Name'">
<el-input v-model="query.realName" clearable style="width: 120px;" />
</el-form-item>
<el-form-item v-if="!isNational" :label="language==0?'证件类型':'ID Type'">
<el-select v-model="query.idcType" clearable style="width: 100px;" @change="getList" @clear="getList">
<el-option
v-for="item in certificates"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="!isNational" :label="language==0?'证件号码':'ID NO.'">
<el-input v-model="query.idcCode" clearable style="width: 120px;" />
</el-form-item>
<!-- <el-form-item label="角色">-->
<!-- <el-input v-model="query.label" style="width: 120px;" clearable/>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" @click="getList">{{ language == 0 ? '查询' : 'Search' }}</el-button>
</el-form-item>
<el-form-item class="fr">
<el-button plain type="primary" @click="resetChose">{{ language == 0 ? '清空选择' : 'Clear Selection' }}
</el-button>
</el-form-item>
</el-form>
</div>
<p v-if="language==0" class="tip">报名单人项目只需选中需要报名的人员</p>
<p v-if="language==1" class="tip">To register for the individual project, simply select the person who needs to
register</p>
<p v-if="noPhotoCanSign == 0" class="text-danger">
{{ language == 0 ? '*需上传照片才可报名' : '*Please upload photo before sign up' }}</p>
<el-table
ref="allSportmenTable" v-loading="loading" :data="tableData" :row-key="getRowKeys"
height="60vh" @selection-change="handleSelectionChange"
>
<el-table-column
:label="language==0?'选择':'Selection'" :reserve-selection="true" :selectable="selectable"
type="selection"
/>
<!-- <el-table-column align="center" type="index" :label="language==0?'序号':'Index'" width="60" :selectable="selectable"/>-->
<el-table-column v-if="isNational" :label="language==0?'WDSF MIN':'WDSF MIN'" prop="wdsfMin" width="100" />
<el-table-column :label="language==0?'姓氏':'Surname'" align="center" min-width="100" prop="xing" />
<el-table-column :label="language==0?'名':'Name'" align="center" min-width="100" prop="ming" />
<el-table-column
v-if="isNational" :label="language==0?'代表':'Representing'" align="center" min-width="120"
prop="representing"
/>
<el-table-column
v-if="!isNational" :label="language==0?'所属国家/地区':'Nationality'" align="center"
min-width="110" prop="countryName"
/>
<el-table-column :label="language==0?'性别':'Gender'" align="center" prop="sexStr" />
<el-table-column
v-if="isNational" :label="language==0?'年龄组':'Age group'" align="center" min-width="100"
prop="ageGroup"
/>
<el-table-column
v-if="isNational" :label="language==0?'舞种':'Division'" align="center" min-width="100"
prop="division"
/>
<el-table-column v-if="!isNational" :label="language==0?'年龄':'Age'" prop="age" />
<el-table-column v-if="!isNational" :label="language==0?'出生日期':'Date of Birth'" prop="birth" width="130" />
<el-table-column v-if="!isNational" :label="language==0?'证件类型':'ID Type'" prop="idcTypeStr" width="120" />
<el-table-column v-if="!isNational" :label="language==0?'证件号码':'ID NO.'" prop="idcCode" width="200" />
<!-- <el-table-column label="会员角色" width="200">-->
<!-- <template #default="scope">-->
<!-- <div>-->
<!-- <div style="white-space: nowrap" class="esp">-->
<!-- <span v-for="item in scope.row.label?.split(',')" :key="item.id">-->
<!-- <span v-if="item==='0'" class="ml5">{{ language==0?'运动员':'athletes' }}</span>-->
<!-- <span v-if="item==='1'" class="ml5">{{ language==0?'教练':'coach' }}</span>-->
<!-- <span v-if="item==='2'" class="ml5">{{ language==0?'领队':'team leader' }}</span>-->
<!-- <span v-if="item==='3'" class="ml5">{{ language==0?'队医':'team doctor' }}</span>-->
<!-- <span v-if="item==='4'" class="ml5">{{ language==0?'翻译':'translator' }}</span>-->
<!-- <span v-if="item==='5'" class="ml5">{{ language==0?'官员':'official' }}</span>-->
<!-- <span v-if="item==='6'" class="ml5">{{ language==0?'其他':'other' }}</span>-->
<!-- </span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column :label="language==0?'操作':'Actions'" :width="language==0?180:200" align="center" fixed="right">
<template #default="scope">
<span v-if="scope.row.passportUrl" class="text-primary pointer" @click="editPerson(scope.row)">
{{ language == 0 ? '编辑' : 'Edit' }}
</span>
<span
v-else class="text-danger pointer"
@click="editPerson(scope.row)"
>{{ language == 0 ? '上传证件' : 'Upload Valid Passport' }}</span>
<span
v-if="scope.row.userId=='0'&&mateId!=scope.row.id" class="text-primary pd10 pointer"
@click="deletePerson(scope.row)"
>
{{ language == 0 ? '删除' : 'Delete' }}
</span>
</template>
</el-table-column>
</el-table>
<paginationPc
v-show="total>0"
v-model:limit="query.pageSize"
v-model:page="query.pageNum"
:total="total"
@pagination="getList"
/>
<template #footer>
<div class="dialog-footer text-center">
<el-button type="primary" @click="submit">{{ language == 0 ? '确定' : 'Confirm' }}</el-button>
<el-button @click="cancel">{{ language == 0 ? '取消' : 'Cancel' }}</el-button>
</div>
</template>
</el-dialog>
<!-- 国内赛运动员-->
<add-coach ref="dialogAddCoach" @submitForm="getList" />
<!-- 国际赛运动员-->
<add-wdsf ref="dialogAddWdsf" @submitForm="getList" />
<Import ref="dialogImportProps" @submitForm="getList" />
</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 AddCoach from '../components/addCoach'
import AddWdsf from '../components/addWdsf'
import Import from '../components/import'
import { useStorage } from '@vueuse/core/index'
import { delPersonForPersonal, getPerPersonList } from '@/apiPc/match'
import useUserStore from '@/store/modules/user'
import { ElMessage, ElMessageBox } from 'element-plus'
import _ from 'lodash'
const language = useStorage('language', 0)
const user = useUserStore().user
const { proxy } = getCurrentInstance()
const emit = defineEmits(['transfer'])
const data = reactive({
query: {
label: '0',
pageSize: 10,
pageNum: 1
},
tableData: [],
show: false,
loading: false,
title: '选择运动员',
noPhotoCanSign: 0,
total: 0,
isNational: false,
mateId: 0
})
const { query, tableData, show, title, loading, noPhotoCanSign, total, isNational, mateId } = toRefs(data)
const certificates = ref([
{
value: '0',
label: language.value == 0 ? '居民身份证' : 'Resident ID card'
},
{
value: '1',
label: language.value == 0 ? '护照' : 'Passport'
},
{
value: '2',
label: language.value == 0 ? '其他' : 'Other'
}
])
let matchId
let choosedList = []
let choosedIds = []
const open = (params) => {
title.value = params.title
matchId = params.matchId
mateId.value = params.mateId
noPhotoCanSign.value = params.noPhotoCanSign
show.value = true
isNational.value = params.isNational
choosedList = params.choosedList
getList()
}
defineExpose({
open
})
const reSetChoosed = () => {
choosedIds = []
for (const p of choosedList) {
choosedIds.push(p.id)
}
console.log(choosedIds, choosedList)
for (const n of tableData.value) {
if (choosedIds.indexOf(n.id) > -1) {
proxy.$refs['allSportmenTable'].toggleRowSelection(n, true)
}
}
}
const resetChose = () => {
proxy.$refs['allSportmenTable'].clearSelection()
}
const selectable = (row) => {
if (!row.picUrl && noPhotoCanSign.value == 0) {
return false
} else if (!row.passportUrl) {
// ElMessageBox.confirm(language.value == 0 ? `请上传${row.realName}的有效证件` : `Please Upload ${row.realName}'s Valid Passport`)
return false
} else {
return true
}
}
const getList = () => {
loading.value = true
getPerPersonList(query.value, user.userId).then(res => {
total.value = res.total
// const startIndex = (query.value.pageNum - 1) * query.value.pageSize;
// const endIndex = startIndex + query.value.pageSize;
// tableData.value = res.rows.slice(startIndex, endIndex)
tableData.value = res.rows
nextTick(() => {
reSetChoosed()
})
loading.value = false
})
}
function handleSelectionChange(val) {
// console.log('change',val)
choosedList = val
for (const p of val) {
choosedIds.push(p.id)
}
// 判断是否队友
if (val.length == 2) {
if (val[0].sex != val[1].sex) {
checkTwo(val[0], val[1])
}
}
if (val.length > 0) {
const newVal = _.last(val)
match.signgetSignInfoConflict({
cptId: matchId,
perId: newVal.id,
groupId: '0'
}).then(res => {
if (!res.data) {
ElMessage.warning(language.value == 0 ? '该人员已在其他团队中报名,请重新选择' : 'This person has already registered in another team, please select again')
proxy.$refs['allSportmenTable'].toggleRowSelection(newVal, false)
}
})
}
}
function checkTwo(a, b) {
match.checkMate({ per1Id: a.id, per2Id: b.id, cptId: matchId }).then(res => {
if (!res.data) {
if (isNational.value) {
ElMessage.warning(language.value == 0 ? '他们不是固定组合' : 'They\'re not a couple')
} else {
ElMessage.warning(language.value == 0 ? `${a.realName} 已经和其他人组成舞伴,无法报名:请重新选择` : `${a.realName} has already formed a dancer with another person, cannot sign up: please select again`)
}
proxy.$refs['allSportmenTable'].clearSelection()
}
})
}
function submit() {
if (choosedIds.length == 0) {
ElMessage.warning(language.value == 0 ? '请选择运动员' : 'Please select athletes')
return
}
emit('transfer', choosedList)
show.value = false
}
function getRowKeys(row) {
return row.id
}
function close() {
choosedIds = []
}
function cancel() {
show.value = false
}
function editPerson(row) {
console.log(isNational.value)
const params = {
id: row.id,
title: language.value == 0 ? '编辑人员' : 'Edit Person',
groupId: '0',
label: '0'
}
if (isNational.value) {
proxy.$refs['dialogAddWdsf'].open(params)
} else {
proxy.$refs['dialogAddCoach'].open(params)
}
}
function addMember() {
console.log(isNational.value)
const params = {
title: language.value == 0 ? '添加人员' : 'Add',
id: 0,
groupId: '0',
label: '0'
}
if (isNational.value) {
proxy.$refs['dialogAddWdsf'].open(params)
} else {
proxy.$refs['dialogAddCoach'].open(params)
}
}
function deletePerson(p) {
let text = ''
let t = '提示'
let s = '确定'
let c = '取消'
let msg = '操作成功'
if (language.value == 0) {
text = `确定删除${p.realName}和${p.sex == '1' ? '他' : '她'}的舞伴吗?`
} else {
text = `Delete ${p.realName} ${p.sex == '1' ? 'he' : 'she'} and ${p.sex == '1' ? 'his' : 'hers'} dance mate?`
t = 'Tips'
s = 'Confirm'
c = 'Cancel'
msg = ' Successful!'
}
ElMessageBox.confirm(text, t, {
confirmButtonText: s,
cancelButtonText: c,
type: 'warning'
}).then(() => {
match.delPersonForPersonal(p.id).then(res => {
ElMessage.success(msg)
getList()
})
})
}
</script>
<style lang="scss" scoped>
.el-form--inline .el-form-item {
width: auto;
}
</style>