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

通用上传接口

parent beb9b637
......@@ -66,3 +66,11 @@ export function exportCmsContest(query) {
responseType: 'blob'
})
}
// 7.上传接口
export function uploadPublic(data) {
return request({
url: 'common/fileUpload',
method: 'post',
data
})
}
......@@ -61,7 +61,8 @@
<el-form-item label="封面:">
<el-upload
class="avatar-uploader"
:action="fileUpload"
action="#"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
......@@ -96,6 +97,7 @@
<script >
import { VueEditor } from 'vue2-editor'
import { addCmsProject, getCmsProject, updateCmsProject } from '@/api/contentManagement/cmsProject'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default {
components: {
......@@ -176,6 +178,21 @@ export default {
this.getDetail()
},
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() {
console.log('查询详情')
......
......@@ -155,13 +155,14 @@
<!-- </el-upload>-->
<el-upload
class="avatar-uploader"
:action="fileUpload"
action="#"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<!-- <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="imageUrl" :src="imageUrl" 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" />
</el-upload>
</el-form-item>
......@@ -187,7 +188,7 @@ import {
delCmsContest,
addCmsContest,
updateCmsContest,
exportCmsContest
exportCmsContest, uploadPublic
} from '@/api/contentManagement/sysContest'
import commonField from '@/utils/commonField'
......@@ -223,7 +224,7 @@ export default {
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://192.168.1.12:8888/eduServer/',
imageUrl: '',
......@@ -265,6 +266,21 @@ export default {
this.getList() // 列表查询
},
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() {
this.loading = true
......
......@@ -189,7 +189,8 @@
<el-upload
:show-file-list="false"
list-type="picture-card"
:action="fileUpload"
action="#"
:http-request="handleUpload"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
:on-remove="handleRemove"
......@@ -232,6 +233,7 @@ import {
exportCmsDevelopment
} from '@/api/contentManagement/cmsDevelopment'
import commonField from '@/utils/commonField'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default {
name: 'CmsDevelopment',
......@@ -241,7 +243,7 @@ export default {
dialogImageUrl: '',
dialogVisible: 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,
// 总条数
......@@ -323,7 +325,21 @@ export default {
this.getList() // 列表查询
},
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) {
console.log('res', res)
this.imageUrl = URL.createObjectURL(file.raw)
......
......@@ -86,7 +86,8 @@
<el-form-item label="封面:">
<el-upload
class="avatar-uploader"
:action="fileUpload"
action="#"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
......@@ -123,6 +124,7 @@ import {
getSysContentNewsInformation, updateSysContentNewsInformation
} from '@/api/contentManagement/sysContentNewsInformation'
import { VueEditor } from 'vue2-editor'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default {
components: {
......@@ -203,6 +205,21 @@ export default {
this.getDetail()
},
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() {
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