添加资源上传

develoop
wenyu441069198 4 months ago
parent 6205c3fa39
commit efc569df5d
  1. 28
      src/views/courseResources/componse/resourceAdd.vue
  2. 2
      src/views/courseResources/index.vue

@ -3,23 +3,37 @@ import { ref } from 'vue'
const visibilerDrawer = ref(false)
import { ElMessage } from 'element-plus'
import { CourseResourceControllerService } from '../../../../generated/services/CourseResourceControllerService'
import tool from '@/utils/oss.js'
import { id } from 'element-plus/es/locales.mjs';
//
const defaultForm = {
description: '',
id: '',
id:'',
img: '', //
name: '',
type: '', //
path: '',
}
const imageUrl = ref('')
const onSelectFile = (uploadFile) => {
// console.log(uploadFile)
//oss
const upload = async (option) =>{
//
imageUrl.value = URL.createObjectURL(uploadFile.raw)
//
formModel.value.img = uploadFile.raw
imageUrl.value = URL.createObjectURL(option.raw)
const res = await tool.oss.upload(option.raw);//
const url = "https://wenyu132.oss-cn-beijing.aliyuncs.com/" + res.name;//url
console.log(url);
//url
formModel.value.img = url
}
// const onSelectFile = (uploadFile) => {
// // console.log(uploadFile)
// //
// imageUrl.value = URL.createObjectURL(uploadFile.raw)
// //
// formModel.value.img = uploadFile.raw
// }
//
const formModel = ref({
@ -184,7 +198,7 @@ defineExpose({
:show-file-list="false"
:auto-upload="false"
:before-upload="beforeAvatarUpload"
:on-change="onSelectFile"
:on-change="upload"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar" />
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>

@ -85,7 +85,7 @@ const param = ref({
download: '0',
content: '',
address: '/portal',
type: '1',
type: '4',
})
//
const generateRecords = async (rescource) => {

Loading…
Cancel
Save