Commit 602c616d authored by 赵伟庚's avatar 赵伟庚

up 开发文档上传附件

parent 1fda35ef
...@@ -12,7 +12,17 @@ ...@@ -12,7 +12,17 @@
ref="docContent" ref="docContent"
> >
</div> </div>
<div>附件:脚接交接军军军军军军军</div> <div v-if="doc_type">
<h3 class="doc_title">附件:
<span v-if="fileList && fileList.length !== 0">
<span v-for="(e,idx) in fileList" :key="idx" class="file" :class="'file'+idx">
<span @click="download(e)">{{helper.downloadFileFormatNew(e)}}</span>
<br>
</span>
</span>
<span class="noFile" v-else>暂无</span>
</h3>
</div>
</div> </div>
</div> </div>
<div class="part nav_part"> <div class="part nav_part">
...@@ -37,6 +47,8 @@ ...@@ -37,6 +47,8 @@
</template> </template>
<script> <script>
import helper from "@/services/helper"
export default { export default {
props: { props: {
richText: { richText: {
...@@ -51,21 +63,35 @@ export default { ...@@ -51,21 +63,35 @@ export default {
type: String, type: String,
defalut: "", defalut: "",
}, },
doc_type: {
type: Boolean,
default: false
},
doc_file: {
type: String,
defalut: "",
}
}, },
data() { data() {
return { return {
helper: helper,
content: "", content: "",
navTree: [], navTree: [],
curNav: "", curNav: "",
fileList: [],
}; };
}, },
watch: { watch: {
richText() { richText() {
this.translate(); this.translate();
}, },
doc_file() {
this.getFile()
}
}, },
mounted() { mounted() {
this.translate(); this.translate();
this.getFile()
}, },
methods: { methods: {
translate() { translate() {
...@@ -124,6 +150,17 @@ export default { ...@@ -124,6 +150,17 @@ export default {
this.curNav = (newTitles[0] && newTitles[0].id) || ""; this.curNav = (newTitles[0] && newTitles[0].id) || "";
} }
}, },
getFile() {
if (this.doc_file != "") {
this.fileList = this.doc_file.split(",")
}
},
download(e) {
const a = document.createElement("a"); // 创建a标签
a.setAttribute("download", ""); // download属性
a.setAttribute("href", e); // href链接
a.click(); // 自执行点击事件
}, // 下载附件
clickNav(item) { clickNav(item) {
let target = document.querySelector(`#${item.id}`); let target = document.querySelector(`#${item.id}`);
...@@ -168,6 +205,25 @@ export default { ...@@ -168,6 +205,25 @@ export default {
.doc_part { .doc_part {
flex-grow: 1; flex-grow: 1;
} }
.doc_title {
font-weight: 700;
padding-left: 32px;
margin-top: 60px;
}
.file {
font-weight: normal;
font-size: 14px;
margin-left: 62px;
cursor: pointer;
color: #515fe7;
}
.file0 {
margin-left: 0;
}
.noFile {
font-weight: normal;
font-size: 14px;
}
.nav_part { .nav_part {
width: 270px; width: 270px;
flex-shrink: 0; flex-shrink: 0;
......
...@@ -15,6 +15,16 @@ ...@@ -15,6 +15,16 @@
<div class="editpage"> <div class="editpage">
<wang-e v-model="content"></wang-e> <wang-e v-model="content"></wang-e>
<div class="up_load_box">
<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"> <div class="apaas_button">
<el-button type="defalut" size="mini" @click="cancelAction"> <el-button type="defalut" size="mini" @click="cancelAction">
取消 取消
...@@ -29,6 +39,7 @@ ...@@ -29,6 +39,7 @@
<script> <script>
import wangE from "@/components/wangE"; import wangE from "@/components/wangE";
import helper from "@/services/helper.js";
export default { export default {
components: { components: {
wangE, wangE,
...@@ -37,6 +48,10 @@ export default { ...@@ -37,6 +48,10 @@ export default {
return { return {
title: "", title: "",
content: "", content: "",
doc_file: [],
anotherData: {
directory: "file",
}
}; };
}, },
computed: { computed: {
...@@ -56,6 +71,16 @@ export default { ...@@ -56,6 +71,16 @@ export default {
if (data.success === 1) { if (data.success === 1) {
this.title = data.data.title; this.title = data.data.title;
this.content = data.data.content; this.content = data.data.content;
let arr = [];
if (data.data.doc_file && data.data.doc_file != "") {
arr = data.data.doc_file.split(",")
arr.forEach(e => {
this.doc_file.push({
name: helper.downloadFileFormatNew(e),
url: e
})
})
}
} }
}); });
} }
...@@ -65,10 +90,18 @@ export default { ...@@ -65,10 +90,18 @@ export default {
this.$router.push("/technical_support/doc_manage"); this.$router.push("/technical_support/doc_manage");
}, },
submitAction() { submitAction() {
let arr = [];
if (this.doc_file && this.doc_file.length > 0 ) {
this.doc_file.forEach(e => {
arr.push(e.url)
})
}
let doc_file = arr.join(",") || ""
this.$http this.$http
.put("/apaas/support/document/put", { .put("/apaas/support/document/put", {
id: this.id, id: this.id,
content: this.content, content: this.content,
doc_file: doc_file,
}) })
.then(({ data }) => { .then(({ data }) => {
if (data.success === 1) { if (data.success === 1) {
...@@ -83,14 +116,31 @@ export default { ...@@ -83,14 +116,31 @@ export default {
this.$message.error("保存失败"); this.$message.error("保存失败");
}); });
}, },
getNewListOne(res,file) {
if (res.success == 1) {
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 30px; padding: 0 20px 20px;
box-sizing: border-box; box-sizing: border-box;
} }
.main_container { .main_container {
...@@ -100,13 +150,13 @@ export default { ...@@ -100,13 +150,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(100% - 100px); height: calc(100vh - 300px);
padding: 0 20px; padding: 0 20px;
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -114,9 +164,17 @@ export default { ...@@ -114,9 +164,17 @@ 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-top: 30px; padding: 30px 0;
} }
.apaas_button .el-button + .el-button { .apaas_button .el-button + .el-button {
margin-right: 30px; margin-right: 30px;
} }
.up_load_box {
padding: 20px 60% 20px 20px;
}
.upload_ben {
background-color: #0f2683;
border-color: #0f2683;
color: #fff;
}
</style> </style>
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
:title="title" :title="title"
:time="update_time" :time="update_time"
:rich-text="content" :rich-text="content"
:doc_type="true"
:doc_file="doc_file"
></doc-width-nav> ></doc-width-nav>
</div> </div>
</template> </template>
...@@ -42,6 +44,7 @@ export default { ...@@ -42,6 +44,7 @@ export default {
title: "", title: "",
update_time: "", update_time: "",
content: "", content: "",
doc_file: ""
}; };
}, },
computed: { computed: {
...@@ -85,6 +88,7 @@ export default { ...@@ -85,6 +88,7 @@ export default {
if (data.data.content) { if (data.data.content) {
this.content = data.data.content; this.content = data.data.content;
} }
this.doc_file = data.data.doc_file || ""
} }
}); });
}, },
......
...@@ -35,6 +35,25 @@ module.exports.dateFormat = function (fmt, timestamp) { ...@@ -35,6 +35,25 @@ module.exports.dateFormat = function (fmt, timestamp) {
return fmt; return fmt;
} }
module.exports.downloadFileFormatNew = function (fileUrl) {
/*
input: /apaas/static/docs/image/images/1234_qq234ewr123.png
output: 1234.png
*/
if (fileUrl != "") {
var temp = fileUrl.split('/')[fileUrl.split('/').length - 1]
var name = temp.split('_')[0]
var type = temp.split('_')[temp.split('_').length - 1].split('.')[1]
if (temp.indexOf('_') == -1) {
return name
} else {
return name + '.' + type
}
} else {
return "";
}
}
module.exports.dateStringTransform = function (date) { module.exports.dateStringTransform = function (date) {
/* /*
input: 2020-06-12T16:38:11+08:00 input: 2020-06-12T16:38:11+08:00
......
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