teamSign.vue
10 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
<template>
<div class="app-container">
<div class="box ph-30">
<el-card>
<team-sign-step :language="language" :active-step="0"/>
</el-card>
<div class="h20"></div>
<div class="panel" style="box-shadow: var(--el-box-shadow)">
<match-info-row :match-id="cptId" :language="language"/>
<div class="h20"></div>
<el-form ref="ruleFormRef" label-width="120px" class="signForm"
:model="form" :rules="rules"
:label-position="language==0?'left':'top'">
<el-row>
<el-col :lg="8" :offset="2">
<el-form-item :label="language==0?'团体Logo':'Group Logo'" prop="imgUrl">
<ImageUpload2 v-model="form.imgUrl" :crop-width="200" :crop-height="200" :limit="1"/>
<span class="tip" v-if="language==0">请上传不超过 <i>5M</i> 的文件 格式为 <i>png/jpg/jpeg</i> 的文件</span>
<span class="tip" v-else>Please upload a file in the format of
<i>png/jpg/jpeg</i> that does not exceed <i>5MB</i>
</span>
</el-form-item>
</el-col>
<el-col :lg="10">
<el-form-item :label="language==0?'参赛队名称':'Name of participating team'" required prop="abreviations">
<el-input type="text" v-model="form.abreviations" :placeholder="language==0?'请输入内容':''"/>
</el-form-item>
<el-form-item :label="language==0?'团体名称':'Team Name'" prop="name">
<el-input v-model="form.name" :placeholder="language==0?'请输入团体名称':''" />
</el-form-item>
<el-form-item :label="language==0?'负责人姓名':'Contact Person'" prop="contactPerson">
<el-input v-model="form.contactPerson" placeholder="请输入联系人" />
</el-form-item>
<el-form-item :label="language==0?'邮箱':'Email'" required prop="contactEmail">
<el-input v-model="form.contactEmail" type="email" placeholder="请输入内容"/>
</el-form-item>
<el-form-item :label="language==0?'团体类型':'Group type'" prop="type">
<el-select v-model="form.type" :placeholder="language==0?'请选择团体类型':''" style="width: 100%;">
<el-option :label="language==0?'普通院校':'School'" value="0" />
<el-option :label="language==0?'专业舞蹈学校':'Professional dance school'" value="1" />
<el-option :label="language==0?'培训机构/俱乐部':'Company/Club'" value="2" />
<el-option :label="language==0?'地方协会':'Local Association'" value="3" />
<el-option :label="language==0?'国家协会':'National Association'" value="4" />
</el-select>
</el-form-item>
<el-form-item :label="language==0?'详细地址':'Detailed Address'" required prop="address">
<el-input type="textarea" v-model="form.address" class="mt10" placeholder="请输入详细地址"/>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="participantsInfoArr&&participantsInfoArr.length>0">
<el-col :span="16" :offset="4">
<h3>{{ language==0?'补充信息':'Supplemental information'}}</h3>
<el-form-item v-for="(s,index) in participantsInfoArr" :key="index">
<template #label>
<span v-if="s.status == 0" class="red">*</span>{{ s.name }}
</template>
<el-input v-if="s.type == '0'" v-model="s.value" />
<el-input v-if="s.type == '1'" v-model="s.value" type="number" />
<el-select v-if="s.type == '4'" v-model="s.value" class="m-2">
<el-option v-for="item in s.option" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
<ImageUpload v-if="s.type == '3'" v-model="s.value" :limit="1" :is-show-tip="false" />
<!-- 文件 2-->
<FileUpload v-if="s.type == '2'" v-model="s.fixWxFile" :action="uploadUrl" :accept="accept" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="panel-footer text-center">
<el-button type="primary" class="btn-lineG w200px" round @click="submitForm()">
{{ language==0?'下一步':'NEXT' }}
</el-button>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { getCurrentInstance, onMounted } from '@vue/runtime-core'
import { useRoute, useRouter } from 'vue-router'
import { toRefs } from '@vueuse/shared'
import TeamSignStep from './components/teamSignStep'
import MatchInfoRow from "@/viewsPc/match/components/matchInfo-row";
import cache from "@/plugins/cache"
const language = ref(cache.local.get('language') || 0)
const { proxy } = getCurrentInstance()
const router = useRouter()
const route = useRoute()
import * as match from '@/apiPc/match'
import { ElMessage } from 'element-plus'
import _ from 'lodash'
import {saveMyGroupForCpt} from "@/apiPc/match";
const data = reactive({
isRanks: false,
matchData:{
enBo:{}
},
form: {},
groupId: route.query.groupId||0,
cptId: route.params.id||0,
signType: false,
regionsList: [],
participantsInfoArr: [],
rankList: [],
accept: '.doc, .pdf, .docx, .zip',
rules: {
imgUrl: { required: true, message: '请上传', trigger: 'blur' },
name: { required: true, message: '请填写', trigger: 'blur' },
type: { required: true, message: '请选择', trigger: 'change' },
contactPerson: { required: true, message: '请填写内容', trigger: 'blur' },
contactEmail: { required: true, message: '请填写内容', trigger: 'blur' },
abreviations: { required: true, message: '请填写内容', trigger: 'blur' },
address: { required: true, message: '请填写内容', trigger: 'blur' }
},
coachOrLeaderFlag: '',
matchInfo:{}
})
const {
isRanks,matchData,
rankList,
form,
groupId,
signType,
participantsInfoArr,
cptId,
rules,
regionsList,matchInfo,
coachOrLeaderFlag, accept
} = toRefs(data)
const uploadUrl = ref('/upload/upLoadToFileServer')
onMounted(() => {
// 获取团体信息
getGroupInfo()
signType.value = route.query.signType
getRegionsList()
match.getMatchById({ id: cptId.value }).then(res => {
coachOrLeaderFlag.value = res.data.coachOrLeaderFlag
matchInfo.value = res.data
if (res.data.groupInfo) {
participantsInfoArr.value = JSON.parse(res.data.groupInfo)
}
// 获取补充信息
match.getMyGroupForCpt(groupId.value, cptId.value).then(res => {
if (res.data.groupInfo && res.data.groupInfo.groupInfo) {
const groupInfo = JSON.parse(res.data.groupInfo.groupInfo)
if (groupInfo.length > 0) {
// 补充字段信息
participantsInfoArr.value = groupInfo
for (var n of participantsInfoArr.value) {
if (n.type == '3' && n.value.url) {
// 图片
n.value = n.value.url
}
if (n.type == '2') {
// 文件
var arr = [{
name: n.value.name,
url: n.value.url
}]
n.fixWxFile = arr
}
}
}
}
})
})
})
function getRegionsList() {
match.regionsList().then(res => {
regionsList.value = res.data
})
}
function getGroupInfo() {
match.getGroupInfo().then(res => {
form.value = res.data
})
}
function getTeamList() {
return match.getMyTeamList(cptId.value, groupId.value).then(response => {
rankList.value = response.data
})
}
function goPrev() {
router.go(-1)
}
function submitForm() {
proxy.$refs['ruleFormRef'].validate((valid, fields) => {
if (valid) {
console.log(form.value)
for (const n of participantsInfoArr.value) {
if (n.status == 0 && (!n.value && !n.fixWxFile)) {
ElMessage.error(`请完善${n.name}信息`)
return
}
}
if (participantsInfoArr.value.length>0) {
// 保存补充信息
let fileInfo = {}
for (var p of participantsInfoArr.value) {
if (p.type == '2' && p.fixWxFile) {
const temp = p.fixWxFile[0].name.split('.')
fileInfo = {
url: p.fixWxFile[0].url,
name: p.fixWxFile[0].name,
extname: temp[temp.length - 1]
}
p.value = fileInfo
}
}
const obj = {
cptId: cptId.value,
groupId: groupId.value,
groupInfo: JSON.stringify(participantsInfoArr.value)
}
match.saveMyGroupExtraInfo(obj).then(res => {
})
}
// 保存团体信息
form.value.cptId = cptId.value
form.value.groupId = groupId.value
match.saveMyGroupForCpt(form.value).then(res => {
goNext()
})
} else {
console.log(form.value, fields)
}
})
}
function goNext() {
// 选教练
router.push({
name: `chooseCoach`,
query: {
matchId: cptId.value,
groupId: groupId.value,
signType: signType.value
}
})
}
</script>
<style scoped lang="scss">
.app-container {
padding: 0;
background: #F5F7F9;
}
.panel-footer .el-button--success {
padding: 0 40px;
}
.bili43{
:deep(.fileItem) {
width: 200px;
height: 150px;
}
.el-upload-list--picture-card .el-upload-list__item {
width: 200px;
height: 150px;
}
}
.signForm {
.el-form-item__label {
color: #4C5359;
}
}
.tip {
font-size: 13px;
color: #999;
margin: 10px 0;
i {
color: red;font-style: normal;
margin: 0 4px 0 0;
}
}
.threeFour {
width: 100%;
}
:deep(.el-upload--picture-card) {
width: 120px;
height: 120px;
}
:deep(.el-upload-list--picture-card .el-upload-list__item) {
width: 120px;
height: 120px;
}
.red {
color: #f56c6c;
}
</style>