|
|
@ -1,9 +1,11 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { ref } from 'vue' |
|
|
|
import { ref } from 'vue' |
|
|
|
|
|
|
|
// import axios from 'axios' |
|
|
|
import { CourseResourceControllerService } from '../../../../generated/services/CourseResourceControllerService' |
|
|
|
import { CourseResourceControllerService } from '../../../../generated/services/CourseResourceControllerService' |
|
|
|
const props = defineProps(['dafulIndex']) |
|
|
|
const props = defineProps(['dafulIndex']) |
|
|
|
import { QuillEditor } from '@vueup/vue-quill' |
|
|
|
import { QuillEditor } from '@vueup/vue-quill' |
|
|
|
import '@vueup/vue-quill/dist/vue-quill.snow.css' |
|
|
|
import '@vueup/vue-quill/dist/vue-quill.snow.css' |
|
|
|
|
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
//默认抽屉隐藏 |
|
|
|
//默认抽屉隐藏 |
|
|
|
const visibleDramwer = ref(false) |
|
|
|
const visibleDramwer = ref(false) |
|
|
|
//默认数据 |
|
|
|
//默认数据 |
|
|
@ -63,12 +65,17 @@ const selectOp = ref([ |
|
|
|
{ label: '文件', value: '5' }, |
|
|
|
{ label: '文件', value: '5' }, |
|
|
|
{ label: '音频', value: '6' }, |
|
|
|
{ label: '音频', value: '6' }, |
|
|
|
]) |
|
|
|
]) |
|
|
|
const handleSel = () => {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上传图片 |
|
|
|
const fileList = ref([]) |
|
|
|
import type { UploadProps, UploadUserFile } from 'element-plus' |
|
|
|
function clearFileList() { |
|
|
|
|
|
|
|
fileList.value.length = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const handleSel = () => { |
|
|
|
|
|
|
|
fileList.value.length = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fileList = ref<UploadUserFile[]>([]) |
|
|
|
//上传图片 |
|
|
|
|
|
|
|
import type { UploadProps } from 'element-plus' |
|
|
|
|
|
|
|
|
|
|
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => { |
|
|
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => { |
|
|
|
console.log(uploadFile, uploadFiles) |
|
|
|
console.log(uploadFile, uploadFiles) |
|
|
@ -77,6 +84,82 @@ const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => { |
|
|
|
const handlePreview: UploadProps['onPreview'] = (file) => { |
|
|
|
const handlePreview: UploadProps['onPreview'] = (file) => { |
|
|
|
console.log(file) |
|
|
|
console.log(file) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const formRef = ref() |
|
|
|
|
|
|
|
function isSubmit() { |
|
|
|
|
|
|
|
formRef.value.validate((valid, fields) => { |
|
|
|
|
|
|
|
if (valid) { |
|
|
|
|
|
|
|
const params = { |
|
|
|
|
|
|
|
name: formModel.value.name, |
|
|
|
|
|
|
|
type: selectVal.value, |
|
|
|
|
|
|
|
img: fileList.value[0]?.raw, |
|
|
|
|
|
|
|
description: formModel.value.description, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log('根据参数:', params, '去调用接口???') |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.log('error submit!', fields) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// upd |
|
|
|
|
|
|
|
const beforeAvatarUpload = (rawFile) => { |
|
|
|
|
|
|
|
console.log('执行了') |
|
|
|
|
|
|
|
switch (+selectVal.value) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
if (rawFile.type !== 'application/vnd.ms-powerpoint') { |
|
|
|
|
|
|
|
clearFileList() |
|
|
|
|
|
|
|
ElMessage.error('必须是ppt文件!') |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
clearFileList() |
|
|
|
|
|
|
|
fileList.value.push(rawFile) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
if (!rawFile.type.startsWith('image/')) { |
|
|
|
|
|
|
|
clearFileList() |
|
|
|
|
|
|
|
ElMessage.error('必须是??文件!') |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
clearFileList() |
|
|
|
|
|
|
|
fileList.value.push(rawFile) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
// case 3: |
|
|
|
|
|
|
|
// if (false) { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// ElMessage.error('必须是??文件!') |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// fileList.value.push(rawFile) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
// case 4: |
|
|
|
|
|
|
|
// if (false) { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// ElMessage.error('必须是??文件!') |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// fileList.value.push(rawFile) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
// case 5: |
|
|
|
|
|
|
|
// if (false) { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// ElMessage.error('必须是??文件!') |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// fileList.value.push(rawFile) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
// case 6: |
|
|
|
|
|
|
|
// if (false) { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// ElMessage.error('必须是??文件!') |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// clearFileList() |
|
|
|
|
|
|
|
// fileList.value.push(rawFile) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<el-drawer |
|
|
|
<el-drawer |
|
|
@ -118,11 +201,13 @@ const handlePreview: UploadProps['onPreview'] = (file) => { |
|
|
|
<el-form-item label="上传资源" prop="fileList"> |
|
|
|
<el-form-item label="上传资源" prop="fileList"> |
|
|
|
<el-upload |
|
|
|
<el-upload |
|
|
|
v-model:file-list="fileList" |
|
|
|
v-model:file-list="fileList" |
|
|
|
|
|
|
|
:limit="1" |
|
|
|
class="upload-demo" |
|
|
|
class="upload-demo" |
|
|
|
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" |
|
|
|
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" |
|
|
|
:on-preview="handlePreview" |
|
|
|
:on-preview="handlePreview" |
|
|
|
:on-remove="handleRemove" |
|
|
|
:on-remove="handleRemove" |
|
|
|
list-type="picture" |
|
|
|
list-type="picture" |
|
|
|
|
|
|
|
:before-upload="beforeAvatarUpload" |
|
|
|
> |
|
|
|
> |
|
|
|
<el-button type="primary">点击上传资源</el-button> |
|
|
|
<el-button type="primary">点击上传资源</el-button> |
|
|
|
<template #tip> |
|
|
|
<template #tip> |
|
|
@ -135,7 +220,7 @@ const handlePreview: UploadProps['onPreview'] = (file) => { |
|
|
|
<el-form-item label="资源简介" prop="description"> |
|
|
|
<el-form-item label="资源简介" prop="description"> |
|
|
|
<div class="editor"> |
|
|
|
<div class="editor"> |
|
|
|
<quill-editor |
|
|
|
<quill-editor |
|
|
|
v-model:description="formModel.description" |
|
|
|
v-model:content="formModel.description" |
|
|
|
content-type="html" |
|
|
|
content-type="html" |
|
|
|
theme="snow" |
|
|
|
theme="snow" |
|
|
|
></quill-editor> |
|
|
|
></quill-editor> |
|
|
@ -143,7 +228,7 @@ const handlePreview: UploadProps['onPreview'] = (file) => { |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary">取消</el-button> |
|
|
|
<el-button type="primary">取消</el-button> |
|
|
|
<el-button type="info">确定</el-button> |
|
|
|
<el-button type="info" @click="isSubmit">确定</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
</el-drawer> |
|
|
|
</el-drawer> |
|
|
|