|
|
@@ -107,8 +107,6 @@
|
|
|
:on-change="handleFileChange"
|
|
|
accept=".rar, .zip, .doc, .docx, .pdf, .mp4"
|
|
|
:file-list="fileList"
|
|
|
- :limit="1"
|
|
|
- :on-exceed="handleFileExceed"
|
|
|
>
|
|
|
<el-button type="default">
|
|
|
<el-icon style="margin-right: 6px">
|
|
|
@@ -229,17 +227,8 @@
|
|
|
fileName: `${uuid}-${timestamp}-${random}`,
|
|
|
file: data,
|
|
|
});
|
|
|
- const fileType = data.fileType;
|
|
|
- const fileSize = data.fileSize;
|
|
|
- const fileId = data.fileId;
|
|
|
- const fileUrl = res.url;
|
|
|
- return {
|
|
|
- fileName,
|
|
|
- fileType,
|
|
|
- fileSize,
|
|
|
- fileUrl,
|
|
|
- fileId,
|
|
|
- };
|
|
|
+
|
|
|
+ return res
|
|
|
};
|
|
|
// 文件选择更新
|
|
|
const courseContentUpload = ref();
|
|
|
@@ -252,7 +241,7 @@
|
|
|
courseContentUpload.value!.handleStart(file); // 手动触发上传
|
|
|
};
|
|
|
// 课程内容文件上传
|
|
|
- const handleFileChange = async (file, fileList) => {
|
|
|
+ const handleFileChange = async (file, fileLists) => {
|
|
|
|
|
|
if (!allowedTypes.includes(file.raw.type)) {
|
|
|
ElMessage.error('不支持的文件格式');
|
|
|
@@ -265,17 +254,24 @@
|
|
|
}
|
|
|
|
|
|
if(file.raw){
|
|
|
- let res = await formatAttachment(file.raw)
|
|
|
- console.log(res, '文件上传')
|
|
|
- // form.uploadAttach =
|
|
|
-
|
|
|
- if(res){
|
|
|
- ElMessage.success('上传成功')
|
|
|
+ try {
|
|
|
+ const res = await formatAttachment(file.raw);
|
|
|
+
|
|
|
+ const targetFile = fileLists.find(f => f.uid === file.uid);
|
|
|
+ if (targetFile) {
|
|
|
+ targetFile.url = res.url;
|
|
|
+ targetFile.contentType = res.contentType
|
|
|
+ }
|
|
|
+ fileList.value = fileLists;
|
|
|
+ form.uploadAttach = JSON.stringify(fileList.value);
|
|
|
+ ElMessage.success('上传成功');
|
|
|
+ } catch (error) {
|
|
|
+ ElMessage.error('上传失败,请重试');
|
|
|
+ // 上传失败时,可以从 fileLists 中移除该文件
|
|
|
+ fileList.value = fileLists.filter(f => f.uid !== file.uid);
|
|
|
}
|
|
|
}
|
|
|
- // 直接替换为新文件
|
|
|
- fileList.value = [file.raw];
|
|
|
- form.uploadAttach = file; // 更新表单数据
|
|
|
+
|
|
|
};
|
|
|
const saveSummary = async()=>{
|
|
|
try {
|
|
|
@@ -285,10 +281,13 @@
|
|
|
} catch (e) {
|
|
|
ElMessage.error('更新小结失败');
|
|
|
}
|
|
|
+ dialogVisible.value = false
|
|
|
}
|
|
|
const handleSummary = async (row) => {
|
|
|
dialogVisible.value = true
|
|
|
form.id = row.id
|
|
|
+ form.trainingSummary = ''
|
|
|
+ form.uploadAttach = ''
|
|
|
};
|
|
|
const handleSizeChange = (value: number) => {
|
|
|
pagination.pageSize = value;
|