oss全部替换完成

master
yujialong 1 year ago
parent 2cb471ec92
commit d9f2543d30
  1. 10
      src/api/index.js
  2. 57
      src/components/editor.js
  3. 71
      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. 36
      src/pages/activity/manage/manage/noticeDetail.vue
  8. 772
      src/pages/course/add/index.vue
  9. 169
      src/pages/course/contentSettings/index.vue
  10. 466
      src/pages/information/addarticle/index.vue
  11. 82
      src/pages/match/add/step1.vue
  12. 20
      src/pages/match/add/step3.vue
  13. 319
      src/pages/match/manage/noticeDetail.vue
  14. 320
      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,23 +348,13 @@ 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', load.close()
url: Api.fileUploadNakadai, callback(res.url)
data: fd, }).catch(e => {
headers: { load.close()
'Content-Type': 'multipart/form-data', })
token: Util.local.get(Setting.tokenKey)
},
}).then(({ data }) => {
load.close()
callback(data.filesResult.fileUrl)
}).catch(res => {
load.close()
})
} }
//触发点击 //触发点击
input.click(); input.click();

@ -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">
<el-button :id="'editorUpload' + index" <div slot="trigger">
type="primary">点击上传</el-button> <el-button :id="'editorUpload' + index"
</el-upload> type="primary">点击上传</el-button>
</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" :file-list="fileList"
:on-success="uploadSuccess" :on-remove="handleRemove"
:before-upload="beforeUpload" @onSuccess="uploadSuccess" />
:before-remove="beforeRemove"
:limit="5"
:on-exceed="handleExceed"
: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-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,385 +1,428 @@
<template> <template>
<div> <div>
<el-card shadow="hover" class="m-b-20"> <el-card shadow="hover"
<div class="flex-between"> class="m-b-20">
<el-page-header @back="back" :content="form.id ? '编辑课程' : '新增课程'"></el-page-header> <div class="flex-between">
</div> <el-page-header @back="back"
</el-card> :content="form.id ? '编辑课程' : '新增课程'"></el-page-header>
</div>
</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"
<div class="d-inline-block"> :rules="rules"
<el-input placeholder="请输入课程名称" v-model="form.courseName" clearable maxlength="25" @change="nameChange"></el-input> ref="form"
</div> :disabled="isDetail"
</el-form-item> label-width="120px"
<el-form-item prop="courseType" label="课程类型"> label-suffix=":">
<div class="d-inline-block"> <el-form-item prop="courseName"
<el-select v-model="form.courseType" placeholder="请选择课程类型"> label="课程名称">
<el-option label="免费" :value="0"></el-option> <div class="d-inline-block">
<!-- <el-option label="付费" :value="1"></el-option> --> <el-input placeholder="请输入课程名称"
</el-select> v-model="form.courseName"
</div> clearable
</el-form-item> maxlength="25"
<el-form-item prop="visibleRange" label="可见范围"> @change="nameChange"></el-input>
<div> </div>
<el-radio v-model="form.visibleRange" :label="0" @change="visibleChange">仅本校</el-radio> </el-form-item>
</div> <el-form-item prop="courseType"
<div> label="课程类型">
<el-radio v-model="form.visibleRange" :label="1" @change="visibleChange">全平台</el-radio> <div class="d-inline-block">
</div> <el-select v-model="form.courseType"
</el-form-item> placeholder="请选择课程类型">
<el-form-item prop="schoolClassificationsIds" label="课程分类"> <el-option label="免费"
<div class="d-inline-block"> :value="0"></el-option>
<el-select v-model="form.schoolClassificationsIds" placeholder="请选择课程分类" multiple> <!-- <el-option label="付费" :value="1"></el-option> -->
<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 prop="visibleRange"
<el-form-item v-if="form.visibleRange == 1" prop="platformClassificationIds" label="平台课程分类"> label="可见范围">
<div class="d-inline-block"> <div>
<el-select v-model="form.platformClassificationIds" placeholder="请选择平台课程分类" multiple> <el-radio v-model="form.visibleRange"
<el-option v-for="item in platformClassificationList" :key="item.id" :label="item.classificationName" :value="item.id"></el-option> :label="0"
</el-select> @change="visibleChange">仅本校</el-radio>
</div> </div>
</el-form-item> <div>
<el-form-item prop="coverUrl" label="课程封面"> <el-radio v-model="form.visibleRange"
<el-upload :label="1"
class="avatar-uploader" @change="visibleChange">全平台</el-radio>
accept=".jpg,.png,.jpeg" </div>
:on-remove="handleRemove" </el-form-item>
:on-error="uploadError" <el-form-item prop="schoolClassificationsIds"
:on-success="uploadSuccess" label="课程分类">
:before-remove="beforeRemove" <div class="d-inline-block">
:limit="1" <el-select v-model="form.schoolClassificationsIds"
:on-exceed="handleExceed" placeholder="请选择课程分类"
:action="this.api.fileupload" multiple>
:headers="headers" <el-option v-for="item in classificationList"
name="file" :key="item.id"
> :label="item.classificationName"
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar"> :value="item.id"></el-option>
<div class="uploader-default" v-else> </el-select>
<i class="el-icon-plus"></i> </div>
<p>上传封面</p> </el-form-item>
</div> <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>
</div>
</el-form-item>
<el-form-item prop="coverUrl"
label="课程封面">
<el-upload class="avatar-uploader"
accept=".jpg,.png,.jpeg"
:on-remove="handleRemove"
:on-error="uploadError"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
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"
<p>只能上传jpg/png文件</p> class="el-upload__tip">
<p>课程封面图将按2:1显示最佳分辨率1400*700</p> <p>只能上传jpg/png文件</p>
</div> <p>课程封面图将按2:1显示最佳分辨率1400*700</p>
</el-upload> </div>
</el-form-item> </el-upload>
<el-form-item prop="courseIntroduction" label="课程介绍"> </el-form-item>
<quill :border="true" :readonly="isDetail" v-model="form.courseIntroduction" :height="400" /> <el-form-item prop="courseIntroduction"
</el-form-item> label="课程介绍">
<el-form-item> <quill :border="true"
<el-button type="primary" @click="save(0)" v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button> :readonly="isDetail"
</el-form-item> v-model="form.courseIntroduction"
</el-form> :height="400" />
</el-card> </el-form-item>
</div> <el-form-item>
<el-button type="primary"
@click="save(0)"
v-show="!isDetail">{{ form.id ? "更新" : "创建" }}</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</template> </template>
<script> <script>
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: {
token: util.local.get(Setting.tokenKey) token: util.local.get(Setting.tokenKey)
}, },
isDetail: Boolean(this.$route.query.show), isDetail: Boolean(this.$route.query.show),
form: { form: {
id: this.$route.query.id, id: this.$route.query.id,
courseIntroduction: '', courseIntroduction: '',
courseName: '', courseName: '',
courseType: 0, courseType: 0,
coverUrl: '', coverUrl: '',
platformSource: Setting.platformSource, platformSource: Setting.platformSource,
platformClassificationIds: [], platformClassificationIds: [],
schoolClassificationsIds: [], schoolClassificationsIds: [],
visibleRange: 0 visibleRange: 0
}, },
rules: { rules: {
courseName: [ courseName: [
{ required: true, message: '请输入课程名称', trigger: 'blur' } { required: true, message: '请输入课程名称', trigger: 'blur' }
], ],
platformClassificationIds: [ platformClassificationIds: [
{ required: true, message: '请选择平台课程分类', trigger: 'change' } { required: true, message: '请选择平台课程分类', trigger: 'change' }
], ],
schoolClassificationsIds: [ schoolClassificationsIds: [
{ required: true, message: '请选择课程分类', trigger: 'change' } { required: true, message: '请选择课程分类', trigger: 'change' }
], ],
coverUrl: [ coverUrl: [
{ required: true, message: '请选择课程封面', trigger: 'change' } { required: true, message: '请选择课程封面', trigger: 'change' }
], ],
courseType: [ courseType: [
{ required: true, message: '请选择课程类型', trigger: 'change' } { required: true, message: '请选择课程类型', trigger: 'change' }
], ],
visibleRange: [ visibleRange: [
{ required: true, message: '请选择可见范围', trigger: 'change' } { required: true, message: '请选择可见范围', trigger: 'change' }
], ],
courseIntroduction: [ courseIntroduction: [
{ required: true, message: '请输入课程介绍', trigger: 'blur' } { required: true, message: '请输入课程介绍', trigger: 'blur' }
] ]
}, },
platformClassificationList: [], platformClassificationList: [],
classificationList: [], classificationList: [],
uploadList: [], uploadList: [],
submiting: false, submiting: false,
updateTime: 0, updateTime: 0,
rangeVisible: false, rangeVisible: false,
range: [], range: [],
rangeInit: [], rangeInit: [],
rangeChecked: [], rangeChecked: [],
schools: [], schools: [],
rangeList: [], rangeList: [],
rangeTimer: null, rangeTimer: null,
// //
props: { props: {
multiple: true, multiple: true,
checkStrictly: true, checkStrictly: true,
lazy: true, lazy: true,
lazyLoad (node, resolve) { lazyLoad (node, resolve) {
// //
const input = document.querySelector('.el-cascader__search-input') const input = document.querySelector('.el-cascader__search-input')
const checked = that.rangeChecked const checked = that.rangeChecked
if (input && input.value.trim()) { if (input && input.value.trim()) {
const val = input.value.trim() const val = input.value.trim()
return that.schools.filter(e => e.label.includes(val)) return that.schools.filter(e => e.label.includes(val))
} }
const { level, value } = node const { level, value } = node
// //
if (!level) { if (!level) {
that.$get(that.api.queryProvince).then(({ list }) => { that.$get(that.api.queryProvince).then(({ list }) => {
const data = [] const data = []
list.map(e => { list.map(e => {
e.value = e.provinceId e.value = e.provinceId
e.label = e.provinceName e.label = e.provinceName
e.children = [] e.children = []
e.disabled = !!checked.find(n => n.provinceId == e.provinceId && !n.cityId) e.disabled = !!checked.find(n => n.provinceId == e.provinceId && !n.cityId)
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, {
provinceId: value provinceId: value
}).then(({ list }) => { }).then(({ list }) => {
const data = [] const data = []
list.map(e => { list.map(e => {
e.value = e.cityId e.value = e.cityId
e.label = e.cityName e.label = e.cityName
e.children = [] e.children = []
e.disabled = !!checked.find(n => n.cityId == e.cityId && n.provinceId == e.provinceId && !n.schoolId) e.disabled = !!checked.find(n => n.cityId == e.cityId && n.provinceId == e.provinceId && !n.schoolId)
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, {
provinceId: node.data.provinceId, provinceId: node.data.provinceId,
cityId: value, cityId: value,
schoolName: '' schoolName: ''
}).then(({ list }) => { }).then(({ list }) => {
const data = [] const data = []
list.map(e => { list.map(e => {
e.value = e.schoolId e.value = e.schoolId
e.label = e.schoolName e.label = e.schoolName
e.leaf = true e.leaf = true
e.disabled = !!checked.find(n => n.schoolId == e.schoolId && n.cityId == e.cityId && n.provinceId == e.provinceId) e.disabled = !!checked.find(n => n.schoolId == e.schoolId && n.cityId == e.cityId && n.provinceId == e.provinceId)
data.push(e) data.push(e)
}) })
resolve(data) resolve(data)
}).catch(res => {}) }).catch(res => { })
} else { } else {
resolve([]) resolve([])
} }
} }
}, },
nameRepeat: false nameRepeat: false
}; };
}, },
watch: { watch: {
// , // ,
form: { form: {
handler(val){ handler (val) {
this.updateTime++ this.updateTime++
}, },
deep:true deep: true
} }
},
// ,
beforeRouteLeave (to, from, next) {
if (this.updateTime) {
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
this.save(next)
}).catch(() => {
next()
})
} else {
next()
}
},
mounted () {
this.getClassification()
this.form.id && this.getData()
},
components: {
quill
},
methods: {
//
getClassification () {
//
this.$post(this.api.listClassification, {
pageNum: 1,
pageSize: 1000,
platformSource: 0
}).then(({ page }) => {
this.platformClassificationList = page.records
}).catch(res => { })
//
this.$post(this.api.listClassification, {
pageNum: 1,
pageSize: 1000,
platformSource: Setting.platformSource
}).then(({ page }) => {
this.classificationList = page.records
}).catch(res => { })
}, },
// , getData () {
beforeRouteLeave(to, from, next) { this.$post(`${this.api.findTheoreticalCourse}?id=${this.form.id}`).then(({ data }) => {
if(this.updateTime){ // id
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', { if (data.platformClassificationList) {
type: 'warning' data.platformClassificationIds = data.platformClassificationList.map(e => e.classificationId)
}).then(() => { delete data.platformClassificationList
this.save(next)
}).catch(() => {
next()
})
}else{
next()
} }
if (data.schoolClassificationsList) {
data.schoolClassificationsIds = data.schoolClassificationsList.map(e => e.classificationId)
delete data.schoolClassificationsList
}
this.visibleChange(data.visibleRange)
this.form = data
this.$nextTick(() => {
this.updateTime = 0
})
this.uploadList.push({
name: "cover.jpg",
url: data.coverUrl
})
}).catch(err => { })
}, },
mounted() { //
this.getClassification() nameChange (val) {
this.form.id && this.getData() this.$post(this.api.checkRepeatTheoreticalCourse, {
id: this.form.id,
courseName: val,
platformSource: Setting.platformSource
}).then(res => {
this.nameRepeat = false
}).catch(err => {
this.nameRepeat = true
})
}, },
components: { //
quill visibleChange (val) {
this.rules.platformClassificationIds[0].required = val == 1
}, },
methods: { handleExceed (files, fileList) { //
// util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
getClassification() { },
// handleRequest ({ file }) {
this.$post(this.api.listClassification, { this.form.coverUrl && Oss.del(this.form.coverUrl)
pageNum: 1, Oss.upload(file).then(res => {
pageSize: 1000, this.form.coverUrl = res.url
platformSource: 0 })
}).then(({ page }) => { },
this.platformClassificationList = page.records uploadError (err, file, fileList) {
}).catch(res => {}) this.$message({
message: "上传出错,请重试!",
// type: "error",
this.$post(this.api.listClassification, { center: true
pageNum: 1, });
pageSize: 1000, },
platformSource: Setting.platformSource beforeRemove (file, fileList) {
}).then(({ page }) => { return this.$confirm(`确定移除 ${file.name}`);
this.classificationList = page.records },
}).catch(res => {}) handleRemove () {
}, Oss.del(this.form.coverUrl)
getData() { this.form.coverUrl = ''
this.$post(`${this.api.findTheoreticalCourse}?id=${this.form.id}`).then(({ data }) => { },
// id save (cb) {
if (data.platformClassificationList) { this.$refs.form.validate((valid) => {
data.platformClassificationIds = data.platformClassificationList.map(e => e.classificationId) if (valid) {
delete data.platformClassificationList if (this.nameRepeat) return util.errorMsg('当前课程名已存在!')
} if (this.submiting) return false
if (data.schoolClassificationsList) { const { form } = this
data.schoolClassificationsIds = data.schoolClassificationsList.map(e => e.classificationId) this.submiting = true
delete data.schoolClassificationsList if (form.id) {
} form.courseId = form.id
this.visibleChange(data.visibleRange) form.platformSource = Setting.platformSource
this.form = data this.$post(this.api.updateTheoreticalCourse, form).then(res => {
this.$nextTick(() => {
this.updateTime = 0 this.updateTime = 0
}) this.submiting = false;
this.uploadList.push({ util.successMsg("修改成功");
name: "cover.jpg", cb ? cb() : this.$router.back()
url: data.coverUrl }).catch(err => {
}) this.submiting = false;
}).catch(err => {}) });
}, } else {
// this.$post(this.api.saveTheoreticalCourse, form).then(({ courseId }) => {
nameChange(val) { this.submiting = false;
this.$post(this.api.checkRepeatTheoreticalCourse, { this.updateTime = 0
id: this.form.id, this.$confirm("课程创建成功,是否马上进行课程内容设置?", "提示", {
courseName: val, type: "success",
platformSource: Setting.platformSource confirmButtonText: "马上设置",
}).then(res => { cancelButtonText: "稍后操作"
this.nameRepeat = false }).then(() => {
}).catch(err => { this.$router.replace(`/course/contentSettings?id=${courseId}`);
this.nameRepeat = true }).catch(() => {
}) cb ? cb() : this.$router.back()
}, });
// }).catch(err => {
visibleChange(val) { this.submiting = false;
this.rules.platformClassificationIds[0].required = val == 1 });
},
handleExceed(files, fileList) { //
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
},
uploadSuccess(res, file, fileList) {
this.form.coverUrl = res.data.filesResult.fileUrl
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
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 => {
this.form.coverUrl = ''
}).catch(res => {});
},
save(cb) {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.nameRepeat) return util.errorMsg('当前课程名已存在!')
if (this.submiting) return false
const { form } = this
this.submiting = true
if (form.id) {
form.courseId = form.id
form.platformSource = Setting.platformSource
this.$post(this.api.updateTheoreticalCourse, form).then(res => {
this.updateTime = 0
this.submiting = false;
util.successMsg("修改成功");
cb ? cb() : this.$router.back()
}).catch(err => {
this.submiting = false;
});
} else {
this.$post(this.api.saveTheoreticalCourse, form).then(({ courseId }) => {
this.submiting = false;
this.updateTime = 0
this.$confirm("课程创建成功,是否马上进行课程内容设置?", "提示", {
type: "success",
confirmButtonText: "马上设置",
cancelButtonText: "稍后操作"
}).then(() => {
this.$router.replace(`/course/contentSettings?id=${courseId}`);
}).catch(() => {
cb ? cb() : this.$router.back()
});
}).catch(err => {
this.submiting = false;
});
}
} }
}) }
}, })
// },
backPage() { //
this.$router.back() backPage () {
}, this.$router.back()
back() { },
const updateTime = this.updateTime back () {
// const updateTime = this.updateTime
if (updateTime) { //
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { if (updateTime) {
type: 'warning' this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
}).then(() => { type: 'warning'
this.save() }).then(() => {
}).catch(() => { this.save()
this.updateTime = 0 }).catch(() => {
this.backPage()
})
} else {
this.updateTime = 0 this.updateTime = 0
this.backPage() this.backPage()
} })
} else {
this.updateTime = 0
this.backPage()
} }
} }
}
}; };
</script> </script>
@ -395,7 +438,7 @@ $avatar-width: 104px;
overflow: hidden; overflow: hidden;
&:hover { &:hover {
border-color: #409EFF; border-color: #409eff;
} }
.uploader-default { .uploader-default {
@ -446,17 +489,18 @@ $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%;
} }
} }
.range-check { .range-check {
display: inline-block; display: inline-block;
margin: 0 0 10px 10px; margin: 0 0 10px 10px;
} }
/deep/.range-cas { /deep/.range-cas {
.el-tag { .el-tag {
display: none; display: none;
} }
} }
</style> </style>

@ -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" :file-list="uploadList"
:on-error="uploadError" :on-remove="handleRemove"
:on-success="uploadSuccess" @beforeUpload="beforeUpload"
:before-remove="beforeRemove" @onSuccess="uploadSuccess">
:limit="1" <template slot="tip">
:on-exceed="handleExceed" <p>视频请上传MP4格式大小不超过30Moffice文件大小不要超过10M</p>
:action="this.api.fileupload" </template>
:file-list="uploadList" </Upload>
: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>
</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) { this.uploading = false
const param = new FormData() this.fileId = ''
param.append('file', data.file) this.fileType = file.format
const config = { this.fileUrl = file.url
timeout: 10000000000, this.fileName = file.name
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.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;
}, },
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,22 +751,26 @@ export default {
}, },
preview (row) { preview (row) {
if (this.transferType(row.fileType) == "视频") { if (this.transferType(row.fileType) == "视频") {
this.$get(`${this.api.getPlayAuth}/${row.fileId}`).then(res => { //
this.playAuth = res.data.playAuth; if (row.fileId) {
if (this.player) { this.$get(`${this.api.getPlayAuth}/${row.fileId}`).then(res => {
this.player.replayByVidAndPlayAuth(row.fileId, this.playAuth); this.playAuth = res.data.playAuth;
} else { if (this.player) {
this.player = new Aliplayer({ this.player.replayByVidAndPlayAuth(row.fileId, this.playAuth);
id: "player", } else {
width: "100%", this.player = new Aliplayer({
autoplay: false, id: "player",
vid: row.fileId, width: "100%",
playauth: this.playAuth, autoplay: false,
encryptType: 1 // vid: row.fileId,
}); playauth: this.playAuth,
} 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,247 +1,266 @@
<template> <template>
<div> <div>
<el-card shadow="hover" class="m-b-20"> <el-card shadow="hover"
<div class="flex-between"> class="m-b-20">
<el-page-header @back="back" :content="'新增文章'"></el-page-header> <div class="flex-between">
<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"
accept=".jpg,.png,.jpeg"
:on-remove="handleRemove"
:on-error="uploadError"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
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>
</el-card> </el-upload>
<el-card shadow="hover" class="m-b-20"> </el-form-item>
<el-form :model="form" :rules="rules" ref="form" label-width="90px" label-suffix=":" size="small"> <el-form-item prop="author"
<el-form-item prop="coverUrl" label="封面图"> label="作者">
<el-upload <div class="d-inline-block">
class="avatar-uploader" <el-input placeholder="请输入作者"
accept=".jpg,.png,.jpeg" v-model="form.author"
:on-remove="handleRemove" clearable></el-input>
:on-error="uploadError" </div>
:on-success="uploadSuccess" </el-form-item>
:before-remove="beforeRemove" <el-form-item prop="date"
:limit="1" label="日期">
:on-exceed="handleExceed" <div class="d-inline-block">
:action="this.api.fileupload" <el-date-picker v-model="form.date"
:headers="headers" type="date"
name="file" value-format="yyyy-MM-dd HH:mm:ss"
> placeholder="选择日期"></el-date-picker>
<img v-if="form.coverUrl" :src="form.coverUrl" class="avatar"> </div>
<div class="uploader-default" v-else> </el-form-item>
<i class="el-icon-plus"></i> <el-form-item prop="title"
<p>上传封面</p> label="文章标题">
</div> <el-input placeholder="请输入文章标题"
</el-upload> v-model="form.title"
</el-form-item> clearable></el-input>
<el-form-item prop="author" label="作者"> </el-form-item>
<div class="d-inline-block"> <el-form-item prop="content"
<el-input placeholder="请输入作者" v-model="form.author" clearable></el-input> label="文章内容">
</div> <quill :border="true"
</el-form-item> v-model="form.content"
<el-form-item prop="date" label="日期"> :uploading.sync="uploading"
<div class="d-inline-block"> :height="400" />
<el-date-picker v-model="form.date" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker> </el-form-item>
</div> <el-form-item>
</el-form-item> <el-button type="primary"
<el-form-item prop="title" label="文章标题"> @click="save(0)">确定</el-button>
<el-input placeholder="请输入文章标题" v-model="form.title" clearable></el-input> </el-form-item>
</el-form-item> </el-form>
<el-form-item prop="content" label="文章内容"> </el-card>
<quill :border="true" v-model="form.content" :uploading.sync="uploading" :height="400" /> </div>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save(0)">确定</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</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: {
token: util.local.get(Setting.tokenKey) token: util.local.get(Setting.tokenKey)
}, },
form: { form: {
columnId: +this.$route.query.columnId, columnId: +this.$route.query.columnId,
sort: +this.$route.query.sort, sort: +this.$route.query.sort,
id: '', id: '',
coverUrl: '', coverUrl: '',
author: '', author: '',
date: '', date: '',
title: '', title: '',
content: '', content: '',
createUser: this.customerName || this.userName createUser: this.customerName || this.userName
}, },
rules: { rules: {
coverUrl: [ coverUrl: [
{ required: true, message: '请上传封面', trigger: 'change' } { required: true, message: '请上传封面', trigger: 'change' }
], ],
author: [ author: [
{ required: true, message: '请输入作者', trigger: 'blur' } { required: true, message: '请输入作者', trigger: 'blur' }
], ],
date: [ date: [
{ required: true, message: '请选择日期', trigger: 'change' } { required: true, message: '请选择日期', trigger: 'change' }
], ],
title: [ title: [
{ required: true, message: '请输入文章标题', trigger: 'blur' } { required: true, message: '请输入文章标题', trigger: 'blur' }
], ],
content: [ content: [
{ required: true, message: '请输入文章内容', trigger: 'blur' } { required: true, message: '请输入文章内容', trigger: 'blur' }
], ],
}, },
uploadList: [], uploadList: [],
uploadDataList: [], uploadDataList: [],
submiting: false, submiting: false,
uploading: false, uploading: false,
updateTime: 0, updateTime: 0,
}; };
},
computed: {
...mapState("user", [
"userName", "customerName"
])
},
components: {
quill
},
watch: {
// ,
form: {
handler (val) {
this.updateTime++
},
deep: true
}
},
// ,
beforeRouteLeave (to, from, next) {
if (this.updateTime) {
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
this.save(next)
}).catch(() => {
next()
})
} else {
next()
}
},
mounted () {
this.id && this.getData();
},
methods: {
getData () {
this.$get(`${this.api.getArticle}?articleId=${this.id}`).then(({ article }) => {
this.form = article
this.$nextTick(() => {
this.updateTime = 0
})
}).catch(err => { })
}, },
computed: { handleCurrentChange (val) {
...mapState("user", [ this.currPage = val;
"userName", "customerName"
])
}, },
components: { handleExceed (files, fileList) {
quill util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
}, },
watch: { //
// , async handleRequest ({ file }) {
form: { this.form.coverUrl && Oss.del(this.form.coverUrl)
handler(val){ Oss.upload(file).then(res => {
this.updateTime++ this.form.coverUrl = res.url
}, })
deep:true
}
}, },
// , uploadError (err, file, fileList) {
beforeRouteLeave(to, from, next) { this.$message({
if(this.updateTime){ message: "上传出错,请重试!",
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', { type: "error",
type: 'warning' center: true
}).then(() => { });
this.save(next) },
}).catch(() => { beforeRemove (file, fileList) {
next() return this.$confirm(`确定移除 ${file.name}`);
}) },
}else{ handleRemove (file, fileList) {
next() Oss.del(this.form.coverUrl)
} this.form.coverUrl = ''
},
uploadSure () {
this.BatchUpload = false;
this.pageNo = 1;
this.keyword = "";
this.getData();
}, },
mounted() { addSponsor () {
this.id && this.getData(); this.sponsorList.push("");
}, },
methods: { delSponsor (index) {
getData() { this.sponsorList.splice(index, 1);
this.$get(`${this.api.getArticle}?articleId=${this.id}`).then(({ article }) => { },
this.form = article addOrganizer () {
this.$nextTick(() => { this.organzinerList.push("");
},
delOrganizer (index) {
this.organzinerList.splice(index, 1);
},
save (cb) {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
const { form } = this
if (this.uploading) return util.warningMsg("图片正在上传中,请稍等");
this.submiting = true
if (form.id) {
this.$put(this.api.editArticle, form).then(res => {
this.submiting = false;
util.successMsg("修改成功");
this.updateTime = 0 this.updateTime = 0
cb ? cb() : this.$router.back()
}) })
}).catch(err => {}) .catch(err => {
}, this.submiting = false;
handleCurrentChange(val) { });
this.currPage = val; } else {
}, this.createUser = this.customerName || this.userName
handleExceed(files, fileList) { this.$post(this.api.addArticle, form).then(res => {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`); this.submiting = false;
}, util.successMsg("创建成功");
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;
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
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 => {
});
},
uploadSure() {
this.BatchUpload = false;
this.pageNo = 1;
this.keyword = "";
this.getData();
},
addSponsor() {
this.sponsorList.push("");
},
delSponsor(index) {
this.sponsorList.splice(index, 1);
},
addOrganizer() {
this.organzinerList.push("");
},
delOrganizer(index) {
this.organzinerList.splice(index, 1);
},
save(cb) {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
const { form } = this
if (this.uploading) return util.warningMsg("图片正在上传中,请稍等");
this.submiting = true
if (form.id) {
this.$put(this.api.editArticle, form).then(res => {
this.submiting = false;
util.successMsg("修改成功");
this.updateTime = 0
cb ? cb() : this.$router.back()
})
.catch(err => {
this.submiting = false;
});
} else {
this.createUser = this.customerName || this.userName
this.$post(this.api.addArticle, form).then(res => {
this.submiting = false;
util.successMsg("创建成功");
this.updateTime = 0
cb ? cb() : this.$router.back()
})
.catch(err => {
this.submiting = false;
});
}
}
})
},
back() {
//
if (this.updateTime) {
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
type: 'warning'
}).then(() => {
this.save()
}).catch(() => {
this.updateTime = 0 this.updateTime = 0
this.$router.back() cb ? cb() : this.$router.back()
}) })
} else { .catch(err => {
this.updateTime = 0 this.submiting = false;
this.$router.back() });
} }
} }
})
},
back () {
//
if (this.updateTime) {
this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
type: 'warning'
}).then(() => {
this.save()
}).catch(() => {
this.updateTime = 0
this.$router.back()
})
} else {
this.updateTime = 0
this.$router.back()
}
} }
}
}; };
</script> </script>
@ -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) {
item.competitionStageContentSetting.fileList.push({ Oss.upload(file).then(res => {
name: originalFileName, item.competitionStageContentSetting.fileList.push({
url: fileUrl name: res.name,
url: res.url
})
}) })
}, },

@ -1,175 +1,175 @@
<template> <template>
<!-- 大赛详情 --> <!-- 大赛详情 -->
<div> <div>
<el-card shadow="hover" style="margin-bottom: 20px"> <el-card shadow="hover"
<div class="flex-between"> style="margin-bottom: 20px">
<el-page-header @back="back" :content="(form.id ? '编辑' : '创建') + '公告'"></el-page-header> <div class="flex-between">
</div> <el-page-header @back="back"
</el-card> :content="(form.id ? '编辑' : '创建') + '公告'"></el-page-header>
<div class="page"> </div>
<div class="page-content"> </el-card>
<el-form label-width="170px" label-suffix=":" size="small"> <div class="page">
<el-form-item label="公告标题"> <div class="page-content">
<div class="d-inline-block"> <el-form label-width="170px"
<el-input placeholder="请输入公告名称" v-model="form.announcementTitle" clearable></el-input> label-suffix=":"
</div> size="small">
</el-form-item> <el-form-item label="公告标题">
<el-form-item label="正文"> <div class="d-inline-block">
<quill :border="true" v-model="form.announcementText" :height="400" /> <el-input placeholder="请输入公告名称"
</el-form-item> v-model="form.announcementTitle"
<el-form-item label="附件"> clearable></el-input>
<el-upload </div>
:on-remove="handleRemove" </el-form-item>
:on-error="uploadError" <el-form-item label="正文">
:on-success="uploadSuccess" <quill :border="true"
:before-upload="beforeUpload" v-model="form.announcementText"
:before-remove="beforeRemove" :height="400" />
:limit="5" </el-form-item>
:on-exceed="handleExceed" <el-form-item label="附件">
:action="this.api.fileupload" <Upload :limit="5"
:headers="headers" :file-list="fileList"
:file-list="fileList" :on-remove="handleRemove"
name="file" @onSuccess="uploadSuccess" />
> </el-form-item>
<el-button size="small" type="primary">点击上传</el-button> <el-form-item>
<div slot="tip" class="el-upload__tip"> <el-button v-if="!form.id"
<p>支持扩展名.rar .zip .doc .docx .pdf .jpg...</p> @click="save(0)"
</div> v-auth="'/match/list:管理:公告通知:草稿'">草稿</el-button>
</el-upload> <el-button type="primary"
</el-form-item> @click="save(1)"
<el-form-item> v-auth="'/match/list:管理:公告通知:发布'">发布</el-button>
<el-button v-if="!form.id" @click="save(0)" v-auth="'/match/list:管理:公告通知:草稿'">草稿</el-button> <el-button @click="back">取消</el-button>
<el-button type="primary" @click="save(1)" v-auth="'/match/list:管理:公告通知:发布'">发布</el-button> </el-form-item>
<el-button @click="back">取消</el-button> </el-form>
</el-form-item>
</el-form>
</div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
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)
}, },
form: { form: {
id: this.$route.query.id, id: this.$route.query.id,
competitionId: this.$route.query.competitionId, competitionId: this.$route.query.competitionId,
announcementText: '', announcementText: '',
announcementTitle: '', announcementTitle: '',
announcementAnnexList: [], announcementAnnexList: [],
isOpen: 1 isOpen: 1
}, },
updateTime: 0, updateTime: 0,
fileName: '', fileName: '',
fileList: [], fileList: [],
}; };
},
components: {
quill,
Upload
},
watch: {
// ,
form: {
handler () {
this.updateTime++
if (this.updateTime > 1) this.$store.commit('match/setWait', 0)
},
deep: true
}, },
components: { },
quill mounted () {
this.form.id && this.getData()
},
methods: {
getData () {
this.$post(`${this.api.queryAnnouncementDetails}?id=${this.form.id}`).then(({ data }) => {
this.form = data
//
const fileList = data.announcementAnnexList
if (fileList) {
const files = []
fileList.map(e => {
files.push({
name: e.fileName,
url: e.filePath
})
})
this.fileList = files
} else {
data.announcementAnnexList = []
}
}).catch(err => { })
}, },
watch: { //
// , save (status) {
form: { const form = this.form
handler(){ if (!form.announcementTitle) return util.warningMsg('请填写公告标题')
this.updateTime++ if (!form.announcementText) return util.warningMsg('请填写正文')
if(this.updateTime > 1) this.$store.commit('match/setWait', 0) form.status = status
}, if (form.id) {
deep:true form.isOpen = 0
}, delete form.announcementAnnexList
this.$post(this.api.amendmentAnnouncement, form).then(res => {
util.successMsg("修改成功")
this.$router.back()
}).catch(err => { })
} else {
form.isOpen = status ? 0 : 1
this.$post(this.api.addAnnouncement, form).then(res => {
util.successMsg("创建成功")
this.$router.back()
}).catch(err => { })
}
}, },
mounted() { handleExceed (files, fileList) {
this.form.id && this.getData() util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
}, },
methods: { //
getData() { uploadSuccess (file) {
this.$post(`${this.api.queryAnnouncementDetails}?id=${this.form.id}`).then(({ data }) => { const { id } = this.form
this.form = data const data = {
// announcementId: id || '',
const fileList = data.announcementAnnexList fileName: file.name,
if (fileList) { filePath: file.url
const files = [] }
fileList.map(e => { this.form.announcementAnnexList.push(data)
files.push({ //
name: e.fileName, id && this.$post(this.api.saveAnnouncementAnnex, data).then(res => { }).catch(res => { })
url: e.filePath },
}) //
}) beforeUpload (file) {
this.fileList = files this.fileName = file.name
} else { },
data.announcementAnnexList = [] uploadError (err, file, fileList) {
} this.$message({
}).catch(err => {}) message: "上传出错,请重试!",
}, type: "error",
// center: true
save(status) { });
const form = this.form },
if (!form.announcementTitle) return util.warningMsg('请填写公告标题') beforeRemove (file, fileList) {
if (!form.announcementText) return util.warningMsg('请填写正文') return this.$confirm(`确定移除 ${file.name}`);
form.status = status },
if (form.id) { handleRemove (file, fileList) {
form.isOpen = 0 if (file.url) {
delete form.announcementAnnexList Oss.del(file.url)
this.$post(this.api.amendmentAnnouncement, form).then(res => { const id = this.form.announcementAnnexList.find(e => e.fileName === file.name).id
util.successMsg("修改成功") this.$post(`${this.api.delAnnex}?id=${id}`).then(res => { }).catch(res => { })
this.$router.back() }
}).catch(err => {}) },
} else { back () {
form.isOpen = status ? 0 : 1 this.$router.back()
this.$post(this.api.addAnnouncement, form).then(res => {
util.successMsg("创建成功")
this.$router.back()
}).catch(err => {})
}
},
handleExceed(files, fileList) {
util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`);
},
//
uploadSuccess(res) {
const file = res.data.filesResult
const { id } = this.form
const data = {
announcementId: id || '',
fileName: this.fileName,
filePath: file.fileUrl || file.fileId
}
this.form.announcementAnnexList.push(data)
//
id && this.$post(this.api.saveAnnouncementAnnex, data).then(res => {}).catch(res => {})
},
//
beforeUpload(file) {
this.fileName = file.name
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
if (file.url) {
this.$del(`${this.api.fileDeletion}?keys=${file.url}`).then(res => {}).catch(res => {})
const id = this.form.announcementAnnexList.find(e => e.fileName === file.name).id
this.$post(`${this.api.delAnnex}?id=${id}`).then(res => {}).catch(res => {})
}
},
back() {
this.$router.back()
}
} }
}
}; };
</script> </script>
@ -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,190 +1,198 @@
<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"
<el-form-item label="标题"> label-width="100px">
<el-input v-model="form.title " ref="account" placeholder="请输入标题" style="width: 400px"></el-input> <el-form-item label="标题">
</el-form-item> <el-input v-model="form.title "
<el-form-item label="图标"> ref="account"
<el-upload placeholder="请输入标题"
class="avatar-uploader" style="width: 400px"></el-input>
accept=".jpg,.png,.jpeg" </el-form-item>
:on-remove="handleRemove" <el-form-item label="图标">
:on-error="uploadError" <el-upload class="avatar-uploader"
:on-success="uploadSuccess" accept=".jpg,.png,.jpeg"
:before-remove="beforeRemove" :on-remove="handleRemove"
:limit="1" :on-error="uploadError"
:on-exceed="handleExceed" :before-remove="beforeRemove"
:action="this.api.fileupload" :limit="1"
:headers="headers" :on-exceed="handleExceed"
name="file" action=""
> :http-request="handleRequest">
<img v-if="coverUrl" :src="coverUrl" class="avatar"> <img v-if="coverUrl"
<div class="uploader-default" v-else> :src="coverUrl"
<i class="el-icon-plus"></i> class="avatar">
<p>上传图标</p> <div class="uploader-default"
</div> v-else>
<i class="el-icon-plus"></i>
<p>上传图标</p>
</div>
<div slot="tip" class="el-upload__tip"> <div slot="tip"
<p>只能上传jpg/png文件</p> class="el-upload__tip">
<p>图标将按1:1显示最佳分辨率100*100</p> <p>只能上传jpg/png文件</p>
</div> <p>图标将按1:1显示最佳分辨率100*100</p>
</el-upload> </div>
</el-form-item> </el-upload>
<el-form-item> </el-form-item>
<el-button type="primary" @click="save">{{ form.id ? "更新" : "创建" }}</el-button> <el-form-item>
</el-form-item> <el-button type="primary"
</el-form> @click="save">{{ form.id ? "更新" : "创建" }}</el-button>
</div> </el-form-item>
</el-form>
</div>
</template> </template>
<script> <script>
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)
}, },
coverUrl: "", coverUrl: "",
uploadList: [], uploadList: [],
form: { form: {
id: "", id: "",
title: "", title: "",
logoUrl: "" logoUrl: ""
} }
}
},
mounted () {
this.getSystemDetail();
},
methods: {
...mapActions("user", [
"setTitle", "setLogoUrl"
]),
getSystemDetail () {
this.$get(this.api.logoDetail).then(res => {
if (res.data) {
this.form = res.data;
this.coverUrl = res.data.logoUrl;
this.uploadList.push({
name: "logo.jpg",
url: this.coverUrl
});
this.setTitle(res.data.title);
this.setLogoUrl(res.data.logoUrl);
} }
}).catch(res => { });
}, },
mounted() { handleExceed (files, fileList) { //
this.getSystemDetail(); util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!");
}, },
methods: { //
...mapActions("user", [ async handleRequest ({ file }) {
"setTitle", "setLogoUrl" this.coverUrl && Oss.del(this.coverUrl)
]), Oss.upload(file).then(res => {
getSystemDetail () { this.coverUrl = res.url
this.$get(this.api.logoDetail).then(res => { })
if (res.data) { },
this.form = res.data; uploadError (err, file, fileList) {
this.coverUrl = res.data.logoUrl; this.$message({
this.uploadList.push({ message: "上传出错,请重试!",
name: "logo.jpg", type: "error",
url: this.coverUrl center: true
}); });
this.setTitle(res.data.title); },
this.setLogoUrl(res.data.logoUrl); beforeRemove (file, fileList) {
} return this.$confirm(`确定移除 ${file.name}`);
}).catch(res => {}); },
}, handleRemove (file, fileList) {
handleExceed(files, fileList) { // Oss.del(this.coverUrl)
util.warningMsg("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); this.coverUrl = ''
}, },
uploadSuccess(res, file, fileList) { save () {
this.coverUrl = res.data.filesResult.fileUrl; this.form.logoUrl = this.coverUrl;
}, if (this.form.id) {
uploadError(err, file, fileList) { this.$post(this.api.logoUpdate, this.form).then(res => {
this.$message({ util.successMsg("更新成功");
message: "上传出错,请重试!", this.getSystemDetail();
type: "error", }).catch(res => { });
center: true } else {
}); this.$post(this.api.logoSave, this.form).then(res => {
}, util.successMsg("新增成功");
beforeRemove(file, fileList) { this.getSystemDetail();
return this.$confirm(`确定移除 ${file.name}`); }).catch(res => { });
}, }
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 => {
});
},
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 => {});
} else {
this.$post(this.api.logoSave, this.form).then(res => {
util.successMsg("新增成功");
this.getSystemDetail();
}).catch(res => {});
}
}
} }
}
}; };
</script> </script>
<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;
border-radius: 2px; border-radius: 2px;
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;
width: $avatar-width !important; width: $avatar-width !important;
height: $avatar-width; height: $avatar-width;
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,
width: 100%; .el-input {
} 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