Commit 9d1348a9 authored by 赵伟庚's avatar 赵伟庚

up 开发文档上传附件

parent b12223bb
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
</div> </div>
</div> </div>
<div class="part nav_part"> <div class="part nav_part">
<h3 class="part_title"> <h5 class="part_title">
<span>导航</span> <span>导航</span>
</h3> </h5>
<ul class="part_content nav_content apaas_scroll"> <ul class="part_content nav_content apaas_scroll">
<li <li
v-for="(item, index) in navTree" v-for="(item, index) in navTree"
...@@ -213,7 +213,7 @@ export default { ...@@ -213,7 +213,7 @@ export default {
.file { .file {
font-weight: normal; font-weight: normal;
font-size: 14px; font-size: 14px;
margin-left: 62px; margin-left: 152px;
cursor: pointer; cursor: pointer;
color: #515fe7; color: #515fe7;
} }
......
<template> <template>
<section class="wangeditor_class"> <section class="wangeditor_class">
<div ref="toolbar" class="toolbar"></div> <div ref="toolbar" class="toolbar"></div>
<div>
<el-upload
class="upload-file"
action="/apaas/static/image/upload"
:on-success="uploadSuccess"
:on-remove="handleRemove"
:data="{directory: 'file' }"
:limit="5"
:file-list="fileArray">
<el-button ref="upload_file" id="upload_file" size="small" type="primary" v-show="false">点击上传</el-button>
</el-upload>
</div>
</section> </section>
</template> </template>
<script> <script>
import E from "wangeditor"; import E from "wangeditor";
const { BtnMenu } = E
//编辑器自定义按钮
class uploadMenu extends BtnMenu {
constructor(editor) {
const $elem = E.$(
`<div class="w-e-menu" data-title="文档上传">
<i class="el-icon-upload2"></i>
</div>`
)
super($elem, editor)
}
clickHandler() {
wangEuploadFile();
}
tryChangeActive() {
this.active()
}
}
export default { export default {
name: "editoritem", name: "editoritem",
data() { data() {
return { return {
// uploadPath, // uploadPath,
uploadMenu,
editor: null, editor: null,
info_: null info_: null,
}; };
}, },
model: { model: {
...@@ -31,6 +64,10 @@ export default { ...@@ -31,6 +64,10 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
fileArray: {
type: Array,
default: () => []
}
}, },
watch: { watch: {
isClear(val) { isClear(val) {
...@@ -59,6 +96,7 @@ export default { ...@@ -59,6 +96,7 @@ export default {
mounted() { mounted() {
this.seteditor(); this.seteditor();
this.editor.txt.html(this.value); this.editor.txt.html(this.value);
window.wangEuploadFile = this.wangEuploadFile
}, },
methods: { methods: {
seteditor() { seteditor() {
...@@ -109,9 +147,45 @@ export default { ...@@ -109,9 +147,45 @@ export default {
this.info_ = html; // 绑定当前逐渐地值 this.info_ = html; // 绑定当前逐渐地值
this.$emit("change", this.info_); // 将内容同步到父组件中 this.$emit("change", this.info_); // 将内容同步到父组件中
}; };
this.editor.menus.extend('uploadMenusKey',uploadMenu)
this.editor.config.menus.push('uploadMenusKey')
// 创建富文本编辑器 // 创建富文本编辑器
this.editor.create(); this.editor.create();
} },
wangEuploadFile() {
// this.$refs.upload_file.handleClick();
document.getElementById('upload_file').click();
},
uploadSuccess(response, file, fileList) {
if (response.success == 1) {
this.fileArray.push({
url: response.data,
name: file.name,
});
this.$emit("getNewList", this.fileArray);
}
},
handleRemove(file, fileList) {
let url = file.url;
let detection = true;
if (url) detection = url.indexOf("blob") != -1;
if (detection) {
this.fileArray.forEach((item, i, arr) => {
if (item.url === file.url) {
this.fileArray.splice(i, 1);
}
});
} else {
this.fileArray.forEach((item, i, arr) => {
if (item.url === file.url) {
this.fileArray.splice(i, 1);
}
});
}
this.$emit("getNewList", this.fileArray);
},
} }
}; };
</script> </script>
...@@ -142,4 +216,7 @@ export default { ...@@ -142,4 +216,7 @@ export default {
border: none!important; border: none!important;
height: calc(100% - 80px)!important; height: calc(100% - 80px)!important;
} }
.upload-file {
width: 50%;
}
</style> </style>
...@@ -14,18 +14,8 @@ ...@@ -14,18 +14,8 @@
</div> </div>
<div class="editpage"> <div class="editpage">
<wang-e v-model="content"></wang-e> <wang-e v-model="content" @getNewList="getNewList" :fileArray="fileArray"></wang-e>
<div class="up_load_box"> <div class="apaas_button pt_max">
<el-upload
action="/apaas/static/image/upload"
:on-success="getNewListOne"
:on-remove="handleRemove"
:data="anotherData"
:file-list="doc_file">
<el-button size="small" class="upload_ben">点击上传附件</el-button>
</el-upload>
</div>
<div class="apaas_button">
<el-button type="defalut" size="mini" @click="cancelAction"> <el-button type="defalut" size="mini" @click="cancelAction">
取消 取消
</el-button> </el-button>
...@@ -48,10 +38,8 @@ export default { ...@@ -48,10 +38,8 @@ export default {
return { return {
title: "", title: "",
content: "", content: "",
doc_file: [], fileList: [],
anotherData: { fileArray: []
directory: "file",
}
}; };
}, },
computed: { computed: {
...@@ -75,7 +63,7 @@ export default { ...@@ -75,7 +63,7 @@ export default {
if (data.data.doc_file && data.data.doc_file != "") { if (data.data.doc_file && data.data.doc_file != "") {
arr = data.data.doc_file.split(",") arr = data.data.doc_file.split(",")
arr.forEach(e => { arr.forEach(e => {
this.doc_file.push({ this.fileArray.push({
name: helper.downloadFileFormatNew(e), name: helper.downloadFileFormatNew(e),
url: e url: e
}) })
...@@ -91,8 +79,8 @@ export default { ...@@ -91,8 +79,8 @@ export default {
}, },
submitAction() { submitAction() {
let arr = []; let arr = [];
if (this.doc_file && this.doc_file.length > 0 ) { if (this.fileList && this.fileList.length > 0 ) {
this.doc_file.forEach(e => { this.fileList.forEach(e => {
arr.push(e.url) arr.push(e.url)
}) })
} }
...@@ -116,31 +104,17 @@ export default { ...@@ -116,31 +104,17 @@ export default {
this.$message.error("保存失败"); this.$message.error("保存失败");
}); });
}, },
getNewListOne(res,file) { getNewList(fileList) {
if (res.success == 1) { this.fileList = fileList;
this.doc_file.push(
{
name: file.name,
url: res.data
}
)
}
}, },
handleRemove(file) {
this.doc_file.forEach((item, i) => {
if (item.url === file.url) {
this.doc_file.splice(i, 1);
}
});
}
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.doc_manage_container { .doc_manage_container {
/* height: 100%; */ height: 100%;
padding: 0 20px 20px; padding: 0 20px 30px;
box-sizing: border-box; box-sizing: border-box;
} }
.main_container { .main_container {
...@@ -150,13 +124,13 @@ export default { ...@@ -150,13 +124,13 @@ export default {
} }
.editpage { .editpage {
background-color: #fff; background-color: #fff;
/* height: calc(100% - 45px); */ height: calc(100% - 45px);
/* margin-bottom: 20px; */ margin-bottom: 20px;
box-shadow: 0px 3px 6px 0px #f4f7fc; box-shadow: 0px 3px 6px 0px #f4f7fc;
border-radius: 12px; border-radius: 12px;
} }
.editpage .wangeditor_class { .editpage .wangeditor_class {
height: calc(100vh - 300px); height: calc(100% - 100px);
padding: 0 20px; padding: 0 20px;
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -164,17 +138,15 @@ export default { ...@@ -164,17 +138,15 @@ export default {
border-top: 1px solid #e3e5ef; border-top: 1px solid #e3e5ef;
box-sizing: border-box; box-sizing: border-box;
text-align: right; text-align: right;
padding: 30px 0; padding-top: 30px;
} }
.apaas_button .el-button + .el-button { .apaas_button .el-button + .el-button {
margin-right: 30px; margin-right: 30px;
} }
.up_load_box { .editpage /deep/ .wangeditor_class {
padding: 20px 60% 20px 20px; height: calc(100% - 200px);
} }
.upload_ben { .pt_max {
background-color: #0f2683; padding-top: 130px;
border-color: #0f2683;
color: #fff;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment