fix:作业文件上传文件名称处理

This commit is contained in:
wyx
2023-02-27 02:22:11 +08:00
parent 2bd9cee5a3
commit 649b3bacd3
2 changed files with 5 additions and 10 deletions

View File

@@ -1,10 +1,10 @@
<template>
<el-upload
ref="imageRef"
:file-list="files"
:show-file-list="false"
:limit="max"
action="/file/upload"
ref="imageRef"
:action="FILE_UPLOAD_ANNEX"
:auto-upload="false"
:on-exceed="exceed"
:on-change="handleChange">
@@ -20,12 +20,11 @@ import { defineProps, ref, watch } from "vue";
import { ElMessage } from "element-plus";
import { computed } from "vue";
import { useStore } from "vuex";
import { request,fileUp } from "@/api/request";
import { FILE_UPLOAD_ANNEX } from "@/api/api";
const store = useStore();
const userInfo = computed(() => store.state.userInfo);
const props = defineProps({
value: [],
max: {
@@ -35,7 +34,6 @@ const props = defineProps({
})
const emit = defineEmits()
const files = ref([])
const imageRef = ref()
@@ -48,25 +46,23 @@ function exceed() {
}
function handleChange(file) {
console.log('111111',userInfo.value)
let fileName = userInfo.value.realName + '-' + userInfo.value.userNo + '-' + file.name;
let f = new File([file.raw],fileName);
f.uid = file.uid;
file.raw = f;
console.log(file.raw)
//
imageRef.value.submit();
if (file.response && file.response.code === 200) {
file.url = file.response.data
}
const index = files.value.findIndex(f => f.uid === file.uid)
if (index === -1) {
files.value.unshift(file)
} else {
files.value[index] = file
}
emit('update:value', files.value)
}
@@ -93,7 +89,6 @@ function abort(i) {
imageRef.value.abort(files.value[i].raw)
}
defineExpose({ reUpload, remove, clearFiles })
</script>

View File

@@ -451,7 +451,7 @@ import {
import dayjs from "dayjs";
import { useRouter } from "vue-router";
// import store from "@/store";
import UploadImg from "@/components/img/UploadImg2HomeWork.vue";
import UploadImg from "@/components/img/UploadImgHomeWork.vue";
import FileTypeImg from "@/components/FileTypeImg.vue";
import { useRoute } from "vue-router/dist/vue-router";
import { ElMessage } from "element-plus";