文件上传

GST002
Ly 3 months ago
parent e27f11436a
commit 1e9cebaa57
  1. 4
      src/api/person.ts
  2. 152
      src/views/registrationPersonage/index.vue

@ -59,7 +59,9 @@ interface SignUpData {
entryFormat: '团队' | '个人'
id: string
instructorSheetList?: any[]
teamManagementList?: any[]
teamManagementList?: any[],
file:string
WorkName:any
}
interface MembersOrAdviser {

@ -25,11 +25,7 @@
<div class="annual">{{ ndbs.annualid }}年度</div>
<div class="title-box">
<div class="text">{{ ndbs.name }}</div>
<img
style="width: 35px"
src="../../assets/images/编组.png"
alt=""
/>
<img style="width: 35px" src="../../assets/images/编组.png" alt="" />
</div>
</div>
<div class="right">
@ -76,16 +72,10 @@
</div>
</el-card>
</div>
<el-acrd>
<el-card>
<div>
<el-form
ref="ruleFormRef"
style="max-width: 600px"
:model="ruleForm"
status-icon
label-width="auto"
class="demo-ruleForm"
>
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" status-icon label-width="auto"
class="demo-ruleForm">
<el-form-item label="年度比赛项目">
<el-input v-model="ruleForm.objName" type="text" disabled />
</el-form-item>
@ -93,23 +83,21 @@
<el-input v-model="ruleForm.entryFormat" type="text" disabled />
</el-form-item>
<el-form-item label="选择题目" prop="topicid">
<el-select
v-model="ruleForm.topicid"
placeholder="请选择题目"
:disabled="isDisable"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-form-item label="选择题目">
<el-select v-model="ruleForm.topicid" placeholder="请选择题目" :disabled="isDisable">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="作品文件" v-if="ndbsXm.requireUploadWorks === 'Y'">
<template #default="{ row }">
<el-input style="width: auto;" v-model="WorkName" disabled>
</el-input>
<el-button type="primary" style="margin-left:15px ;" @click="uploadZp(ruleForm.id)">上传作品</el-button>
</template>
</el-form-item>
</el-form>
</div>
</el-acrd>
</el-card>
<el-card class="center">
<div class="personage-info">
<div class="head">
@ -179,16 +167,37 @@
<el-button class="btn" @click="() => router.back()">
{{ isDisable ? '返回' : isEdit ? '取消修改' : '取消报名' }}
</el-button>
<el-button
class="btn cyan"
:loading="subLoading"
@click="submit"
v-if="!isDisable"
>
<el-button class="btn cyan" :loading="subLoading" @click="submit" v-if="!isDisable">
{{ isEdit ? '确认修改' : '确认报名' }}
</el-button>
</div>
</div>
<el-dialog v-model="dialogVisible" title="上传作品" width="500" :before-close="handleClose" v-if="dialogVisible"
:close-on-click-modal="false">
<el-form label-width="80" style="padding-right: 30px">
<el-form-item label="作品名称">
<el-input v-model="raceName" />
</el-form-item>
<el-form-item label="作品">
<el-upload ref="upload" class="upload-demo" action="#" v-model:file-list="fileList" :limit="1"
:auto-upload="false">
<template #trigger>
<el-button type="primary">选择文件</el-button>
</template>
<template #tip>
<div class="el-upload__tip text-red">作品只允许上传一个</div>
</template>
</el-upload>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="submitWork">确认</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
@ -199,7 +208,7 @@ import { useRoute, useRouter } from 'vue-router'
import userStore from '@/store/module/user'
import { getNdbswxqList, getComppxqList } from '@/api/person'
import { getOldRaceList, getOldRaceInfo } from '@/api/oldRace'
import { getTopicList } from '@/api/race'
import { getTopicList, uploadFileZp, uploadFile } from '@/api/race'
const user = userStore()
const route = useRoute()
@ -224,8 +233,65 @@ const upData = ref<Parameters<typeof getSignUpApi>[0]>({
id: route.query.edit ? route.query.annualCompid : route.query.id,
instructorSheetList: [],
teamManagementList: [{ realname: '', captain: '', teamSeq: '', userId: '' }],
// WorkName:WorkName.value,
// file:fileUrl.value
})
//
const dialogVisible = ref(false)
const fileList = ref<any>([])
const annualCompid = ref('')
const raceName = ref<any>('')
const uploadZp = (id: any) => {
console.log(id)
annualCompid.value = id
dialogVisible.value = true
}
const handleClose = () => {
dialogVisible.value = false
fileList.value = []
raceName.value = ''
annualCompid.value = ''
}
const WorkName = ref<string>('')
// const fileUrl = ref<string>('')
const fileUrl = ref<string[]>([]);
const submitWork = async () => {
if (!raceName.value) return ElMessage.warning('请输入作品名称')
if (!fileList.value.length) return ElMessage.warning('请上传作品')
console.log(fileList.value[0].raw, raceName.value, 'fileList.value[0].raw')
const fromData = new FormData()
fromData.append('annualCompid', annualCompid.value)
console.log(annualCompid.value);
fromData.append('file', fileList.value[0].raw)
// fileUrl.value = fileList.value[0].raw.name
fromData.append('workName', raceName.value)
const res: any = await uploadFile(fromData)
if (res && Array.isArray(res.message)) {
fileUrl.value = res.message;
} else {
fileUrl.value = [res.message];
}
WorkName.value = raceName.value;
handleClose();
};
// fromData.append('annualCompid', annualCompid.value)
// fromData.append('workName', raceName.value)
// const res: any = await uploadFileZp(fromData).then((res: any) => {
// console.log(res)
// if (res.code == 500) return ElMessage.warning(res.message)
// ElMessage.success(res.message)
// })
// console.log(res)
//
const ndbs = ref<any>({})
const ndbsXm = ref<any>({})
@ -233,12 +299,13 @@ const ndbsXm = ref<any>({})
const subLoading = ref(false)
async function submit() {
console.log(ruleForm, 'ruleForm')
if (!ruleForm.topicid) return ElMessage.warning('请选择题目')
upData.value.teamManagementList[0].realname = info.value.realname
upData.value.teamManagementList[0].userId = info.value.id
upData.value.annualCompid = route.query.annualCompid
upData.value.topicid = ruleForm.topicid
upData.value.workName = WorkName.value
upData.value.files = fileUrl.value
// if (!upData.value.teamName) {
// ElMessage({
// message: '',
@ -248,8 +315,8 @@ async function submit() {
// }
try {
subLoading.value = true
const res: any = await getSignUpApi(upData.value)
const res: any = await getSignUpApi({ ...upData.value })
console.log(res, 999999999)
ElMessage({
message: res?.message || res?.result || '报名成功',
type: 'success',
@ -274,6 +341,9 @@ const ruleForm = reactive<any>({
id: route.query.id,
topicid: '',
objName: route.query.objName,
// requireUploadWorks: ndbsXm.requireUploadWorks,
raceName: WorkName.value,
fileUrl: fileUrl.value
})
const options = ref([])
if (route.query.edit) {
@ -289,7 +359,7 @@ if (route.query.edit) {
ruleForm.teamName = res.result.teamName
ruleForm.topicid = res.result.topicObj ? res.result.topicObj.id : ''
ruleForm.objName = res.result.annualCompPointName
ruleForm.requireUploadWorks = res.result.requireUploadWorks
options.value = res.result.topicList.map((item) => {
return {
value: item.id,
@ -392,7 +462,7 @@ getTopicListApi()
margin: 0 auto;
width: 1397px;
& > * {
&>* {
background: #ffffff;
}
@ -462,7 +532,8 @@ getTopicListApi()
line-height: 39px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3; /* 限制显示的行数 */
-webkit-line-clamp: 3;
/* 限制显示的行数 */
overflow: hidden;
text-overflow: ellipsis;
}
@ -472,6 +543,7 @@ getTopicListApi()
.right {
.info-box {
width: 210px;
.name {
height: 20px;
font-family:

Loading…
Cancel
Save