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`, deleteProfile : `users/users/userInfo/deleteProfile`,
refreshPageNotification : `nakadai/message/refreshPageNotification`, refreshPageNotification : `nakadai/message/refreshPageNotification`,
getPlayAuth: `${uploadURL}oss/manage/getPlayAuth`, // 获取播放凭证
platformLogList: `nakadai/nakadai/log/platformLogList`, platformLogList: `nakadai/nakadai/log/platformLogList`,
logNotification: `nakadai/nakadai/log/logNotification`, logNotification: `nakadai/nakadai/log/logNotification`,
//实验台 //实验台
@ -304,14 +306,6 @@ export default {
editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节 editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节
getSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/getSubsection`, // 根据小节id获取预览文件地址 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`, //查询省份 queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份
queryCity: `nakadai/nakadai/city/queryCity`, //查询城市 queryCity: `nakadai/nakadai/city/queryCity`, //查询城市
querySchoolData: `nakadai/nakadai/school/querySchool`, //根据学校名称查询学校信息 querySchoolData: `nakadai/nakadai/school/querySchool`, //根据学校名称查询学校信息

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

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

@ -102,7 +102,7 @@ export default {
this.uploading = true this.uploading = true
this.showFiles = false this.showFiles = false
// oss // 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 progress: this.handleProgress
}); });

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

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

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

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

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

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

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

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

@ -1,45 +1,43 @@
<template> <template>
<!-- 大赛详情 --> <!-- 大赛详情 -->
<div> <div>
<el-card shadow="hover" style="margin-bottom: 20px"> <el-card shadow="hover"
style="margin-bottom: 20px">
<div class="flex-between"> <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> </div>
</el-card> </el-card>
<div class="page"> <div class="page">
<div class="page-content"> <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="公告标题"> <el-form-item label="公告标题">
<div class="d-inline-block"> <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> </div>
</el-form-item> </el-form-item>
<el-form-item label="正文"> <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>
<el-form-item label="附件"> <el-form-item label="附件">
<el-upload <Upload :limit="5"
: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"
:file-list="fileList" :file-list="fileList"
name="file" :on-remove="handleRemove"
> @onSuccess="uploadSuccess" />
<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>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button v-if="!form.id" @click="save(0)" v-auth="'/match/list:管理:公告通知:草稿'">草稿</el-button> <el-button v-if="!form.id"
<el-button type="primary" @click="save(1)" v-auth="'/match/list:管理:公告通知:发布'">发布</el-button> @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-button @click="back">取消</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -52,9 +50,11 @@
import quill from "@/components/quill"; import quill from "@/components/quill";
import util from "@/libs/util"; import util from "@/libs/util";
import Setting from "@/setting"; import Setting from "@/setting";
import Upload from '@/components/upload';
import Oss from '@/components/upload/upload.js'
export default { export default {
name: "matchDetail", name: "matchDetail",
data() { data () {
return { return {
headers: { headers: {
token: util.local.get(Setting.tokenKey) token: util.local.get(Setting.tokenKey)
@ -73,23 +73,24 @@ export default {
}; };
}, },
components: { components: {
quill quill,
Upload
}, },
watch: { watch: {
// , // ,
form: { form: {
handler(){ handler () {
this.updateTime++ 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() this.form.id && this.getData()
}, },
methods: { methods: {
getData() { getData () {
this.$post(`${this.api.queryAnnouncementDetails}?id=${this.form.id}`).then(({ data }) => { this.$post(`${this.api.queryAnnouncementDetails}?id=${this.form.id}`).then(({ data }) => {
this.form = data this.form = data
// //
@ -106,10 +107,10 @@ export default {
} else { } else {
data.announcementAnnexList = [] data.announcementAnnexList = []
} }
}).catch(err => {}) }).catch(err => { })
}, },
// //
save(status) { save (status) {
const form = this.form const form = this.form
if (!form.announcementTitle) return util.warningMsg('请填写公告标题') if (!form.announcementTitle) return util.warningMsg('请填写公告标题')
if (!form.announcementText) return util.warningMsg('请填写正文') if (!form.announcementText) return util.warningMsg('请填写正文')
@ -120,53 +121,52 @@ export default {
this.$post(this.api.amendmentAnnouncement, form).then(res => { this.$post(this.api.amendmentAnnouncement, form).then(res => {
util.successMsg("修改成功") util.successMsg("修改成功")
this.$router.back() this.$router.back()
}).catch(err => {}) }).catch(err => { })
} else { } else {
form.isOpen = status ? 0 : 1 form.isOpen = status ? 0 : 1
this.$post(this.api.addAnnouncement, form).then(res => { this.$post(this.api.addAnnouncement, form).then(res => {
util.successMsg("创建成功") util.successMsg("创建成功")
this.$router.back() this.$router.back()
}).catch(err => {}) }).catch(err => { })
} }
}, },
handleExceed(files, fileList) { handleExceed (files, fileList) {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`); util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
}, },
// //
uploadSuccess(res) { uploadSuccess (file) {
const file = res.data.filesResult
const { id } = this.form const { id } = this.form
const data = { const data = {
announcementId: id || '', announcementId: id || '',
fileName: this.fileName, fileName: file.name,
filePath: file.fileUrl || file.fileId filePath: file.url
} }
this.form.announcementAnnexList.push(data) 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 this.fileName = file.name
}, },
uploadError(err, file, fileList) { uploadError (err, file, fileList) {
this.$message({ this.$message({
message: "上传出错,请重试!", message: "上传出错,请重试!",
type: "error", type: "error",
center: true center: true
}); });
}, },
beforeRemove(file, fileList) { beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`); return this.$confirm(`确定移除 ${file.name}`);
}, },
handleRemove(file, fileList) { handleRemove (file, fileList) {
if (file.url) { 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 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() this.$router.back()
} }
} }
@ -256,7 +256,8 @@ $upload-lg-height: 150px;
/deep/ .d-inline-block { /deep/ .d-inline-block {
width: 216px; width: 216px;
.el-select, .el-input { .el-select,
.el-input {
width: 100%; width: 100%;
} }
} }
@ -276,7 +277,7 @@ $upload-lg-height: 150px;
.remove { .remove {
width: 16px; width: 16px;
height: 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; cursor: pointer;
} }
} }

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

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

Loading…
Cancel
Save