oss全部替换完成

master
yujialong 1 year ago
parent 2cb471ec92
commit d9f2543d30
  1. 10
      src/api/index.js
  2. 51
      src/components/editor.js
  3. 65
      src/components/quill/index.vue
  4. 2
      src/components/upload/index.vue
  5. 2
      src/components/upload/upload.js
  6. 69
      src/pages/activity/manage/add/index.vue
  7. 34
      src/pages/activity/manage/manage/noticeDetail.vue
  8. 170
      src/pages/course/add/index.vue
  9. 135
      src/pages/course/contentSettings/index.vue
  10. 138
      src/pages/information/addarticle/index.vue
  11. 78
      src/pages/match/add/step1.vue
  12. 18
      src/pages/match/add/step3.vue
  13. 101
      src/pages/match/manage/noticeDetail.vue
  14. 106
      src/pages/system/list/logo.vue
  15. 2
      src/setting.js

@ -14,6 +14,8 @@ export default {
deleteProfile : `users/users/userInfo/deleteProfile`,
refreshPageNotification : `nakadai/message/refreshPageNotification`,
getPlayAuth: `${uploadURL}oss/manage/getPlayAuth`, // 获取播放凭证
platformLogList: `nakadai/nakadai/log/platformLogList`,
logNotification: `nakadai/nakadai/log/logNotification`,
//实验台
@ -304,14 +306,6 @@ export default {
editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节
getSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/getSubsection`, // 根据小节id获取预览文件地址
// 阿里云文件/视频管理
fileDeletion: `${uploadURL}oss/manage/fileDeletion`, // 删除OSS文件
fileupload: `${uploadURL}oss/manage/fileupload`, // 文件上传
getPlayAuth: `${uploadURL}oss/manage/getPlayAuth`, // 获取播放凭证
removeMoreVideo: `${uploadURL}oss/manage/removeMoreVideo`, // 批量删除视频文件
removeVideo: `${uploadURL}oss/manage/removeVideo`, // 删除视频文件
fileUploadNakadai: `${host}nakadai/nakadai/oss/fileUpload`,
queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份
queryCity: `nakadai/nakadai/city/queryCity`, //查询城市
querySchoolData: `nakadai/nakadai/school/querySchool`, //根据学校名称查询学校信息

@ -1,7 +1,4 @@
import Axios from 'axios'
import Api from '@/api'
import Setting from '@/setting'
import Util from '@/libs/util'
import Oss from '@/components/upload/upload.js'
import { Loading } from 'element-ui'
export default {
//skin:'oxide-dark',
@ -315,21 +312,25 @@ export default {
powerpaste_allow_local_images: true,
powerpaste_word_import: 'clean',
powerpaste_html_import: 'clean',
urlconverter_callback: (url, node, onSave, name) => {
if (node === 'img' && url.startsWith('blob:')) {
// Do some custom URL conversion
tinymce.activeEditor && tinymce.activeEditor.uploadImages()
}
// Return new URL
return url
},
// 自定义上传
images_upload_handler: function (blobInfo, succFun, failFun) {
const form = new FormData()
form.append('file', blobInfo.blob()),
Axios({
method: 'post',
url: Api.fileUploadNakadai,
data: form,
headers: {
'Content-Type': 'multipart/form-data',
token: Util.local.get(Setting.tokenKey)
},
}).then(({ data }) => {
succFun(data.filesResult.fileUrl)
}).catch(res => {})
const blob = blobInfo.blob()
// blob转换为file
const file = new File([blob], blobInfo.filename(), {
type: 'application/json',
lastModified: Date.now()
});
Oss.upload(file).then(res => {
succFun(res.url)
})
},
//自定义文件选择器的回调内容 此方法只有在点击上方图片按钮才会触发
file_picker_callback: function (callback, value, meta) {
@ -347,21 +348,11 @@ export default {
input.setAttribute("accept", ".mp4");
input.onchange = function(){
let file = this.files[0];
let fd = new FormData();
fd.append("file", file);
const load = Loading.service()
Axios({
method: 'post',
url: Api.fileUploadNakadai,
data: fd,
headers: {
'Content-Type': 'multipart/form-data',
token: Util.local.get(Setting.tokenKey)
},
}).then(({ data }) => {
Oss.upload(file).then(res => {
load.close()
callback(data.filesResult.fileUrl)
}).catch(res => {
callback(res.url)
}).catch(e => {
load.close()
})
}

@ -15,14 +15,16 @@
:style="styles"
v-loading="loading"></div>
<el-upload :headers="headers"
:action="this.api.fileupload"
:before-upload="beforeUpload"
:on-success="editorUploadSuccess"
<Upload :max-size="1000"
:limit="100"
@beforeUpload="beforeUpload"
@onSuccess="editorUploadSuccess"
style="display: none">
<div slot="trigger">
<el-button :id="'editorUpload' + index"
type="primary">点击上传</el-button>
</el-upload>
</div>
</Upload>
</div>
<mavon-editor class="md"
v-model="mdVal"
@ -43,13 +45,15 @@ import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import toolbarOptions from "./options";
import axios from 'axios'
import { mavonEditor } from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default {
name: "quill",
components: {
Upload,
mavonEditor
},
props: {
@ -242,20 +246,16 @@ export default {
if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
return
}
const param = new FormData()
param.append('file', file)
// base64
this.$post(this.api.fileupload, param, {
headers: { "Content-Type": "multipart/form-data" }
}).then(res => {
// ossbase64
Oss.upload(file).then(res => {
var range = ins.getSelection()
if (range) {
//
ins.insertEmbed(range.index, 'image', res.data.filesResult.fileUrl)
ins.insertEmbed(range.index, 'image', res.url)
//
ins.setSelection(range.index + 1)
}
}).catch(res => { })
})
});
}
}, false)
@ -264,21 +264,26 @@ export default {
this.loading = true;
},
// quill
editorUploadSuccess (res) {
editorUploadSuccess (file) {
//
let quill = this.Quill;
let quill = this.Quill
//
if (res.data.filesResult.fileUrl) {
if (file.url) {
//
let length = quill.getSelection().index;
let lengths;
if (quill.getSelection() == null) {
lengths = 1
} else {
lengths = quill.getSelection().index;
}
// res
quill.insertEmbed(length, "image", res.data.filesResult.fileUrl);
quill.insertEmbed(lengths, 'image', file.url)
//
quill.setSelection(length + 1);
quill.setSelection(lengths + 1)
} else {
util.successMsg("图片插入失败");
this.$message.success('图片插入失败')
}
this.loading = false;
this.loading = false
},
//
@ -288,19 +293,9 @@ export default {
// markdown
imgAdd (pos, $file) {
let $vm = this.$refs.md
// ..
const formData = new FormData();
formData.append('file', $file);
axios({
url: this.api.fileupload,
method: 'post',
data: formData,
headers: {
token: this.token,
'Content-Type': 'multipart/form-data'
},
}).then((res) => {
$vm.$img2Url(pos, res.data.data.filesResult.fileUrl);
// oss
Oss.upload($file).then(res => {
$vm.$img2Url(pos, res.url);
})
},
}

@ -102,7 +102,7 @@ export default {
this.uploading = true
this.showFiles = false
// oss
const { name } = await this.client.multipartUpload(file.name, file, {
const { name } = await this.client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file, {
progress: this.handleProgress
});

@ -17,7 +17,7 @@ export default {
return new Promise(async (resolve, reject) => {
try {
// 上传到阿里云oss
const res = await client.multipartUpload(file.name, file);
const res = await client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file);
resolve({
format: Util.getFileExt(file.name),
name: file.name,

@ -16,15 +16,13 @@
<el-form-item label="项目封面(选填)">
<el-upload class="avatar-uploader"
accept=".jpg,.png,.jpeg,.gif"
:on-success="uploadSuccess"
:action="this.api.fileupload"
:headers="headers"
:limit="1"
:on-exceed="handleExceed"
:before-remove="beforeRemove"
:on-remove="handleRemove"
:on-error="uploadError"
name="file">
action=""
:http-request="handleRequest">
<img v-if="form.coverUrl"
:src="form.coverUrl"
class="avatar">
@ -42,15 +40,13 @@
<el-form-item label="项目封面长图(选填)">
<el-upload class="avatar-uploader avatar-uploader-lg"
accept=".jpg,.png,.jpeg,.gif"
:on-success="uploadLgSuccess"
:action="this.api.fileupload"
:headers="headers"
:limit="1"
:on-exceed="handleExceed"
:before-remove="beforeRemove"
:on-remove="handleCarouselRemove"
:on-error="uploadError"
name="file">
action=""
:http-request="handleRequestLg">
<img v-if="form.carouselUrl"
:src="form.carouselUrl"
class="avatar-lg">
@ -154,23 +150,11 @@
:height="400" />
</el-form-item>
<el-form-item label="附件">
<el-upload :on-remove="handleAnnexRemove"
:on-error="uploadError"
:before-upload="beforeUpload"
:on-success="uploadAnnexSuccess"
:on-exceed="handleExceedAnnex"
:limit="5"
:action="this.api.fileupload"
:headers="headers"
:file-list="form.activityFileList"
name="file">
<el-button size="small"
type="primary">点击上传</el-button>
<div slot="tip"
class="el-upload__tip">
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p>
</div>
</el-upload>
<Upload :limit="5"
:file-list.sync="form.activityFileList"
:changeFileList="false"
:on-remove="handleAnnexRemove"
@onSuccess="uploadAnnexSuccess" />
</el-form-item>
</el-form>
@ -191,6 +175,8 @@
import util from "@/libs/util";
import quill from "@/components/quill";
import Setting from "@/setting";
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default {
data () {
return {
@ -236,6 +222,7 @@ export default {
},
components: {
quill,
Upload
},
watch: {
// ,
@ -319,10 +306,12 @@ export default {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove (file, fileList) {
handleRemove () {
Oss.del(this.form.coverUrl)
this.form.coverUrl = ''
},
handleCarouselRemove (file, fileList) {
handleCarouselRemove () {
Oss.del(this.form.carouselUrl)
this.form.carouselUrl = ''
},
uploadError (err, file, fileList) {
@ -332,20 +321,27 @@ export default {
center: true
})
},
uploadSuccess (res) {
this.form.coverUrl = res.data.filesResult.fileUrl
//
async handleRequest ({ file }) {
this.form.coverUrl && Oss.del(this.form.coverUrl)
Oss.upload(file).then(res => {
this.form.coverUrl = res.url
})
},
uploadLgSuccess (res) {
this.form.carouselUrl = res.data.filesResult.fileUrl
//
async handleRequestLg ({ file }) {
this.form.carouselUrl && Oss.del(this.form.carouselUrl)
Oss.upload(file).then(res => {
this.form.carouselUrl = res.url
})
},
//
uploadAnnexSuccess (res) {
const file = res.data.filesResult
const url = file.fileUrl || file.fileId
uploadAnnexSuccess (file) {
const url = file.url
const data = {
activityId: this.form.id || '',
fileName: this.fileName,
name: this.fileName,
fileName: file.name,
name: file.name,
filePath: url,
url
}
@ -366,6 +362,7 @@ export default {
}
},
handleAnnexRemove (file, fileList) {
Oss.del(file.url)
this.form.activityFileList = fileList
},
//

@ -26,24 +26,10 @@
:height="400" />
</el-form-item>
<el-form-item label="附件">
<el-upload :on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-upload="beforeUpload"
:before-remove="beforeRemove"
:limit="5"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
<Upload :limit="5"
:file-list="fileList"
name="file">
<el-button size="small"
type="primary">点击上传</el-button>
<div slot="tip"
class="el-upload__tip">
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p>
</div>
</el-upload>
:on-remove="handleRemove"
@onSuccess="uploadSuccess" />
</el-form-item>
<el-form-item>
<el-button v-if="!form.id"
@ -62,6 +48,8 @@
import quill from "@/components/quill";
import util from "@/libs/util";
import Setting from "@/setting";
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default {
name: "matchDetail",
data () {
@ -83,7 +71,8 @@ export default {
};
},
components: {
quill
quill,
Upload
},
watch: {
// ,
@ -142,13 +131,12 @@ export default {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
},
//
uploadSuccess (res) {
const file = res.data.filesResult
uploadSuccess (file) {
const { id } = this.form
const data = {
announcementId: id || '',
fileName: this.fileName,
filePath: file.fileUrl || file.fileId
fileName: file.name,
filePath: file.url
}
this.form.announcementAnnexList.push(data)
//
@ -170,7 +158,7 @@ export default {
},
handleRemove (file, fileList) {
if (file.url) {
this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => { }).catch(res => { })
Oss.del(file.url)
const id = this.form.announcementAnnexList.find(e => e.fileName === file.name).id
this.$post(`${this.api.delActivityAnnouncementAnnex}?id=${id}`).then(res => { }).catch(res => { })
}

@ -1,79 +1,120 @@
<template>
<div>
<el-card shadow="hover" class="m-b-20">
<el-card shadow="hover"
class="m-b-20">
<div class="flex-between">
<el-page-header @back="back" :content="form.id ? '编辑课程' : '新增课程'"></el-page-header>
<el-page-header @back="back"
:content="form.id ? '编辑课程' : '新增课程'"></el-page-header>
</div>
</el-card>
<el-card shadow="hover" class="m-b-20">
<el-form :model="form" :rules="rules" ref="form" :disabled="isDetail" label-width="120px" label-suffix=":">
<el-form-item prop="courseName" label="课程名称">
<el-card shadow="hover"
class="m-b-20">
<el-form :model="form"
:rules="rules"
ref="form"
:disabled="isDetail"
label-width="120px"
label-suffix=":">
<el-form-item prop="courseName"
label="课程名称">
<div class="d-inline-block">
<el-input placeholder="请输入课程名称" v-model="form.courseName" clearable maxlength="25" @change="nameChange"></el-input>
<el-input placeholder="请输入课程名称"
v-model="form.courseName"
clearable
maxlength="25"
@change="nameChange"></el-input>
</div>
</el-form-item>
<el-form-item prop="courseType" label="课程类型">
<el-form-item prop="courseType"
label="课程类型">
<div class="d-inline-block">
<el-select v-model="form.courseType" placeholder="请选择课程类型">
<el-option label="免费" :value="0"></el-option>
<el-select v-model="form.courseType"
placeholder="请选择课程类型">
<el-option label="免费"
:value="0"></el-option>
<!-- <el-option label="付费" :value="1"></el-option> -->
</el-select>
</div>
</el-form-item>
<el-form-item prop="visibleRange" label="可见范围">
<el-form-item prop="visibleRange"
label="可见范围">
<div>
<el-radio v-model="form.visibleRange" :label="0" @change="visibleChange">仅本校</el-radio>
<el-radio v-model="form.visibleRange"
:label="0"
@change="visibleChange">仅本校</el-radio>
</div>
<div>
<el-radio v-model="form.visibleRange" :label="1" @change="visibleChange">全平台</el-radio>
<el-radio v-model="form.visibleRange"
:label="1"
@change="visibleChange">全平台</el-radio>
</div>
</el-form-item>
<el-form-item prop="schoolClassificationsIds" label="课程分类">
<el-form-item prop="schoolClassificationsIds"
label="课程分类">
<div class="d-inline-block">
<el-select v-model="form.schoolClassificationsIds" placeholder="请选择课程分类" multiple>
<el-option v-for="item in classificationList" :key="item.id" :label="item.classificationName" :value="item.id"></el-option>
<el-select v-model="form.schoolClassificationsIds"
placeholder="请选择课程分类"
multiple>
<el-option v-for="item in classificationList"
:key="item.id"
:label="item.classificationName"
:value="item.id"></el-option>
</el-select>
</div>
</el-form-item>
<el-form-item v-if="form.visibleRange == 1" prop="platformClassificationIds" label="平台课程分类">
<el-form-item v-if="form.visibleRange == 1"
prop="platformClassificationIds"
label="平台课程分类">
<div class="d-inline-block">
<el-select v-model="form.platformClassificationIds" placeholder="请选择平台课程分类" multiple>
<el-option v-for="item in platformClassificationList" :key="item.id" :label="item.classificationName" :value="item.id"></el-option>
<el-select v-model="form.platformClassificationIds"
placeholder="请选择平台课程分类"
multiple>
<el-option v-for="item in platformClassificationList"
:key="item.id"
:label="item.classificationName"
:value="item.id"></el-option>
</el-select>
</div>
</el-form-item>
<el-form-item prop="coverUrl" label="课程封面">
<el-upload
class="avatar-uploader"
<el-form-item prop="coverUrl"
label="课程封面">
<el-upload class="avatar-uploader"
accept=".jpg,.png,.jpeg"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file"
>
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar">
<div class="uploader-default" v-else>
action=""
:http-request="handleRequest">
<img v-if="form.coverUrl"
:src="form.coverUrl"
class="avatar">
<div class="uploader-default"
v-else>
<i class="el-icon-plus"></i>
<p>上传封面</p>
</div>
<div slot="tip" class="el-upload__tip">
<div slot="tip"
class="el-upload__tip">
<p>只能上传jpg/png文件</p>
<p>课程封面图将按2:1显示最佳分辨率1400*700</p>
</div>
</el-upload>
</el-form-item>
<el-form-item prop="courseIntroduction" label="课程介绍">
<quill :border="true" :readonly="isDetail" v-model="form.courseIntroduction" :height="400" />
<el-form-item prop="courseIntroduction"
label="课程介绍">
<quill :border="true"
:readonly="isDetail"
v-model="form.courseIntroduction"
:height="400" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save(0)" v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button>
<el-button type="primary"
@click="save(0)"
v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button>
</el-form-item>
</el-form>
</el-card>
@ -84,9 +125,10 @@
import util from "@/libs/util";
import Setting from "@/setting";
import quill from "@/components/quill";
import Oss from '@/components/upload/upload.js'
export default {
data() {
data () {
const that = this
return {
headers: {
@ -168,7 +210,7 @@ export default {
data.push(e)
})
resolve(data)
}).catch(res => {})
}).catch(res => { })
} else if (level === 1) {
//
that.$get(that.api.queryCity, {
@ -183,7 +225,7 @@ export default {
data.push(e)
})
resolve(data)
}).catch(res => {})
}).catch(res => { })
} else if (level === 2) {
//
that.$get(that.api.getSchoolsByProvince, {
@ -200,7 +242,7 @@ export default {
data.push(e)
})
resolve(data)
}).catch(res => {})
}).catch(res => { })
} else {
resolve([])
}
@ -212,15 +254,15 @@ export default {
watch: {
// ,
form: {
handler(val){
handler (val) {
this.updateTime++
},
deep:true
deep: true
}
},
// ,
beforeRouteLeave(to, from, next) {
if(this.updateTime){
beforeRouteLeave (to, from, next) {
if (this.updateTime) {
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
@ -228,11 +270,11 @@ export default {
}).catch(() => {
next()
})
}else{
} else {
next()
}
},
mounted() {
mounted () {
this.getClassification()
this.form.id && this.getData()
},
@ -241,7 +283,7 @@ export default {
},
methods: {
//
getClassification() {
getClassification () {
//
this.$post(this.api.listClassification, {
pageNum: 1,
@ -249,7 +291,7 @@ export default {
platformSource: 0
}).then(({ page }) => {
this.platformClassificationList = page.records
}).catch(res => {})
}).catch(res => { })
//
this.$post(this.api.listClassification, {
@ -258,9 +300,9 @@ export default {
platformSource: Setting.platformSource
}).then(({ page }) => {
this.classificationList = page.records
}).catch(res => {})
}).catch(res => { })
},
getData() {
getData () {
this.$post(`${this.api.findTheoreticalCourse}?id=${this.form.id}`).then(({ data }) => {
// id
if (data.platformClassificationList) {
@ -280,10 +322,10 @@ export default {
name: "cover.jpg",
url: data.coverUrl
})
}).catch(err => {})
}).catch(err => { })
},
//
nameChange(val) {
nameChange (val) {
this.$post(this.api.checkRepeatTheoreticalCourse, {
id: this.form.id,
courseName: val,
@ -295,32 +337,33 @@ export default {
})
},
//
visibleChange(val) {
visibleChange (val) {
this.rules.platformClassificationIds[0].required = val == 1
},
handleExceed(files, fileList) { //
handleExceed (files, fileList) { //
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
},
uploadSuccess(res, file, fileList) {
this.form.coverUrl = res.data.filesResult.fileUrl
handleRequest ({ file }) {
this.form.coverUrl && Oss.del(this.form.coverUrl)
Oss.upload(file).then(res => {
this.form.coverUrl = res.url
})
},
uploadError(err, file, fileList) {
uploadError (err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
let fileName = this.form.coverUrl.replace('https://huoran.oss-cn-shenzhen.aliyuncs.com/', "");
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => {
handleRemove () {
Oss.del(this.form.coverUrl)
this.form.coverUrl = ''
}).catch(res => {});
},
save(cb) {
save (cb) {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.nameRepeat) return util.errorMsg('当前课程名已存在!')
@ -359,10 +402,10 @@ export default {
})
},
//
backPage() {
backPage () {
this.$router.back()
},
back() {
back () {
const updateTime = this.updateTime
//
if (updateTime) {
@ -395,7 +438,7 @@ $avatar-width: 104px;
overflow: hidden;
&:hover {
border-color: #409EFF;
border-color: #409eff;
}
.uploader-default {
@ -446,7 +489,8 @@ $avatar-width: 104px;
/deep/ .d-inline-block {
width: 216px;
.el-select, .el-input {
.el-select,
.el-input {
width: 100%;
}
}

@ -165,26 +165,15 @@
:close-on-click-modal="false">
<el-form label-width="80px">
<el-form-item label="资源添加">
<el-upload :before-upload="beforeUpload"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
<Upload :max-size="100000"
:file-list="uploadList"
:headers="headers"
:http-request="handleRequest"
name="file">
<el-button size="small"><img src="@/assets/img/upload.png"
alt=""> 上传资源</el-button>
<div slot="tip"
class="el-upload__tip">视频请上传MP4格式大小不超过30Moffice文件大小不要超过10M</div>
</el-upload>
<el-progress v-if="showProgress"
:stroke-width="3"
:percentage="progressPercent"></el-progress>
:on-remove="handleRemove"
@beforeUpload="beforeUpload"
@onSuccess="uploadSuccess">
<template slot="tip">
<p>视频请上传MP4格式大小不超过30Moffice文件大小不要超过10M</p>
</template>
</Upload>
</el-form-item>
<el-form-item label="小节名称">
<el-input placeholder="请输入小节名称"
@ -206,24 +195,12 @@
:close-on-click-modal="false"
@close="closeSwitch">
<div style="text-align: center">
<el-upload :before-upload="beforeUpload"
<Upload :file-list="uploadList"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:file-list="uploadList"
:headers="headers"
:http-request="handleRequest"
name="file">
<el-button size="small"><img src="@/assets/img/upload.png"
alt=""> 上传资源</el-button>
</el-upload>
<el-progress v-if="showProgress"
:stroke-width="3"
:percentage="progressPercent"></el-progress>
@beforeUpload="beforeUpload"
@onSuccess="uploadSuccess">
<div slot="tip"></div>
</Upload>
</div>
<span slot="footer"
class="dialog-footer">
@ -266,7 +243,7 @@
style="transform: scale(1) rotate(0deg);margin-top: -1px; max-height: 100%; max-width: 100%;">
</div>
</div>
<div v-show="iframeSrc"
<div v-show="iframeSrc || videoSrc"
class="el-image-viewer__wrapper"
:class="{active: iframeSrc}"
style="z-index: 2000">
@ -282,6 +259,16 @@
id="fileIframe"
:src="iframeSrc"
frameborder="0"></iframe>
<video v-if="videoSrc"
class="video"
width="1200"
height="600"
autoplay
controls>
<source :src="videoSrc"
type="video/mp4">
您的浏览器不支持 video 标签
</video>
<template v-if="showMask">
<div class="mask"
style="width: 200px;height: 30px;top: 53px;right: 320px"></div>
@ -360,7 +347,9 @@ import util from "@/libs/util";
import Setting from "@/setting";
import { Loading } from "element-ui";
import pdf from "@/components/pdf";
import axios from 'axios'
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
import Util from '@/libs/util'
export default {
name: "contentSettings",
@ -388,6 +377,7 @@ export default {
fileUrl: "",
originalFileName: "",
fileType: "",
videoSrc: '',
playAuth: "",
player: null,
previewImg: "",
@ -425,7 +415,7 @@ export default {
moved: false //
};
},
components: { pdf },
components: { pdf, Upload },
mounted () {
this.insertScript();
this.id = this.$route.query.id;
@ -528,40 +518,12 @@ export default {
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
);
},
//
handleRequest (data) {
const param = new FormData()
param.append('file', data.file)
const config = {
timeout: 10000000000,
headers: {
'Accept': '*/*',
'Content-Type': 'multipart/form-data',
token: util.local.get(Setting.tokenKey)
},
//
onUploadProgress: progressEvent => {
const per = Number((progressEvent.loaded / progressEvent.total * 100).toFixed(2))
if (this.progressPercent <= 80) this.progressPercent = (per > 80) ? (Math.random() * 10 + 80).toFixed(2) : per
}
}
axios.post(this.api.fileupload, param, config).then(res => {
this.progressPercent = 100
this.showProgress = false
const { fileId, fileType, fileUrl, ossFileName } = res.data.data.filesResult
uploadSuccess (file) {
this.uploading = false
this.fileId = fileId
this.fileType = fileType
this.fileUrl = fileUrl
this.fileName = ossFileName
})
},
uploadSuccess (res, file, fileList) {
this.uploading = false;
this.fileId = res.data.filesResult.fileId;
this.fileType = res.data.filesResult.fileType;
this.fileUrl = res.data.filesResult.fileUrl;
this.fileName = res.data.filesResult.ossFileName;
this.fileId = ''
this.fileType = file.format
this.fileUrl = file.url
this.fileName = file.name
},
uploadError (err, file, fileList) {
this.$message({
@ -576,7 +538,8 @@ export default {
}
},
handleRemove (file, fileList) {
this.uploadList = fileList;
Oss.del(this.fileUrl)
this.fileUrl = ''
},
uploadSure () {
this.importVisible = false;
@ -788,6 +751,8 @@ export default {
},
preview (row) {
if (this.transferType(row.fileType) == "视频") {
//
if (row.fileId) {
this.$get(`${this.api.getPlayAuth}/${row.fileId}`).then(res => {
this.playAuth = res.data.playAuth;
if (this.player) {
@ -802,8 +767,10 @@ export default {
encryptType: 1 //
});
}
}).catch(res => {
});
}).catch(res => { });
} else {
this.videoSrc = row.fileUrl
}
} else if (this.transferType(row.fileType) == "图片") {
this.previewImg = row.fileUrl;
} else if (row.fileType == "pdf") {
@ -880,23 +847,10 @@ export default {
.catch(err => {
});
},
switchSubmit () {
async switchSubmit () {
if (this.uploading) return util.warningMsg("资源正在上传中,请稍候");
if (!this.fileUrl && !this.fileId) return util.warningMsg("请上传资源");
if (this.transferType(this.curFile.fileType) == "视频") {
let data = {
videoIdList: [this.sectionId]
};
this.$del(`${this.api.removeVideo}/${this.curFile.fileId}`).then(res => {
this.switchSubmitFile();
}).catch(res => {
});
} else {
this.$del(`${this.api.fileDeletion}?keys=${this.curFile.fileName}`).then(res => {
this.switchSubmitFile();
}).catch(res => {
});
}
this.switchSubmitFile()
},
delSection (row) {
this.$confirm("此删除操作不可逆,是否确认删除选中项?", "提示", {
@ -960,6 +914,7 @@ export default {
},
closeIframe () {
this.iframeSrc = "";
this.videoSrc = ''
this.showMask = false;
this.showMask1 = false;
this.showMask2 = false;

@ -1,51 +1,74 @@
<template>
<div>
<el-card shadow="hover" class="m-b-20">
<el-card shadow="hover"
class="m-b-20">
<div class="flex-between">
<el-page-header @back="back" :content="'新增文章'"></el-page-header>
<el-page-header @back="back"
:content="'新增文章'"></el-page-header>
</div>
</el-card>
<el-card shadow="hover" class="m-b-20">
<el-form :model="form" :rules="rules" ref="form" label-width="90px" label-suffix=":" size="small">
<el-form-item prop="coverUrl" label="封面图">
<el-upload
class="avatar-uploader"
<el-card shadow="hover"
class="m-b-20">
<el-form :model="form"
:rules="rules"
ref="form"
label-width="90px"
label-suffix=":"
size="small">
<el-form-item prop="coverUrl"
label="封面图">
<el-upload class="avatar-uploader"
accept=".jpg,.png,.jpeg"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file"
>
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar">
<div class="uploader-default" v-else>
action=""
:http-request="handleRequest">
<img v-if="form.coverUrl"
:src="form.coverUrl"
class="avatar">
<div class="uploader-default"
v-else>
<i class="el-icon-plus"></i>
<p>上传封面</p>
</div>
</el-upload>
</el-form-item>
<el-form-item prop="author" label="作者">
<el-form-item prop="author"
label="作者">
<div class="d-inline-block">
<el-input placeholder="请输入作者" v-model="form.author" clearable></el-input>
<el-input placeholder="请输入作者"
v-model="form.author"
clearable></el-input>
</div>
</el-form-item>
<el-form-item prop="date" label="日期">
<el-form-item prop="date"
label="日期">
<div class="d-inline-block">
<el-date-picker v-model="form.date" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
<el-date-picker v-model="form.date"
type="date"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期"></el-date-picker>
</div>
</el-form-item>
<el-form-item prop="title" label="文章标题">
<el-input placeholder="请输入文章标题" v-model="form.title" clearable></el-input>
<el-form-item prop="title"
label="文章标题">
<el-input placeholder="请输入文章标题"
v-model="form.title"
clearable></el-input>
</el-form-item>
<el-form-item prop="content" label="文章内容">
<quill :border="true" v-model="form.content" :uploading.sync="uploading" :height="400" />
<el-form-item prop="content"
label="文章内容">
<quill :border="true"
v-model="form.content"
:uploading.sync="uploading"
:height="400" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save(0)">确定</el-button>
<el-button type="primary"
@click="save(0)">确定</el-button>
</el-form-item>
</el-form>
</el-card>
@ -53,13 +76,14 @@
</template>
<script>
import Oss from '@/components/upload/upload.js'
import { mapState } from "vuex";
import quill from "@/components/quill";
import util from "@/libs/util";
import Setting from '@/setting'
export default {
name: "addarticle",
data() {
data () {
return {
id: this.$route.query.id,
headers: {
@ -111,15 +135,15 @@ export default {
watch: {
// ,
form: {
handler(val){
handler (val) {
this.updateTime++
},
deep:true
deep: true
}
},
// ,
beforeRouteLeave(to, from, next) {
if(this.updateTime){
beforeRouteLeave (to, from, next) {
if (this.updateTime) {
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
@ -127,73 +151,68 @@ export default {
}).catch(() => {
next()
})
}else{
} else {
next()
}
},
mounted() {
mounted () {
this.id && this.getData();
},
methods: {
getData() {
getData () {
this.$get(`${this.api.getArticle}?articleId=${this.id}`).then(({ article }) => {
this.form = article
this.$nextTick(() => {
this.updateTime = 0
})
}).catch(err => {})
}).catch(err => { })
},
handleCurrentChange(val) {
handleCurrentChange (val) {
this.currPage = val;
},
handleExceed(files, fileList) {
handleExceed (files, fileList) {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
},
uploadSuccess(res, file, fileList) {
if (this.form.coverUrl) {
let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", "");
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => {
}).catch(res => {
});
}
this.form.coverUrl = res.data.filesResult.fileUrl;
//
async handleRequest ({ file }) {
this.form.coverUrl && Oss.del(this.form.coverUrl)
Oss.upload(file).then(res => {
this.form.coverUrl = res.url
})
},
uploadError(err, file, fileList) {
uploadError (err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
let fileName = this.form.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", "");
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => {
this.form.coverUrl = "";
}).catch(res => {
});
handleRemove (file, fileList) {
Oss.del(this.form.coverUrl)
this.form.coverUrl = ''
},
uploadSure() {
uploadSure () {
this.BatchUpload = false;
this.pageNo = 1;
this.keyword = "";
this.getData();
},
addSponsor() {
addSponsor () {
this.sponsorList.push("");
},
delSponsor(index) {
delSponsor (index) {
this.sponsorList.splice(index, 1);
},
addOrganizer() {
addOrganizer () {
this.organzinerList.push("");
},
delOrganizer(index) {
delOrganizer (index) {
this.organzinerList.splice(index, 1);
},
save(cb) {
save (cb) {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
@ -225,7 +244,7 @@ export default {
}
})
},
back() {
back () {
//
if (this.updateTime) {
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
@ -257,7 +276,7 @@ $avatar-width: 104px;
overflow: hidden;
&:hover {
border-color: #409EFF;
border-color: #409eff;
}
.uploader-default {
@ -308,7 +327,8 @@ $avatar-width: 104px;
/deep/ .d-inline-block {
width: 216px;
.el-select, .el-input {
.el-select,
.el-input {
width: 100%;
}
}

@ -12,13 +12,11 @@
accept=".jpg,.png,.jpeg,.gif"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file">
action=""
:http-request="handleRequest">
<img v-if="form.coverUrl"
:src="form.coverUrl"
class="avatar">
@ -38,13 +36,11 @@
accept=".jpg,.png,.jpeg,.gif"
:on-remove="handleLgRemove"
:on-error="uploadError"
:on-success="uploadLgSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file">
action=""
:http-request="handleRequestLg">
<img v-if="form.carouselUrl"
:src="form.carouselUrl"
class="avatar-lg">
@ -220,23 +216,10 @@
:readonly="!editing && form.id !== ''" />
</el-form-item>
<el-form-item label="附件">
<el-upload :on-remove="handleAnnexRemove"
:on-error="uploadError"
:before-upload="beforeUpload"
:on-success="uploadAnnexSuccess"
:limit="5"
:on-exceed="handleExceedAnnex"
:action="this.api.fileupload"
:headers="headers"
:file-list="fileList"
name="file">
<el-button size="small"
type="primary">点击上传</el-button>
<div slot="tip"
class="el-upload__tip">
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p>
</div>
</el-upload>
<Upload :limit="5"
:file-list.sync="fileList"
:on-remove="handleAnnexRemove"
@onSuccess="uploadAnnexSuccess" />
</el-form-item>
</el-form>
</div>
@ -287,6 +270,8 @@
import util from "@/libs/util";
import quill from "@/components/quill";
import Setting from "@/setting";
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default {
props: ['editing'],
data () {
@ -414,7 +399,8 @@ export default {
};
},
components: {
quill
quill,
Upload
},
watch: {
editing: function (val) {
@ -600,24 +586,25 @@ export default {
handleExceedAnnex (files, fileList) {
util.warningMsg(`当前限制选择 5 个文件,如需更换,请删除一个文件再重新选择!`);
},
uploadSuccess (res) {
const { coverUrl } = this.form
coverUrl && this.$del(`${this.api.fileDeletion}?keys=${coverUrl}`).then(res => { }).catch(res => { })
this.form.coverUrl = res.data.filesResult.fileUrl
//
async handleRequest ({ file }) {
Oss.upload(file).then(res => {
this.form.coverUrl = res.url
})
},
uploadLgSuccess (res) {
const { carouselUrl } = this.form
carouselUrl && this.$del(`${this.api.fileDeletion}?keys=${carouselUrl}`).then(res => { }).catch(res => { })
this.form.carouselUrl = res.data.filesResult.fileUrl
//
async handleRequestLg ({ file }) {
Oss.upload(file).then(res => {
this.form.carouselUrl = res.url
})
},
//
uploadAnnexSuccess (res) {
const file = res.data.filesResult
uploadAnnexSuccess (file) {
const { id } = this.form
const data = {
competitionId: id || '',
fileName: this.fileName,
filePath: file.fileUrl || file.fileId
fileName: file.name,
filePath: file.url
}
this.form.competitionAnnexList.push(data)
//
@ -644,20 +631,17 @@ export default {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove (file, fileList) {
this.$del(`${this.api.fileDeletion}?keys=${this.form.coverUrl}`).then(res => {
handleRemove () {
Oss.del(this.form.coverUrl)
this.form.coverUrl = ''
}).catch(res => { })
},
handleLgRemove (file, fileList) {
this.$del(`${this.api.fileDeletion}?keys=${this.form.carouselUrl}`).then(res => {
handleLgRemove () {
Oss.del(this.form.carouselUrl)
this.form.carouselUrl = ''
}).catch(res => { })
},
handleAnnexRemove (file, fileList) {
const { url, name } = file
url && this.$del(`${this.api.fileDeletion}?keys=${url}`).then(res => { }).catch(res => { })
const id = this.form.competitionAnnexList.find(e => e.fileName === name).id
Oss.del(file.url)
const { id } = file
id && this.$post(`${this.api.delComAnnex}?id=${id}`).then(res => { }).catch(res => { })
},
//

@ -62,12 +62,10 @@
<template v-if="item.competitionStageContentSetting.whetherToUploadFiles">
<el-upload :on-remove="(file, fileList) => handleRemove(file, fileList, item)"
:on-error="uploadError"
:on-success="res => uploadSuccess(res, item)"
:before-remove="beforeRemove"
:action="api.fileUploadNakadai"
:headers="headers"
action=""
:file-list="item.competitionStageContentSetting.fileList"
name="file">
:http-request="res => handleRequest(res, item)">
<el-button size="small"
type="primary">上传文件</el-button>
</el-upload>
@ -137,6 +135,7 @@
</template>
<script>
import Oss from '@/components/upload/upload.js'
import util from "@/libs/util";
import Setting from "@/setting";
import set from './set'
@ -319,14 +318,17 @@ export default {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove (file, fileList, item) {
Oss.del(file.url)
const i = item.competitionStageContentSetting.fileList.findIndex(e => e.url === file.url)
item.competitionStageContentSetting.fileList.splice(i, 1)
},
uploadSuccess (res, item) {
const { originalFileName, fileUrl } = res.filesResult
//
async handleRequest ({ file }, item) {
Oss.upload(file).then(res => {
item.competitionStageContentSetting.fileList.push({
name: originalFileName,
url: fileUrl
name: res.name,
url: res.url
})
})
},

@ -1,45 +1,43 @@
<template>
<!-- 大赛详情 -->
<div>
<el-card shadow="hover" style="margin-bottom: 20px">
<el-card shadow="hover"
style="margin-bottom: 20px">
<div class="flex-between">
<el-page-header @back="back" :content="(form.id ? '编辑' : '创建') + '公告'"></el-page-header>
<el-page-header @back="back"
:content="(form.id ? '编辑' : '创建') + '公告'"></el-page-header>
</div>
</el-card>
<div class="page">
<div class="page-content">
<el-form label-width="170px" label-suffix=":" size="small">
<el-form label-width="170px"
label-suffix=":"
size="small">
<el-form-item label="公告标题">
<div class="d-inline-block">
<el-input placeholder="请输入公告名称" v-model="form.announcementTitle" clearable></el-input>
<el-input placeholder="请输入公告名称"
v-model="form.announcementTitle"
clearable></el-input>
</div>
</el-form-item>
<el-form-item label="正文">
<quill :border="true" v-model="form.announcementText" :height="400" />
<quill :border="true"
v-model="form.announcementText"
:height="400" />
</el-form-item>
<el-form-item label="附件">
<el-upload
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-upload="beforeUpload"
:before-remove="beforeRemove"
:limit="5"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
<Upload :limit="5"
:file-list="fileList"
name="file"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p>
</div>
</el-upload>
:on-remove="handleRemove"
@onSuccess="uploadSuccess" />
</el-form-item>
<el-form-item>
<el-button v-if="!form.id" @click="save(0)" v-auth="'/match/list:管理:公告通知:草稿'">草稿</el-button>
<el-button type="primary" @click="save(1)" v-auth="'/match/list:管理:公告通知:发布'">发布</el-button>
<el-button v-if="!form.id"
@click="save(0)"
v-auth="'/match/list:管理:公告通知:草稿'">草稿</el-button>
<el-button type="primary"
@click="save(1)"
v-auth="'/match/list:管理:公告通知:发布'">发布</el-button>
<el-button @click="back">取消</el-button>
</el-form-item>
</el-form>
@ -52,9 +50,11 @@
import quill from "@/components/quill";
import util from "@/libs/util";
import Setting from "@/setting";
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default {
name: "matchDetail",
data() {
data () {
return {
headers: {
token: util.local.get(Setting.tokenKey)
@ -73,23 +73,24 @@ export default {
};
},
components: {
quill
quill,
Upload
},
watch: {
// ,
form: {
handler(){
handler () {
this.updateTime++
if(this.updateTime > 1) this.$store.commit('match/setWait', 0)
if (this.updateTime > 1) this.$store.commit('match/setWait', 0)
},
deep:true
deep: true
},
},
mounted() {
mounted () {
this.form.id && this.getData()
},
methods: {
getData() {
getData () {
this.$post(`${this.api.queryAnnouncementDetails}?id=${this.form.id}`).then(({ data }) => {
this.form = data
//
@ -106,10 +107,10 @@ export default {
} else {
data.announcementAnnexList = []
}
}).catch(err => {})
}).catch(err => { })
},
//
save(status) {
save (status) {
const form = this.form
if (!form.announcementTitle) return util.warningMsg('请填写公告标题')
if (!form.announcementText) return util.warningMsg('请填写正文')
@ -120,53 +121,52 @@ export default {
this.$post(this.api.amendmentAnnouncement, form).then(res => {
util.successMsg("修改成功")
this.$router.back()
}).catch(err => {})
}).catch(err => { })
} else {
form.isOpen = status ? 0 : 1
this.$post(this.api.addAnnouncement, form).then(res => {
util.successMsg("创建成功")
this.$router.back()
}).catch(err => {})
}).catch(err => { })
}
},
handleExceed(files, fileList) {
handleExceed (files, fileList) {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
},
//
uploadSuccess(res) {
const file = res.data.filesResult
uploadSuccess (file) {
const { id } = this.form
const data = {
announcementId: id || '',
fileName: this.fileName,
filePath: file.fileUrl || file.fileId
fileName: file.name,
filePath: file.url
}
this.form.announcementAnnexList.push(data)
//
id && this.$post(this.api.saveAnnouncementAnnex, data).then(res => {}).catch(res => {})
id && this.$post(this.api.saveAnnouncementAnnex, data).then(res => { }).catch(res => { })
},
//
beforeUpload(file) {
beforeUpload (file) {
this.fileName = file.name
},
uploadError(err, file, fileList) {
uploadError (err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
handleRemove (file, fileList) {
if (file.url) {
this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => {}).catch(res => {})
Oss.del(file.url)
const id = this.form.announcementAnnexList.find(e => e.fileName === file.name).id
this.$post(`${this.api.delAnnex}?id=${id}`).then(res => {}).catch(res => {})
this.$post(`${this.api.delAnnex}?id=${id}`).then(res => { }).catch(res => { })
}
},
back() {
back () {
this.$router.back()
}
}
@ -256,7 +256,8 @@ $upload-lg-height: 150px;
/deep/ .d-inline-block {
width: 216px;
.el-select, .el-input {
.el-select,
.el-input {
width: 100%;
}
}
@ -276,7 +277,7 @@ $upload-lg-height: 150px;
.remove {
width: 16px;
height: 16px;
background: url("../../../assets/img/close.png") 0 0/cover no-repeat;
background: url('../../../assets/img/close.png') 0 0 / cover no-repeat;
cursor: pointer;
}
}

@ -1,38 +1,43 @@
<template>
<div class="page">
<h6 class="p-title">系统logo设置</h6>
<el-form ref="form" label-width="100px">
<el-form ref="form"
label-width="100px">
<el-form-item label="标题">
<el-input v-model="form.title " ref="account" placeholder="请输入标题" style="width: 400px"></el-input>
<el-input v-model="form.title "
ref="account"
placeholder="请输入标题"
style="width: 400px"></el-input>
</el-form-item>
<el-form-item label="图标">
<el-upload
class="avatar-uploader"
<el-upload class="avatar-uploader"
accept=".jpg,.png,.jpeg"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.fileupload"
:headers="headers"
name="file"
>
<img v-if="coverUrl" :src="coverUrl" class="avatar">
<div class="uploader-default" v-else>
action=""
:http-request="handleRequest">
<img v-if="coverUrl"
:src="coverUrl"
class="avatar">
<div class="uploader-default"
v-else>
<i class="el-icon-plus"></i>
<p>上传图标</p>
</div>
<div slot="tip" class="el-upload__tip">
<div slot="tip"
class="el-upload__tip">
<p>只能上传jpg/png文件</p>
<p>图标将按1:1显示最佳分辨率100*100</p>
</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save">{{ form.id ? "更新" : "创建" }}</el-button>
<el-button type="primary"
@click="save">{{ form.id ? "更新" : "创建" }}</el-button>
</el-form-item>
</el-form>
</div>
@ -42,9 +47,10 @@
import util from "@/libs/util";
import Setting from "@/setting";
import { mapActions, mapState } from "vuex";
import Oss from '@/components/upload/upload.js'
export default {
name: "logo",
data() {
data () {
return {
headers: {
token: util.local.get(Setting.tokenKey)
@ -58,7 +64,7 @@ export default {
}
}
},
mounted() {
mounted () {
this.getSystemDetail();
},
methods: {
@ -77,43 +83,44 @@ export default {
this.setTitle(res.data.title);
this.setLogoUrl(res.data.logoUrl);
}
}).catch(res => {});
}).catch(res => { });
},
handleExceed(files, fileList) { //
handleExceed (files, fileList) { //
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
},
uploadSuccess(res, file, fileList) {
this.coverUrl = res.data.filesResult.fileUrl;
//
async handleRequest ({ file }) {
this.coverUrl && Oss.del(this.coverUrl)
Oss.upload(file).then(res => {
this.coverUrl = res.url
})
},
uploadError(err, file, fileList) {
uploadError (err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
let fileName = this.coverUrl.replace("https://liuwanr.oss-cn-shenzhen.aliyuncs.com/", "");
this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => {
this.coverUrl = "";
}).catch(res => {
});
handleRemove (file, fileList) {
Oss.del(this.coverUrl)
this.coverUrl = ''
},
save() {
save () {
this.form.logoUrl = this.coverUrl;
if (this.form.id) {
this.$post(this.api.logoUpdate, this.form).then(res => {
util.successMsg("更新成功");
this.getSystemDetail();
}).catch(res => {});
}).catch(res => { });
} else {
this.$post(this.api.logoSave, this.form).then(res => {
util.successMsg("新增成功");
this.getSystemDetail();
}).catch(res => {});
}).catch(res => { });
}
}
}
@ -123,7 +130,7 @@ export default {
<style lang="scss" scoped>
$avatar-width: 104px;
/deep/ .avatar-uploader {
.el-upload {
.el-upload {
position: relative;
width: $avatar-width;
border: 1px dashed #d9d9d9;
@ -131,11 +138,11 @@ $avatar-width: 104px;
cursor: pointer;
overflow: hidden;
&:hover {
border-color: #409EFF;
&:hover {
border-color: #409eff;
}
.uploader-default {
.uploader-default {
display: flex;
flex-direction: column;
justify-content: center;
@ -144,47 +151,48 @@ $avatar-width: 104px;
text-align: center;
background: rgba(0, 0, 0, 0.04);
i {
i {
font-size: 20px;
font-weight: bold;
color: #8c939d;
}
}
p {
p {
margin-top: 10px;
font-size: 14px;
color: rgba(0, 0, 0, 0.65);
line-height: 1;
}
}
}
}
.avatar {
.avatar {
width: $avatar-width;
height: $avatar-width;
display: block;
}
}
}
}
.el-upload__tip {
.el-upload__tip {
margin-top: 0;
p {
p {
font-size: 14px;
color: rgba(0, 0, 0, 0.45);
line-height: 1;
&:first-child {
&:first-child {
margin-bottom: 5px;
}
}
}
}
}
}
/deep/ .d-inline-block {
width: 216px;
.el-select, .el-input {
.el-select,
.el-input {
width: 100%;
}
}
}
</style>

@ -30,7 +30,7 @@ if (isPro) {
uploadURL = `http://121.37.12.51/`
host = "http://121.37.12.51/"; // 中台测试服
// host = 'https://www.occupationlab.com/' // 正式服
// host = "http://192.168.31.217:9000/"; // 榕
host = "http://192.168.31.217:9000/"; // 榕
// host = 'http://192.168.31.51:9000/'; // 赓
} else if (isSq) {
zcPath = `10.20.100.204:8883`

Loading…
Cancel
Save