|
@@ -138,40 +138,47 @@
|
|
|
};
|
|
};
|
|
|
const handleImageUploadSuccess = (response: any, file: any, fileList: any[]) => {};
|
|
const handleImageUploadSuccess = (response: any, file: any, fileList: any[]) => {};
|
|
|
|
|
|
|
|
- const handleFileChange = (file, fileList) => {
|
|
|
|
|
- // 验证文件类型
|
|
|
|
|
|
|
+const handleFileChange = (file, fileList) => {
|
|
|
|
|
+ // 1. 验证文件类型和大小
|
|
|
const allowedTypes = [
|
|
const allowedTypes = [
|
|
|
- 'application/rar',
|
|
|
|
|
- 'application/zip',
|
|
|
|
|
- 'application/msword',
|
|
|
|
|
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
|
|
|
- 'application/pdf',
|
|
|
|
|
- 'video/mp4',
|
|
|
|
|
|
|
+ 'application/rar',
|
|
|
|
|
+ 'application/zip',
|
|
|
|
|
+ 'application/msword',
|
|
|
|
|
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
|
|
|
+ 'application/pdf',
|
|
|
|
|
+ 'video/mp4'
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!allowedTypes.includes(file.raw.type)) {
|
|
if (!allowedTypes.includes(file.raw.type)) {
|
|
|
- ElMessage.error('不支持的文件格式');
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ ElMessage.error('不支持的文件格式');
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 验证文件大小
|
|
|
|
|
if (file.raw.size > 20 * 1024 * 1024) {
|
|
if (file.raw.size > 20 * 1024 * 1024) {
|
|
|
- ElMessage.error('文件大小不能超过20MB');
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ ElMessage.error('文件大小不能超过20MB');
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- console.log('选择的文件:', file.raw);
|
|
|
|
|
- fileList.value = [file.raw];
|
|
|
|
|
- // 生成文件信息JSON
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 关键修改:强制覆盖旧文件
|
|
|
|
|
+ fileList.value = [file.raw]; // 直接替换为新文件
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 生成文件信息JSON
|
|
|
fileInfo.value = {
|
|
fileInfo.value = {
|
|
|
- fileName: file.raw.name,
|
|
|
|
|
- fileSize: `${(file.raw.size / (1024 * 1024)).toFixed(2)} MB`,
|
|
|
|
|
- fileType: file.raw.type,
|
|
|
|
|
- lastModified: new Date(file.raw.lastModified).toLocaleString(),
|
|
|
|
|
- rawFile: file.raw, // 包含更多原始文件信息
|
|
|
|
|
|
|
+ fileName: file.raw.name,
|
|
|
|
|
+ fileSize: `${(file.raw.size / (1024 * 1024)).toFixed(2)} MB`,
|
|
|
|
|
+ fileType: file.raw.type,
|
|
|
|
|
+ lastModified: new Date(file.raw.lastModified).toLocaleString(),
|
|
|
|
|
+ rawFile: file.raw
|
|
|
};
|
|
};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+ const handleUploadSignsUploadSuccess = async (item, fileList) => {
|
|
|
|
|
+ // const attachment = await formatAttachmentList(fileList);
|
|
|
|
|
+ // item.attachment = attachment;
|
|
|
|
|
+
|
|
|
|
|
+ // form.courseImg = [...signRecords.value.level1, ...signRecords.value.level2, ...signRecords.value.level3];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const handleImageRemove = (file: any, fileList: any[]) => {};
|
|
|
|
|
|
|
|
|
|
// 文件上传
|
|
// 文件上传
|
|
|
const handleUploadSuccess = (files: FileItem[]) => {
|
|
const handleUploadSuccess = (files: FileItem[]) => {
|
|
@@ -276,21 +283,6 @@
|
|
|
<!-- <UploadFiles label="上传文件" :maxCount="1" :file-list="form.courseImg" :disabled="isViewMode"
|
|
<!-- <UploadFiles label="上传文件" :maxCount="1" :file-list="form.courseImg" :disabled="isViewMode"
|
|
|
accept=".rar,.zip,.doc,.docx,.pdf,.mp4" desc="支持格式:.rar .zip .doc .docx .pdf .mp4 ,单个文件不能超过20MB"
|
|
accept=".rar,.zip,.doc,.docx,.pdf,.mp4" desc="支持格式:.rar .zip .doc .docx .pdf .mp4 ,单个文件不能超过20MB"
|
|
|
:allow-all-file-types="true" @uploadSuccess="handleUploadSuccess" /> -->
|
|
:allow-all-file-types="true" @uploadSuccess="handleUploadSuccess" /> -->
|
|
|
-
|
|
|
|
|
- <!-- <el-upload action="https://jsonplaceholder.typicode.com/posts/" :on-exceed="handleExceed"
|
|
|
|
|
- :before-upload="beforeUpload" :file-list="fileList" :limit="1"
|
|
|
|
|
- accept=".rar, .zip, .doc, .docx, .pdf, .mp4">
|
|
|
|
|
- <el-button type="default" :disabled="isViewMode">
|
|
|
|
|
- <el-icon style="margin-right: 6px;">
|
|
|
|
|
- <UploadFilled />
|
|
|
|
|
- </el-icon> 选择附件
|
|
|
|
|
- </el-button>
|
|
|
|
|
- <template #tip>
|
|
|
|
|
- <div class="el-upload__tip">
|
|
|
|
|
- 支持格式:.rar .zip .doc .docx .pdf .mp4,单个文件不能超过20MB
|
|
|
|
|
- </div>
|
|
|
|
|
- </template>
|
|
|
|
|
-</el-upload> -->
|
|
|
|
|
<el-upload
|
|
<el-upload
|
|
|
action=""
|
|
action=""
|
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
@@ -309,12 +301,6 @@
|
|
|
<div class="el-upload__tip"> 支持格式:.rar .zip .doc .docx .pdf .mp4,单个文件不能超过20MB </div>
|
|
<div class="el-upload__tip"> 支持格式:.rar .zip .doc .docx .pdf .mp4,单个文件不能超过20MB </div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-upload>
|
|
</el-upload>
|
|
|
-
|
|
|
|
|
- <!-- 显示文件信息 -->
|
|
|
|
|
- <div v-if="fileInfo" class="file-info">
|
|
|
|
|
- <h3>文件信息:</h3>
|
|
|
|
|
- <pre>{{ fileInfo }}</pre>
|
|
|
|
|
- </div>
|
|
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="是否需要签名:" prop="isSign">
|
|
<el-form-item label="是否需要签名:" prop="isSign">
|
|
@@ -325,12 +311,19 @@
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="课程图片:" prop="courseImg">
|
|
<el-form-item label="课程图片:" prop="courseImg">
|
|
|
- <el-upload
|
|
|
|
|
|
|
+ <UploadFiles
|
|
|
|
|
+ accept=".jpeg,.jpg,.png,.svg"
|
|
|
|
|
+ label="上传文件"
|
|
|
|
|
+ :fileList="form.courseImg"
|
|
|
|
|
+ @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
|
|
|
|
|
+ />
|
|
|
|
|
+ <!-- <el-upload
|
|
|
class="image-uploader"
|
|
class="image-uploader"
|
|
|
- action="/api/admin/minio/uploadFile"
|
|
|
|
|
|
|
+ action="safety_api/api/admin/minio/uploadFile"
|
|
|
:file-list="form.courseContent"
|
|
:file-list="form.courseContent"
|
|
|
:disabled="isViewMode"
|
|
:disabled="isViewMode"
|
|
|
- :limit="5"
|
|
|
|
|
|
|
+ :limit="1"
|
|
|
|
|
+ accept=".jpg,.png,.jpeg"
|
|
|
:on-success="handleImageUploadSuccess"
|
|
:on-success="handleImageUploadSuccess"
|
|
|
:on-remove="handleImageRemove"
|
|
:on-remove="handleImageRemove"
|
|
|
list-type="picture-card"
|
|
list-type="picture-card"
|
|
@@ -342,7 +335,7 @@
|
|
|
<template #tip>
|
|
<template #tip>
|
|
|
<div class="el-upload__tip"> 支持格式:.jpg .png .jpeg,单个文件不能超过300k,设置一个默认图片。 </div>
|
|
<div class="el-upload__tip"> 支持格式:.jpg .png .jpeg,单个文件不能超过300k,设置一个默认图片。 </div>
|
|
|
</template>
|
|
</template>
|
|
|
- </el-upload>
|
|
|
|
|
|
|
+ </el-upload> -->
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
|
|
|