|
|
@@ -31,7 +31,7 @@
|
|
|
<el-button color="#597d3b" @click="enroll">加入课程</el-button>
|
|
|
</template>
|
|
|
<template v-if="showEdit && role == 'teachers'">
|
|
|
- <el-button style="background-color: #4a90c4 ;color: white" @click="visible = true; fileList[0] = {name: '壁纸', url: newCourseInfo.courseImages[0]}">编辑课程</el-button>
|
|
|
+ <el-button style="background-color: #4a90c4 ;color: white" @click="visible = true; fileList.value = newCourseInfo.courseImages[0] ? [{ name: '壁纸', url: newCourseInfo.courseImages[0], uid: Date.now(), status: 'success' }] : []">编辑课程</el-button>
|
|
|
<el-button style="background-color: #4a90c4 ;color: white" @click="$router.push(`/home/courseClass/${courseId}`)">班级管理</el-button>
|
|
|
</template>
|
|
|
</div>
|
|
|
@@ -95,6 +95,7 @@
|
|
|
:on-error="handleError"
|
|
|
:on-exceed="handleExceed"
|
|
|
:on-change="handleChange"
|
|
|
+ :on-remove="handleRemove"
|
|
|
list-type="picture-card"
|
|
|
accept=".png, .jpg"
|
|
|
:auto-upload="false"
|
|
|
@@ -124,7 +125,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {onMounted, reactive, ref} from 'vue';
|
|
|
+import {onMounted, reactive, ref, nextTick} from 'vue';
|
|
|
import {
|
|
|
ElTabs,
|
|
|
ElTabPane,
|
|
|
@@ -291,6 +292,14 @@ const handleError: UploadProps['onError'] = (error: Error, uploadFile: UploadFil
|
|
|
console.log(error, uploadFile, uploadFiles)
|
|
|
}
|
|
|
|
|
|
+const handleRemove: UploadProps['onRemove'] = async (uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
|
+ // 删除图片后,将图片设置为空字符串,后端会处理为空
|
|
|
+ newCourseInfo.courseImages[0] = ''
|
|
|
+ await nextTick()
|
|
|
+ // 清空文件列表
|
|
|
+ fileList.value = []
|
|
|
+}
|
|
|
+
|
|
|
const handleExceed = (files, fileList) => {
|
|
|
// console.log(files)
|
|
|
uploadRef.value.clearFiles() //清空上传文件(限制一个,所以直接清空即可)
|