This commit is contained in:
zhaofang
2022-09-27 20:24:23 +08:00
parent 021f02ece5
commit 88c2061094
7 changed files with 490 additions and 39 deletions

View File

@@ -20,8 +20,9 @@
</div>
</div>
<!-- 我的笔记 -->
<div class="mycote-content" v-if="notetab == 2">
<div v-if="noteList.length > 0">
<div v-if="notetab == 2">
<div class="mycote-content" v-show="!isEdit">
<div v-if="noteList.length > 0">
<div style="border-bottom:1px solid #4444;padding-bottom:25px;" v-for="note in noteList"
:key="note.id">
<span class="mycote-time">{{note.sysCreateTime}}
@@ -53,23 +54,45 @@
</div>
</div>
<h6 class="mycote-dibu">已经到底啦</h6>
</div>
<div class="my-nonote" v-else>
<img src="../../../public/images/no-note.png" alt="" />
<h6 style="color: #666666;font-size: 14px;">你还没有记录此课程的笔记哦</h6>
</div>
</div>
<div class="my-nonote" v-else>
<img src="../../../public/images/no-note.png" alt="" />
<h6 style="color: #666666;font-size: 14px;">你还没有记录此课程的笔记哦</h6>
<div v-show="isEdit">
<p style="margin-top:37px">
<span style="font-size: 14px;color: #333333;margin-left:10px;">{{mynoteData.sysCreateTime}}</span>
<span class="sm">{{mynoteData.openType == 1?'公开':'私密'}}</span>
<svg-icon style="float:right;font-size:26px;margin-top:16px" icon-class="spot"></svg-icon>
</p>
<div class="newcote-content" style="margin-top:10px;height:436px">
<div class="newcote-time" v-if="mynoteData.playTime != 0">
<img src="../../../public/images/coteplay.png" />
{{formatSeconds(mynoteData.playTime)}}
<img src="../../../public/images/cotedetel.png" @click="timeDel()" />
</div>
<div class="newcote-text">
<el-input type="textarea" :autofocus="true" placeholder="好记性不如烂笔头,记录些什么吧~"
v-model="mynoteData.content" maxlength="200" :autosize="{ minRows: 18, maxRows: 20}"
show-word-limit>
</el-input>
</div>
</div>
</div>
</div>
<div class="newcote-bottom" v-if="notetab == 1">
<div class="newcote-bottom" v-if="notetab == 1 || isEdit">
<span style="cursor: pointer;" @click="videoLocation"> <img src="../../../public/images/playtime.png"
alt=""> 视频位置</span>
<el-radio v-model="mynoteData.openType" :label="9">公开</el-radio>
<el-radio v-model="mynoteData.openType" :label="1">私密</el-radio>
<el-button size="small" v-show="isEdit" @click="isEdit = false">取消</el-button>
<el-button type="primary" size="small" @click="saveNote()">保存</el-button>
</div>
</div>
<div class="animation-box" :class="inAnimation?'animation':''" @animationend="inAnimation=false">
<div class="box-text">
<img src="../../../public/images/success-note.png" />笔记保存成功U币+2
<img src="../../../public/images/success-note.png" />{{inAnimationText}}
</div>
</div>
</div>
@@ -93,6 +116,8 @@ export default {
name: 'MyNote',
data() {
return {
inAnimationText:'笔记保存成功U币+2',
isEdit:false,
courseId:'',
inAnimation: false,
radio: '1',
@@ -161,8 +186,10 @@ export default {
}, 10000);
},
noteEdit(note) {
console.log(note,'note');
this.isEdit = true;
this.mynoteData = note;
this.notetabType(1);
// this.notetabType(1);
},
noteDel(note) {
this.$confirm('您确定要删除这条笔记吗?', '删除提示', {
@@ -205,10 +232,31 @@ export default {
return;
}
this.mynoteData.courseId = this.courseId;
console.log(this.mynoteData,'this.mynoteData');
apiNote.save(this.mynoteData).then(res => {
if(this.isEdit) {
apiNote.update(this.mynoteData).then(res=>{
if(res.status == 200) {
this.inAnimationText = '笔记编辑成功';
this.inAnimation = true;
this.isEdit = false;
setTimeout(() => {
this.getMyNote();
this.mynoteData = {
type: 1, //我发布的是1 我导入的是2
content: '',
playTime: '',
courseId: '',// 课程id
contentId: '',//课程内容id
courseName: '',// 课程名称
openType: 1,// 1表不公开 9表完全公开
};
}, 2000)
}
})
} else {
apiNote.save(this.mynoteData).then(res => {
if (res.status == 200) {
if (!this.mynoteData.id) {
this.inAnimationText = '笔记保存成功U币+2';
this.inAnimation = true;
if(this.mynoteData.openType != 9){
return
@@ -245,6 +293,9 @@ export default {
}, 2000)
}
})
}
console.log(this.mynoteData,'this.mynoteData');
}
},
beforeDestroy() {
@@ -341,7 +392,17 @@ export default {
padding: 0;
}
}
.sm {
width: 50px;
height: 22px;
border-radius: 10px;
border: 1px solid #3379FB;
color: #3379FB;
font-size: 12px;
line-height: 50px;
margin-left: 20px;
padding: 3px 10px;
}
.newcote-content {
margin: 30px 0px;
box-sizing: border-box;
@@ -373,17 +434,7 @@ export default {
font-size: 14px;
padding-bottom: 20px;
.sm {
width: 50px;
height: 22px;
border-radius: 10px;
border: 1px solid #3379FB;
color: #3379FB;
font-size: 12px;
line-height: 50px;
margin-left: 20px;
padding: 3px 10px;
}
.more {
margin-top: 12px;

View File

@@ -0,0 +1,255 @@
<template>
<div class="upload-file">
<!-- <el-upload
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:multiple="limit>1"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="showList"
:data="data"
:headers="headers"
class="upload-file-uploader"
ref="upload"
>
<el-button :icon="loading ? 'el-icon-upload2':''" :size="size" type="primary" :loading="isLoading">{{text}}</el-button>
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
的文件
</div>
</el-upload> -->
<el-upload
class="upload-demo"
drag
:multiple="limit>1"
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:on-success="handleUploadSuccess"
:show-file-list="showList"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-remove="handleUploadRemove"
:data="data"
:headers="headers"
:limit="limit">
<svg-icon style="font-size:52px;margin-right:5px;margin-top:20px" icon-class="up-char"></svg-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">支持拓展名支持扩展名.txt/.dox/.docx/.png/.jpg, 图片支持批量上传最多9张</div>
</el-upload>
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
<el-link :href="file.url" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
</div>
</li>
</transition-group>
</div>
</template>
<script>
import { getToken } from "@/utils/token";
export default {
props: {
// 值
value: [String, Object, Array],
showList: {
type: Boolean,
default: false
},
url:{
type: String,
default: '/xboe/sys/xuploader/file/upload'
},
limit:{
type:Number,
default:1
},
dir:{
type:String,
default:'files'
},
text:{
type:String,
default:'选择文件并上传'
},
size:{
type:String,
default:'small'
},
// 大小限制(MB)
fileSize: {
type: Number,
default: 1024,
},
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["doc", "xls", "ppt","docx", "xlsx", "pptx","png","txt", "pdf","jpg","gif","bmp","mp4","mp3"],
},
// 是否显示提示
isShowTip: {
type: Boolean,
default: true
},
loading: {
type: Boolean,
default: false
},
},
data() {
return {
uploadFileUrl: process.env.VUE_APP_BASE_API + this.url, // 上传的图片服务器地址
headers: {
'XBOE-Access-Token': getToken(),
},
isLoading:false,
fileList: [],
data:{
dir:this.dir
}
};
},
computed: {
// 是否显示提示
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
// 列表
list() {
let temp = 1;
if (this.value) {
// 首先将值转为数组
const list = Array.isArray(this.value) ? this.value : [this.value];
// 然后将数组转为对象数组
return list.map((item) => {
if (typeof item === "string") {
item = { name: item, url: item };
}
item.uid = item.uid || new Date().getTime() + temp++;
return item;
});
} else {
this.fileList = [];
return [];
}
},
},
methods: {
handleUploadRemove(file) {
console.log(file,'file');
this.$emit("remove",file);
},
// 上传前校检格式和大小
handleBeforeUpload(file) {
// 校检文件类型
if (this.fileType) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
const isTypeOk = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
if (!isTypeOk) {
//this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
this.$message({message:`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`,type:'error',offset:100})
//this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
return false;
}
}
// 校检文件大小
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$message({message:`上传文件大小不能超过 ${this.fileSize} MB!`,type:'error',offset:100})
//this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
if(this.loading) {
this.isLoading = true;
}
return true;
},
// 文件个数超出
handleExceed(res) {
this.$message({message:`只允许上传单个文件`,type:'error',offset:100});
},
// 上传失败
handleUploadError(err) {
this.isLoading = false;
this.$message({message:"上传失败, 请重试",type:'error',offset:100});
},
// 上传成功回调
handleUploadSuccess(res, file) {
if(res.status == 200) {
this.fileList = [];
this.isLoading = false;
this.$message({message:"上传成功",type:'success',offset:100});
} else {
this.isLoading = false;
this.fileList = [];
this.$message({message:"上传失败",type:'error',offset:100});
}
this.$emit("success", res);
},
// 删除文件
handleDelete(index) {
this.fileList.splice(index, 1);
this.$emit("remove", '');
},
// 获取文件名称
getFileName(name) {
if (name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
} else {
return "";
}
}
},
created() {
this.fileList = this.list;
},
};
</script>
<style scoped lang="scss">
.el-upload__tip{
margin-top: 10px;
text-align: center;
}
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
border: 1px solid #e4e7ed;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}
</style>