|
@@ -12,6 +12,7 @@
|
|
|
import { ElMessage, UploadRawFile } from 'element-plus';
|
|
import { ElMessage, UploadRawFile } from 'element-plus';
|
|
|
import { unformatAttachment, formatAttachmentList } from '@/components/UploadFiles/utils';
|
|
import { unformatAttachment, formatAttachmentList } from '@/components/UploadFiles/utils';
|
|
|
import { uploadFileApi, UPLOAD_BIZ_TYPE } from '@/api/minio';
|
|
import { uploadFileApi, UPLOAD_BIZ_TYPE } from '@/api/minio';
|
|
|
|
|
+ import { downloadFile } from '@/views/disaster/utils';
|
|
|
|
|
|
|
|
import { debounce } from 'lodash-es';
|
|
import { debounce } from 'lodash-es';
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
@@ -49,9 +50,10 @@
|
|
|
courseIntroduction: '',
|
|
courseIntroduction: '',
|
|
|
courseContent: '', //[] as FileItem[],
|
|
courseContent: '', //[] as FileItem[],
|
|
|
isSign: 0,
|
|
isSign: 0,
|
|
|
- courseImg: [] as FileItem[],
|
|
|
|
|
|
|
+ courseImg: '', //[] as FileItem[],
|
|
|
});
|
|
});
|
|
|
const fileList = ref<FileItem[]>([]);
|
|
const fileList = ref<FileItem[]>([]);
|
|
|
|
|
+ const courseImgList = ref<FileItem[]>([]);
|
|
|
const fileInfo = ref<any>(null);
|
|
const fileInfo = ref<any>(null);
|
|
|
|
|
|
|
|
const categoryOptions = ref([
|
|
const categoryOptions = ref([
|
|
@@ -83,7 +85,7 @@ const openState = ref(false)
|
|
|
// 编辑/查看模式,加载现有详情数据
|
|
// 编辑/查看模式,加载现有详情数据
|
|
|
// 这里可以调用接口获取当前培训课程的信息,并填充到 form 中
|
|
// 这里可以调用接口获取当前培训课程的信息,并填充到 form 中
|
|
|
await queryEducationTrainingPlanCourseDetail(props.currentId).then((res) => {
|
|
await queryEducationTrainingPlanCourseDetail(props.currentId).then((res) => {
|
|
|
- console.log(res, '课程详情',);
|
|
|
|
|
|
|
+ // console.log(res, '课程详情',);
|
|
|
Object.assign(form, {
|
|
Object.assign(form, {
|
|
|
courseType: res.courseType,
|
|
courseType: res.courseType,
|
|
|
courseName: res.courseName,
|
|
courseName: res.courseName,
|
|
@@ -98,12 +100,12 @@ const openState = ref(false)
|
|
|
form.groupOfParticipants = res.groupOfParticipants ? res.groupOfParticipants.split(',').map(Number) : [];
|
|
form.groupOfParticipants = res.groupOfParticipants ? res.groupOfParticipants.split(',').map(Number) : [];
|
|
|
// 编辑和查看时 没有回显
|
|
// 编辑和查看时 没有回显
|
|
|
if(res.courseImg){
|
|
if(res.courseImg){
|
|
|
- form.courseImg = [JSON.parse(res.courseImg)]
|
|
|
|
|
|
|
+ form.courseImg = JSON.parse(res.courseImg)
|
|
|
|
|
+ courseImgList.value = JSON.parse(res.courseImg) || []
|
|
|
}
|
|
}
|
|
|
if(res.courseContent){
|
|
if(res.courseContent){
|
|
|
- // handleFileExceed(JSON.parse(res.courseContent))
|
|
|
|
|
- // fileList.value = JSON.parse(res.courseContent) || [];
|
|
|
|
|
- // form.courseContent = res.courseContent
|
|
|
|
|
|
|
+ fileList.value = JSON.parse(res.courseContent) || [];
|
|
|
|
|
+ form.courseContent = JSON.parse(res.courseContent)
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
} else if (props.state === 'add') {
|
|
} else if (props.state === 'add') {
|
|
@@ -145,13 +147,24 @@ const openState = ref(false)
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 上传图片
|
|
// 上传图片
|
|
|
- const handleImageUploadChange = async (uploadFile: any, uploadFiles: any) => {
|
|
|
|
|
- form.courseImg = uploadFiles;
|
|
|
|
|
- if(uploadFile.raw){
|
|
|
|
|
- let res = await formatAttachment(uploadFile.raw)
|
|
|
|
|
- console.log(res, '图片上传')
|
|
|
|
|
- if(res){
|
|
|
|
|
- ElMessage.success('上传成功')
|
|
|
|
|
|
|
+ const handleImageUploadChange = async (file: any, fileLists: any) => {
|
|
|
|
|
+
|
|
|
|
|
+ if(file.raw){
|
|
|
|
|
+ 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
|
|
|
|
|
+ }
|
|
|
|
|
+ courseImgList.value = fileLists;
|
|
|
|
|
+ form.courseImg = JSON.stringify(fileLists);
|
|
|
|
|
+ ElMessage.success('上传成功');
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ ElMessage.error('上传失败,请重试');
|
|
|
|
|
+ // 上传失败时,可以从 fileLists 中移除该文件
|
|
|
|
|
+ courseImgList.value = fileLists.filter(f => f.uid !== file.uid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -275,16 +288,7 @@ const openState = ref(false)
|
|
|
fileList.value = fileLists.filter(f => f.uid !== file.uid);
|
|
fileList.value = fileLists.filter(f => f.uid !== file.uid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(file.raw){
|
|
|
|
|
- let res = await formatAttachment(file.raw)
|
|
|
|
|
- console.log(res, '文件上传')
|
|
|
|
|
- if(res){
|
|
|
|
|
- ElMessage.success('上传成功')
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // // 直接替换为新文件
|
|
|
|
|
- // fileList.value = [file.raw];
|
|
|
|
|
- // form.courseContent = file; // 更新表单数据
|
|
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 提交保存/编辑
|
|
// 提交保存/编辑
|
|
@@ -304,9 +308,8 @@ const openState = ref(false)
|
|
|
const basePayload = {
|
|
const basePayload = {
|
|
|
...form,
|
|
...form,
|
|
|
petpiId: props.currentId,
|
|
petpiId: props.currentId,
|
|
|
- courseImg: form.courseImg[0],
|
|
|
|
|
};
|
|
};
|
|
|
- console.log('提交的表单数据:', basePayload);
|
|
|
|
|
|
|
+ // console.log('提交的表单数据:', basePayload);
|
|
|
|
|
|
|
|
if (isCreateMode.value) {
|
|
if (isCreateMode.value) {
|
|
|
// 新增,创建接口
|
|
// 新增,创建接口
|
|
@@ -417,7 +420,6 @@ const openState = ref(false)
|
|
|
<Editor
|
|
<Editor
|
|
|
style="height: 400px; overflow-y: auto"
|
|
style="height: 400px; overflow-y: auto"
|
|
|
v-model="form.courseIntroduction"
|
|
v-model="form.courseIntroduction"
|
|
|
- mode="disabled"
|
|
|
|
|
:disabled="isViewMode"
|
|
:disabled="isViewMode"
|
|
|
:defaultConfig="editorConfig"
|
|
:defaultConfig="editorConfig"
|
|
|
@on-created="handleEditorCreated"
|
|
@on-created="handleEditorCreated"
|
|
@@ -446,6 +448,14 @@ const openState = ref(false)
|
|
|
<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 class="file-list" >
|
|
|
|
|
+ <div class="file-item" v-for="file in fileList" :key="file.fileId">
|
|
|
|
|
+ <span class="file-item--name">{{ file.fileName }}</span>
|
|
|
|
|
+ <div class="file-item--footer">
|
|
|
|
|
+ <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)">下载</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="是否需要签名:" prop="isSign">
|
|
<el-form-item label="是否需要签名:" prop="isSign">
|
|
@@ -460,7 +470,7 @@ const openState = ref(false)
|
|
|
class="image-uploader"
|
|
class="image-uploader"
|
|
|
ref="courseImgRef"
|
|
ref="courseImgRef"
|
|
|
action="#"
|
|
action="#"
|
|
|
- :file-list="form.courseImg"
|
|
|
|
|
|
|
+ :file-list="courseImgList"
|
|
|
:disabled="isViewMode"
|
|
:disabled="isViewMode"
|
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
|
:limit="1"
|
|
:limit="1"
|