allSportsmanList.vue
5.04 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
<template>
<el-dialog v-model="show" :title="title" width="1000px" append-to-body>
<el-form :inline="true" :model="query" style="display: flex;">
<el-form-item label="姓名">
<el-input v-model="query.name" style="width: 120px;" clearable />
</el-form-item>
<el-form-item label="性别">
<el-select v-model="query.sex" placeholder="请选择" style="width: 100px;" clearable @change="getList">
<el-option label="全部" value="" />
<el-option label="男" value="1" />
<el-option label="女" value="0" />
</el-select>
</el-form-item>
<el-form-item label="出生日期">
<el-date-picker
v-model="birthArr" clearable
format="YYYY-MM-DD" value-format="YYYY-MM-DD"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="getList"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList">查询</el-button>
</el-form-item>
</el-form>
<p v-if="noPhotoCanSign == 0" class="text-danger">*需上传照片才可报名</p>
<el-table ref="allSportmenTable" v-loading="loading" :data="tableData" height="60vh" @selection-change="handleSelectionChange">
<el-table-column type="selection" label="选择" :selectable="selectable" />
<el-table-column label="照片" width="70">
<template #default="scope">
<img :src="scope.row.picUrl" style="width: 50px">
</template>
</el-table-column>
<el-table-column prop="realName" label="姓名" width="120" />
<el-table-column prop="sex" label="性别" width="50">
<template #default="scope">
<span v-if="scope.row.sex=='0'">女</span>
<span v-if="scope.row.sex=='1'">男</span>
</template>
</el-table-column>
<el-table-column label="证件号码" width="80">
<template #default="scope">
<span v-if="scope.row.idcType=='0'">身份证 </span>
<span v-if="scope.row.idcType=='1'">护照 </span>
<span v-if="scope.row.idcType=='2'">其他 </span>
</template>
</el-table-column>
<el-table-column prop="idcCode" label="证件号码" width="200" />
<el-table-column label="出生日期" width="120">
<template #default="scope">
<span>{{ scope.row.birth.substring(0,10) }}</span>
</template>
</el-table-column>
<el-table-column prop="phone" label="联系方式" />
<el-table-column label="操作" width="120">
<template #default="scope">
<el-button type="text" @click="editPerson(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer text-center">
<el-button type="primary" @click="submitForm">确定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</template>
</el-dialog>
<dialogPersonInfo ref="editPersonInfoRef" @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 dialogPersonInfo from '../components/addCoach'
const { proxy } = getCurrentInstance()
const emit = defineEmits(['submitForm', 'transfer'])
const data = reactive({
query: {},
tableData: [],
birthArr: [],
show: false,
loading: false,
title: '选择运动员',
noPhotoCanSign: 0
})
const { query, tableData, show, title, birthArr, loading, noPhotoCanSign } = toRefs(data)
let matchId
let groupId
let choosedList = []
const choosedIds = []
const open = (params) => {
matchId = params.matchId
groupId = params.groupId
noPhotoCanSign.value = params.noPhotoCanSign
show.value = true
choosedList = params.choosedList
for (const p of choosedList) {
choosedIds.push(p.id)
}
getList()
}
defineExpose({
open
})
const selectable = (row) => {
if (!row.picUrl && noPhotoCanSign.value == 0) {
return false
} else {
return true
}
}
const getList = () => {
loading.value = true
if (birthArr.value) {
query.value.birthBegin = birthArr.value[0]
query.value.birthEnd = birthArr.value[1]
}
match.getMyGroupForCptFilter(groupId, matchId, query.value).then(res => {
tableData.value = res.data.athletes
nextTick(() => {
for (const n in tableData.value) {
if (choosedIds.indexOf(tableData.value[n].id) > -1) {
proxy.$refs['allSportmenTable'].toggleRowSelection(tableData.value[n], true)
}
}
})
loading.value = false
})
}
function handleSelectionChange(val) {
// console.log(val)
choosedList = val
}
function submitForm() {
emit('transfer', choosedList)
// emit('submitForm', choosedList)
show.value = false
}
function cancel() {
show.value = false
}
function editPerson(row) {
const params = {
id: row.id,
groupId: groupId
}
proxy.$refs['editPersonInfoRef'].open(params)
}
</script>
<style scoped>
</style>