mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-24 02:02:55 +08:00
fix(upload): 统一使用$message提示并优化文件校验逻辑
- 移除重复引入的ElMessage组件 - 使用$message.error替换ElMessage错误提示 - 添加文件上传前的console.log调试信息 - 优化文件格式和大小校验的提示逻辑 - 在dragTable.vue中使用ElInput组件替换原生input - 优化HomeWorkComp.vue中附件显示条件判断 chore(style): 统一element-plus弹窗样式 - 为el-dialog和el-message-box添加圆角样式 - 调整消息框标题和内容的字体样式 - 优化按钮样式和间距布局 - 规范化弹窗内部元素的显示效果
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { reactive, onMounted, ref, h } from "vue";
|
||||
import { ElButton, ElInput, ElUpload } from "element-plus";
|
||||
import { $message, ElMessage } from "@/utils/useMessage";
|
||||
import { $message } from "@/utils/useMessage";
|
||||
import BasicTable from "@/components/BasicElTable/BasicTable.vue";
|
||||
import {
|
||||
getPageListByType,
|
||||
@@ -248,12 +248,13 @@ const handleUploadSuccess = (res, file) => {
|
||||
|
||||
// 上传前处理
|
||||
const handleBeforeUpload = (file) => {
|
||||
console.log(file);
|
||||
const { fileType, name, uploadSize, uploadSizeName } = getMapsItem(
|
||||
props.resType
|
||||
);
|
||||
|
||||
if (file.name.lastIndexOf(".") === -1) {
|
||||
ElMessage({ message: `文件格式不正确!`, type: "error", offset: 100 });
|
||||
$message.error(`文件格式不正确!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -262,11 +263,7 @@ const handleBeforeUpload = (file) => {
|
||||
|
||||
// 校检文件类型
|
||||
if (fileType.join(",").indexOf(fileExtension) === -1) {
|
||||
ElMessage({
|
||||
message: `文件格式不正确, 请上传正确格式的${name}文件!`,
|
||||
type: "error",
|
||||
offset: 100,
|
||||
});
|
||||
$message.error(`文件格式不正确, 请上传正确格式的${name}文件!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -274,11 +271,7 @@ const handleBeforeUpload = (file) => {
|
||||
if (uploadSize) {
|
||||
const isLt = file.size / 1024 / 1024 < uploadSize;
|
||||
if (!isLt) {
|
||||
ElMessage({
|
||||
message: `上传文件大小不能超过 ${uploadSizeName} !`,
|
||||
type: "error",
|
||||
offset: 100,
|
||||
});
|
||||
$message.error(`上传文件大小不能超过 ${uploadSizeName} !`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ const removeHomeworkFile = () => {
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="附件">
|
||||
<div v-if="localDialogVideoForm.file !== ''" class="flex align-center">
|
||||
<div v-if="localDialogVideoForm.file" class="flex align-center">
|
||||
<a :href="fileBaseUrl + localDialogVideoForm.file" target="_blank"
|
||||
>下载作业附件
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user