addWdsf.vue
9.48 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
<template>
<el-dialog
v-model="show" :title="title" width="800px" append-to-body close-icon="CircleClose" center
:close-on-click-modal="false" class="pcloginpop" @close="cancel"
destroy-on-close
>
<el-form ref="dialogRef" :model="form" :label-width="language==0?120:180" inline>
<el-form-item :label="language==0?'WDSF卡号':'WDSF ID'" v-if="form.id">
{{ form.wdsfMin }}
</el-form-item>
<el-form-item :label="language==0?'WDSF卡号':'WDSF ID'" required v-else>
<el-input type="text" v-model="card" @change="resetCode" >
<template #append>
<el-button type="primary" plain style="width: 110px" @click="checkCard">
<el-icon v-if="isCodeTrue" size="16" color="#67C23A">
<CircleCheckFilled/>
</el-icon>
<span v-else>{{ language == 0 ? '校验卡号' : 'Check Code' }}</span>
</el-button>
</template>
</el-input>
<Vcode :show="showVcode" :z-index="2999" @success="codeSuccess()"></Vcode>
</el-form-item>
<div class="h30"></div>
<div class="leftboderTT">{{ language == 0 ? '个人信息' : 'Personal information' }}
<span v-if="language==0">(登录时需要验证,保护账户信息)</span>
<span v-else>(Obtain automatically according to the WDSF number)</span>
</div>
<div class="h20"></div>
<el-form-item :label="language==0?'名':'name'">
<el-input v-model="form.ming" disabled/>
</el-form-item>
<el-form-item :label="language==0?'姓氏':'surname'">
<el-input v-model="form.xing" disabled/>
</el-form-item>
<el-form-item label="Representing">
<el-input v-model="form.representing" disabled/>
</el-form-item>
<el-form-item label="Age group">
<el-input v-model="form.ageGroup" disabled/>
</el-form-item>
<el-form-item label="Division">
<el-input v-model="form.division" disabled/>
</el-form-item>
<el-form-item label="Status">
<el-input v-model="form.wdsfStatus" disabled/>
</el-form-item>
<div class="h30"></div>
<div class="leftboderTT">
{{ language == 0 ? '补充信息' : 'Supplementary Information' }}
</div>
<div class="h20"></div>
<el-form-item :label="language==0?'性别':'Sex'" required>
<el-radio-group v-model="form.sex">
<el-radio label="0">{{ language == 0 ? '女' : 'female' }}</el-radio>
<el-radio label="1">{{ language == 0 ? '男' : 'male' }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="language==0?'出生日期':'Birthday'" required>
<el-date-picker
v-model="form.birth"
style="width: 100%;"
type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
/>
</el-form-item>
<el-form-item label="Passport number" required>
<el-input v-model="form.passportNumber"/>
</el-form-item>
<el-form-item label="Passport File">
<file-upload v-model="form.passportUrl" :limit="1" :is-show-tip="false" :button-text="'Upload'"/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer text-center">
<el-button type="primary" class="btn-lineG w200px" round @click="submitForm">{{
language == 0 ? '确定' : 'Save'
}}
</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'
import _ from 'lodash'
import cache from "@/plugins/cache";
import Vcode from "vue3-puzzle-vcode"
import {checkWdsf} from "@/apiPc/match";
const language = ref(cache.local.get('language') || 0)
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'
}
])
const {proxy} = getCurrentInstance()
const emit = defineEmits(['submitForm'])
const data = reactive({
form: {
// countryId: 240
sex:'0'
},
card:'',
show: false,
showVcode: false,
labels: [
{value: '0', label: '运动员', enlabel: 'Sportsman'},
{value: '1', label: '教练', enlabel: 'Coach'},
{value: '2', label: '领队', enlabel: 'Leader'},
{value: '4', label: '队医', enlabel: 'Nurse'},
{value: '5', label: '翻译', enlabel: 'Translator'},
{value: '6', label: '官员', enlabel: 'Official'},
{value: '3', label: '其他', enlabel: 'Other'}
],
title: '添加选手信息',
isMe: false,
isCodeTrue: false,
cptId:''
})
const {form, show,showVcode, title, labels, uType, isMe,isCodeTrue,card,cptId} = toRefs(data)
let editgay = false
const open = (params) => {
console.log(params)
show.value = true
title.value = params.title
isMe.value = params.isMe
cptId.value = params.cptId
if (language.value == 0) {
form.value.countryId = 240
}
if (isMe.value) {
//个人
match.getMyPersonInfo().then(res => {
form.value = res.data
form.value.id = res.data.id
if (form.value.label) {
// {0:0,1:1,2:3}
form.value.labelArr = form.value.label.split(',')
} else {
form.value.labelArr = ['0']
}
})
} else {
if (params.id != 0) { // 编辑舞伴
editgay = true
form.value = params.form
}
}
}
defineExpose({open})
watch(show, (value) => {
if (!value) {
form.value = {
sex:'0'
}
}
nextTick(() => {
proxy.$refs['dialogRef'].clearValidate()
})
})
function submitForm() {
if (editgay) {
// id不是0
form.value.cptId = cptId.value
if(Array.isArray(form.value.passportUrl)){
form.value.passportUrl = form.value.passportUrl[0].url
} else {
form.value.passportUrl = form.value.passportUrl
}
match.editPersonInfo(form.value).then(res => {
ElMessage.success('保存成功')
show.value = false
emit('submitForm')
})
} else {
if (!form.value.passportNumber) {
ElMessage.error('Please fill in your passport number')
return
}
if (!form.value.birth) {
ElMessage.error('Please fill in your birthday')
return
}
if(Array.isArray(form.value.passportUrl)){
form.value.passportUrl = form.value.passportUrl[0].url
}
if (isMe.value) {
match.saveMyBaseInfo(form.value).then(res => {
ElMessage.success('保存成功')
show.value = false
emit('submitForm')
})
} else {
delete form.value.status
delete form.value.id
form.value.label = '0'
form.value.cptId = cptId.value
form.value.wdsfMin = form.value.min
form.value.idcCode = form.value.passportNumber
form.value.idcType = '1'
if(Array.isArray(form.value.passportUrl)){
form.value.passportUrl = form.value.passportUrl[0].url
} else {
form.value.passportUrl = form.value.passportUrl
}
match.savePersonForMyPerson(form.value).then(res => {
ElMessage.success('保存成功')
show.value = false
emit('submitForm', res.data)
})
}
}
}
function cancel() {
show.value = false
showVcode.value = false
}
function resetCode() {
isCodeTrue.value = false
}
function checkCard() {
if(isCodeTrue.value){
return
}
if (!card.value) {
if (language.value == 0) {
ElMessage.error('请填写WDSF卡号')
} else {
ElMessage.error('Please fill in your WDSF code')
}
return
}
showVcode.value = true
}
function codeSuccess(msg) {
console.log('验证通过' + msg);
showVcode.value = false
isCodeTrue.value = true
checkWdsf({card: card.value}).then(res => {
form.value = res.data
form.value.xing = form.value.surname
form.value.ming = form.value.name
form.value.wdsfStatus = form.value.status
if (!form.value.sex) {
form.value.sex = '0'
}
if (form.value.wdsfFlag == '0') {
isCodeTrue.value = false
if (language.value == 0) {
ElMessage.error('WDSF卡号错误')
} else {
ElMessage.error('WDSF ID is Error')
}
}
})
}
</script>
<style lang="scss">
.el-input-group__append button.el-button, .el-input-group__append button.el-button:hover {
color: var(--el-color-primary);
background: #efefff;
border: var(--el-color-primary) solid 1px;
border-radius: 0;
}
.leftboderTT {
color: var(--el-color-primary);
font-size: 16px;
font-weight: 600;
span {
color: #929AA0;
font-size: 14px;
}
}
.threeFour {
width: 100%;
.el-upload--picture-card {
width: 120px;
height: 160px;
}
.el-upload-list--picture-card .el-upload-list__item {
width: 120px;
height: 160px;
}
}
.tip {
font-size: 13px;
color: #999;
margin: 10px 0;
i {
color: red;
margin: 0 4px 0 0;
}
}
.shenfen {
.el-upload--picture-card {
width: 320px;
height: 200px;
}
.el-upload-list--picture-card .el-upload-list__item {
width: 320px;
height: 200px;
}
}
.touxiang {
:deep(.el-upload--picture-card ) {
width: 140px;
height: 200px;
}
}
.touxiang {
:deep(.el-upload-list__item ) {
width: 140px;
height: 200px;
}
}
.el-form--inline .el-form-item {
width: 100%
}
.boxDialog {
.el-dialog__header {
background: linear-gradient(#ed2c22, #fe6d45);
margin-right: 0;
height: 52px;
span {
color: #fff;
}
}
}
</style>