|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="cover-upload-row">
|
|
<div class="cover-upload-row">
|
|
|
|
|
+ <span v-if="form.id != ''" style="cursor: pointer; color: #0d84ff">{{ form.name }}</span>
|
|
|
<a-upload
|
|
<a-upload
|
|
|
:key="form.id"
|
|
:key="form.id"
|
|
|
:show-upload-list="false"
|
|
:show-upload-list="false"
|
|
@@ -9,11 +10,14 @@
|
|
|
:action="action"
|
|
:action="action"
|
|
|
:headers="headers"
|
|
:headers="headers"
|
|
|
>
|
|
>
|
|
|
- <a-button v-if="form.id == ''">
|
|
|
|
|
- <CloudUploadOutlined/>
|
|
|
|
|
- 上传文件
|
|
|
|
|
- </a-button>
|
|
|
|
|
- <span v-if="form.id != ''" style="cursor: pointer;">{{form.name}}</span>
|
|
|
|
|
|
|
+ <a-button v-if="form.id == ''" style="margin-left: 20px">
|
|
|
|
|
+ <CloudUploadOutlined/>
|
|
|
|
|
+ 上传文件
|
|
|
|
|
+ </a-button>
|
|
|
|
|
+ <a-button v-if="form.id != ''" style="margin-left: 20px">
|
|
|
|
|
+ <CloudUploadOutlined/>
|
|
|
|
|
+ 更换文件
|
|
|
|
|
+ </a-button>
|
|
|
</a-upload>
|
|
</a-upload>
|
|
|
<span class="upload-tip">支持ppt、word等格式文件上传,文件大小不超过10MB</span>
|
|
<span class="upload-tip">支持ppt、word等格式文件上传,文件大小不超过10MB</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -26,7 +30,8 @@ import {message} from 'ant-design-vue'
|
|
|
import {PictureOutlined, CloudUploadOutlined} from '@ant-design/icons-vue'
|
|
import {PictureOutlined, CloudUploadOutlined} from '@ant-design/icons-vue'
|
|
|
import tool from "@/utils/tool";
|
|
import tool from "@/utils/tool";
|
|
|
import sysConfig from '@/config/index'
|
|
import sysConfig from '@/config/index'
|
|
|
-const action = ref(sysConfig.API_URL+'/api/webapp/dev/file/uploadMinioReturnId')
|
|
|
|
|
|
|
+
|
|
|
|
|
+const action = ref(sysConfig.API_URL + '/api/webapp/dev/file/uploadMinioReturnId')
|
|
|
const headers = ref({
|
|
const headers = ref({
|
|
|
token: tool.data.get('TOKEN')
|
|
token: tool.data.get('TOKEN')
|
|
|
})
|
|
})
|
|
@@ -35,9 +40,9 @@ const headers = ref({
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
count: Number,
|
|
count: Number,
|
|
|
- default : () => 1
|
|
|
|
|
|
|
+ default: () => 1
|
|
|
})
|
|
})
|
|
|
-const emit = defineEmits(['update:visible', 'ok','handlerUpSelect','handlerNewSelect','handlerUpDoc'])
|
|
|
|
|
|
|
+const emit = defineEmits(['update:visible', 'ok', 'handlerUpSelect', 'handlerNewSelect', 'handlerUpDoc'])
|
|
|
|
|
|
|
|
const modalVisible = ref(props.visible)
|
|
const modalVisible = ref(props.visible)
|
|
|
watch(
|
|
watch(
|
|
@@ -52,18 +57,18 @@ watch(modalVisible, (v) => {
|
|
|
|
|
|
|
|
const formRef = ref()
|
|
const formRef = ref()
|
|
|
const file = ref({
|
|
const file = ref({
|
|
|
- id : '',
|
|
|
|
|
|
|
+ id: '',
|
|
|
name: '',
|
|
name: '',
|
|
|
})
|
|
})
|
|
|
const form = reactive({
|
|
const form = reactive({
|
|
|
|
|
|
|
|
- id : '',
|
|
|
|
|
|
|
+ id: '',
|
|
|
title: '',
|
|
title: '',
|
|
|
video: '',
|
|
video: '',
|
|
|
coverUrl: '',
|
|
coverUrl: '',
|
|
|
docUrl: '',
|
|
docUrl: '',
|
|
|
srtUrl: '',
|
|
srtUrl: '',
|
|
|
- name : ''
|
|
|
|
|
|
|
+ name: ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const rules = {
|
|
const rules = {
|
|
@@ -74,11 +79,11 @@ const rules = {
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleChange = (res) => {
|
|
const handleChange = (res) => {
|
|
|
- console.log('上传完毕',res)
|
|
|
|
|
- if (res.file && res.file.response &&res.file.response.code == 200) {
|
|
|
|
|
|
|
+ console.log('上传完毕', res)
|
|
|
|
|
+ if (res.file && res.file.response && res.file.response.code == 200) {
|
|
|
message.success('上传成功')
|
|
message.success('上传成功')
|
|
|
- form.id = res.file.response.data
|
|
|
|
|
- emit('handlerUpDoc',form.id)
|
|
|
|
|
|
|
+ form.id = res.file.response.data
|
|
|
|
|
+ emit('handlerUpDoc', form.id)
|
|
|
} else {
|
|
} else {
|
|
|
// message.error('上传失败')
|
|
// message.error('上传失败')
|
|
|
}
|
|
}
|
|
@@ -88,9 +93,9 @@ const handleChange = (res) => {
|
|
|
const setData = (item) => {
|
|
const setData = (item) => {
|
|
|
form.id = item.id
|
|
form.id = item.id
|
|
|
form.name = item.name
|
|
form.name = item.name
|
|
|
- emit('handlerUpDoc',form.id)
|
|
|
|
|
|
|
+ emit('handlerUpDoc', form.id)
|
|
|
}
|
|
}
|
|
|
-const beforeUploadDoc = (file) =>{
|
|
|
|
|
|
|
+const beforeUploadDoc = (file) => {
|
|
|
const isDoc = /\.(ppt|pptx|doc|docx|pdf)$/i.test(file.name)
|
|
const isDoc = /\.(ppt|pptx|doc|docx|pdf)$/i.test(file.name)
|
|
|
const isLt10M = file.size / 1024 / 1024 < 10
|
|
const isLt10M = file.size / 1024 / 1024 < 10
|
|
|
if (!isDoc) {
|
|
if (!isDoc) {
|
|
@@ -106,12 +111,11 @@ const beforeUploadDoc = (file) =>{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const dummyRequest = ({onSuccess}) => {
|
|
const dummyRequest = ({onSuccess}) => {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
const setFile = (fileData) => {
|
|
const setFile = (fileData) => {
|
|
|
- console.log("设置了文件",fileData)
|
|
|
|
|
|
|
+ console.log("设置了文件", fileData)
|
|
|
file.value.id = fileData.id
|
|
file.value.id = fileData.id
|
|
|
file.value.name = fileData.fileName
|
|
file.value.name = fileData.fileName
|
|
|
}
|
|
}
|
|
@@ -128,7 +132,7 @@ const handleCancel = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
- getData,setFile,setData
|
|
|
|
|
|
|
+ getData, setFile, setData
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|