|
@@ -282,6 +282,7 @@ import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
import { CourseApi, CourseVO } from '@/api/bjdx/course'
|
|
import { CourseApi, CourseVO } from '@/api/bjdx/course'
|
|
|
import { defaultProps, handleTree } from '@/utils/tree'
|
|
import { defaultProps, handleTree } from '@/utils/tree'
|
|
|
import { CourseTypeApi } from '@/api/bjdx/coursetype'
|
|
import { CourseTypeApi } from '@/api/bjdx/coursetype'
|
|
|
|
|
+import { deleteFileByUrl } from '@/api/infra/file'
|
|
|
import AiGengrate from './aiGenerate/aiGengrate.vue'
|
|
import AiGengrate from './aiGenerate/aiGengrate.vue'
|
|
|
|
|
|
|
|
/** 课程 表单 */
|
|
/** 课程 表单 */
|
|
@@ -341,6 +342,7 @@ const formData = ref({
|
|
|
courseOrder: undefined,
|
|
courseOrder: undefined,
|
|
|
courseStatus: "0",
|
|
courseStatus: "0",
|
|
|
tenantId: undefined,
|
|
tenantId: undefined,
|
|
|
|
|
+ replacedUrls: [],
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 添加上传进度相关的状态
|
|
// 添加上传进度相关的状态
|
|
@@ -393,6 +395,18 @@ const submitForm = async () => {
|
|
|
// 提交请求
|
|
// 提交请求
|
|
|
formLoading.value = true
|
|
formLoading.value = true
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 删除所有被替换的URL链接
|
|
|
|
|
+ if (formData.value.replacedUrls && formData.value.replacedUrls.length > 0) {
|
|
|
|
|
+ for (const url of formData.value.replacedUrls) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ console.log('删除文件:', url)
|
|
|
|
|
+ await deleteFileByUrl(url)
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('删除文件失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const data = { ...formData.value } as unknown as CourseVO
|
|
const data = { ...formData.value } as unknown as CourseVO
|
|
|
if (data.courseContentType === 'image') {
|
|
if (data.courseContentType === 'image') {
|
|
|
data.courseImagePath = data.courseImagePath?.join(',')
|
|
data.courseImagePath = data.courseImagePath?.join(',')
|
|
@@ -430,9 +444,10 @@ const handleUploadComplete = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 处理 AI 生成课程保存
|
|
// 处理 AI 生成课程保存
|
|
|
-const handleAiSave = (scriptData) => {
|
|
|
|
|
|
|
+const handleAiSave = (scriptData, replacedUrls) => {
|
|
|
formData.value.courseContent = JSON.stringify(scriptData)
|
|
formData.value.courseContent = JSON.stringify(scriptData)
|
|
|
formData.value.courseContentType = 'ailab'
|
|
formData.value.courseContentType = 'ailab'
|
|
|
|
|
+ formData.value.replacedUrls = replacedUrls
|
|
|
showAiGengrate.value = false
|
|
showAiGengrate.value = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -483,6 +498,7 @@ const resetForm = () => {
|
|
|
courseOrder: undefined,
|
|
courseOrder: undefined,
|
|
|
courseStatus: "0",
|
|
courseStatus: "0",
|
|
|
tenantId: undefined,
|
|
tenantId: undefined,
|
|
|
|
|
+ replacedUrls: [],
|
|
|
}
|
|
}
|
|
|
formRef.value?.resetFields()
|
|
formRef.value?.resetFields()
|
|
|
}
|
|
}
|