Commit 7579b181 authored by 高宇's avatar 高宇

通用上传接口

parent beb9b637
...@@ -66,3 +66,11 @@ export function exportCmsContest(query) { ...@@ -66,3 +66,11 @@ export function exportCmsContest(query) {
responseType: 'blob' responseType: 'blob'
}) })
} }
// 7.上传接口
export function uploadPublic(data) {
return request({
url: 'common/fileUpload',
method: 'post',
data
})
}
...@@ -61,7 +61,8 @@ ...@@ -61,7 +61,8 @@
<el-form-item label="封面:"> <el-form-item label="封面:">
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
:action="fileUpload" action="#"
:http-request="handleUpload"
:show-file-list="false" :show-file-list="false"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload" :before-upload="beforeAvatarUpload"
...@@ -96,6 +97,7 @@ ...@@ -96,6 +97,7 @@
<script > <script >
import { VueEditor } from 'vue2-editor' import { VueEditor } from 'vue2-editor'
import { addCmsProject, getCmsProject, updateCmsProject } from '@/api/contentManagement/cmsProject' import { addCmsProject, getCmsProject, updateCmsProject } from '@/api/contentManagement/cmsProject'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default { export default {
components: { components: {
...@@ -176,6 +178,21 @@ export default { ...@@ -176,6 +178,21 @@ export default {
this.getDetail() this.getDetail()
}, },
methods: { methods: {
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'centralCase')
uploadPublic(formData).then(res => {
this.form.pictureId = res.data.businessId
this.imageUrl = this.imagePath + res.data.path
})
},
// 查询详情 // 查询详情
getDetail() { getDetail() {
console.log('查询详情') console.log('查询详情')
......
...@@ -155,13 +155,14 @@ ...@@ -155,13 +155,14 @@
<!-- </el-upload>--> <!-- </el-upload>-->
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
:action="fileUpload" action="#"
:http-request="handleUpload"
:show-file-list="false" :show-file-list="false"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload" :before-upload="beforeAvatarUpload"
> >
<!-- <img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">--> <img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">
<img v-if="form.url" :src="form.url" style="height: 200px;width: 200px"> <!-- <img v-if="form.url" :src="form.url" style="height: 200px;width: 200px">-->
<i v-else class="el-icon-plus avatar-uploader-icon" /> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
...@@ -187,7 +188,7 @@ import { ...@@ -187,7 +188,7 @@ import {
delCmsContest, delCmsContest,
addCmsContest, addCmsContest,
updateCmsContest, updateCmsContest,
exportCmsContest exportCmsContest, uploadPublic
} from '@/api/contentManagement/sysContest' } from '@/api/contentManagement/sysContest'
import commonField from '@/utils/commonField' import commonField from '@/utils/commonField'
...@@ -223,7 +224,7 @@ export default { ...@@ -223,7 +224,7 @@ export default {
dictValue: '0' dictValue: '0'
} }
], ],
fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'temp', fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'competitionSupport',
// imagePath: 'http://49.232.167.247:20020/eduServer/', // imagePath: 'http://49.232.167.247:20020/eduServer/',
imagePath: 'http://192.168.1.12:8888/eduServer/', imagePath: 'http://192.168.1.12:8888/eduServer/',
imageUrl: '', imageUrl: '',
...@@ -265,6 +266,21 @@ export default { ...@@ -265,6 +266,21 @@ export default {
this.getList() // 列表查询 this.getList() // 列表查询
}, },
methods: { methods: {
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'competitionSupport')
uploadPublic(formData).then(res => {
this.form.contestPicture = res.data.businessId
this.imageUrl = this.imagePath + res.data.path
})
},
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
this.loading = true this.loading = true
......
...@@ -189,7 +189,8 @@ ...@@ -189,7 +189,8 @@
<el-upload <el-upload
:show-file-list="false" :show-file-list="false"
list-type="picture-card" list-type="picture-card"
:action="fileUpload" action="#"
:http-request="handleUpload"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload" :before-upload="beforeAvatarUpload"
:on-remove="handleRemove" :on-remove="handleRemove"
...@@ -232,6 +233,7 @@ import { ...@@ -232,6 +233,7 @@ import {
exportCmsDevelopment exportCmsDevelopment
} from '@/api/contentManagement/cmsDevelopment' } from '@/api/contentManagement/cmsDevelopment'
import commonField from '@/utils/commonField' import commonField from '@/utils/commonField'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default { export default {
name: 'CmsDevelopment', name: 'CmsDevelopment',
...@@ -241,7 +243,7 @@ export default { ...@@ -241,7 +243,7 @@ export default {
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
disabled: false, disabled: false,
fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'temp', fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'development',
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 总条数 // 总条数
...@@ -323,7 +325,21 @@ export default { ...@@ -323,7 +325,21 @@ export default {
this.getList() // 列表查询 this.getList() // 列表查询
}, },
methods: { methods: {
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'developmentCourse')
uploadPublic(formData).then(res => {
this.form.img = res.data.businessId
this.imageUrl = this.imagePath + res.data.path
})
},
handleAvatarSuccess(res, file) { handleAvatarSuccess(res, file) {
console.log('res', res) console.log('res', res)
this.imageUrl = URL.createObjectURL(file.raw) this.imageUrl = URL.createObjectURL(file.raw)
......
...@@ -86,7 +86,8 @@ ...@@ -86,7 +86,8 @@
<el-form-item label="封面:"> <el-form-item label="封面:">
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
:action="fileUpload" action="#"
:http-request="handleUpload"
:show-file-list="false" :show-file-list="false"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload" :before-upload="beforeAvatarUpload"
...@@ -123,6 +124,7 @@ import { ...@@ -123,6 +124,7 @@ import {
getSysContentNewsInformation, updateSysContentNewsInformation getSysContentNewsInformation, updateSysContentNewsInformation
} from '@/api/contentManagement/sysContentNewsInformation' } from '@/api/contentManagement/sysContentNewsInformation'
import { VueEditor } from 'vue2-editor' import { VueEditor } from 'vue2-editor'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default { export default {
components: { components: {
...@@ -203,6 +205,21 @@ export default { ...@@ -203,6 +205,21 @@ export default {
this.getDetail() this.getDetail()
}, },
methods: { methods: {
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'newInformation')
uploadPublic(formData).then(res => {
this.form.pictureId = res.data.businessId
this.imageUrl = this.imagePath + res.data.path
})
},
// 查询详情 // 查询详情
getDetail() { getDetail() {
console.log('查询详情') console.log('查询详情')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment