|
@@ -11,9 +11,9 @@
|
|
|
</div>
|
|
|
<div class="edit-container-document-options">
|
|
|
<div class="document-options-button-box">
|
|
|
- <el-button type="primary" class="document-options-button" @click="previewDocument">预览</el-button>
|
|
|
- <el-button type="primary" class="document-options-button" @click="saveDocument('保存')">保存</el-button>
|
|
|
- <el-button type="primary" class="document-options-button" @click="saveDocument('发布')">发布</el-button>
|
|
|
+ <el-button type="primary" class="document-options-button" @click="previewDocument" v-loading="isSubmiting">预览</el-button>
|
|
|
+ <el-button type="primary" class="document-options-button" @click="saveDocument('保存')" v-loading="isSubmiting">保存</el-button>
|
|
|
+ <el-button type="primary" class="document-options-button" @click="saveDocument('发布')" v-loading="isSubmiting">发布</el-button>
|
|
|
</div>
|
|
|
<div class="document-options-form">
|
|
|
<el-form :model="addDocForm" ref="addDocForm" :rules="addDocRules">
|
|
@@ -142,7 +142,8 @@ import {createBottomHref} from "./utils/common"
|
|
|
ClassifyId:{required:true,message:'文章所属分类不能为空',trigger:'change'},
|
|
|
Author:{required:true,message:'文章作者不能为空',trigger:'blur'}
|
|
|
},
|
|
|
- anchorData:[]
|
|
|
+ anchorData:[],
|
|
|
+ isSubmiting:false,
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -188,8 +189,8 @@ import {createBottomHref} from "./utils/common"
|
|
|
frontH1Posiiton = this.addDocForm.Content.indexOf('<h1',searchPosition)
|
|
|
// 右闭合标签
|
|
|
frontH1RightPosiiton = this.addDocForm.Content.indexOf('>',frontH1Posiiton)
|
|
|
- // 对应的</h1>的位置
|
|
|
- backH1Posiiton = this.addDocForm.Content.indexOf('</h1>',frontH1Posiiton)
|
|
|
+ // 对应的</h1>的位置 原本用的</h1>,后来发现> 和 </h1>之间会掺其他标签
|
|
|
+ backH1Posiiton = this.addDocForm.Content.indexOf('<',frontH1RightPosiiton)
|
|
|
|
|
|
if(frontH1Posiiton == -1) return
|
|
|
|
|
@@ -215,8 +216,8 @@ import {createBottomHref} from "./utils/common"
|
|
|
while (!(H2Posiiton==-1 || H2Posiiton>nextH1Posiiton)) {
|
|
|
// 右闭合标签
|
|
|
H2RightPosiiton = this.addDocForm.Content.indexOf('>',H2Posiiton)
|
|
|
- // 对应的</h1>的位置
|
|
|
- backH2Posiiton = this.addDocForm.Content.indexOf('</h2>',H2Posiiton)
|
|
|
+ // 对应的</h2>的位置 原本用的</h2>,后来发现> 和 </h2>之间会掺其他标签
|
|
|
+ backH2Posiiton = this.addDocForm.Content.indexOf('<',H2RightPosiiton)
|
|
|
// 找到了,并且位置小于下一个h1的位置
|
|
|
let anchorTextH2=`id="doc_anchor_${firstLevel}_${secondLevel}"`
|
|
|
// console.log(H2Posiiton,secondLevel,'secondLevel');
|
|
@@ -247,7 +248,8 @@ import {createBottomHref} from "./utils/common"
|
|
|
},
|
|
|
previewDocument(){
|
|
|
// this.addDocForm.Content=`<p>范德萨发的刚发的</p><p>刚发的g梵蒂冈</p><p>割发代首刚发的</p><hr><h1>1. 个刚发的施工方</h1><p>刚发的刚发的g规范的施工方都是割发代首规范</p><h2>1.1. 规范的三个富士达割发代首</h2><p>个梵蒂冈是梵蒂冈讽德诵功范德萨割发代首个割发代首</p><p>刚分手的割发代首割发代首高富帅d</p><p>刚分手的刚分手的</p><p>割发代首刚分手的</p><p>刚分手的公司发的</p><p>刚发的事故发生的</p><p><br></p><p>割发代首刚分手的刚分手的</p><h2>1.2. 噶规范十多个范德萨刚发的施工方多少公分</h2><p>个讽德诵功范德萨</p><p>割发代首割发代首刚发的s规范的三个</p><h1>2.讽德诵功是反的</h1><p>割发代首割发代首个人的施工方都是</p><p>范德萨个人东方闪电方式</p><p>割发代首割发代首</p><h2>2.1.个梵蒂冈</h2><p>讽德诵功范德萨规范的三个范德萨讽德诵功放大s</p><h2>2.2.刚发的广泛地个</h2><p>刚分手的割发代首</p><p>割发代首割发代首割发代首</p><p><br></p><p>范德萨割发代首</p><h2>2.3.辅导费是的</h2><p>范甘迪个放大割发代首个</p><p>刚发的刚发的</p><h1>3. 个梵蒂冈放大</h1>`
|
|
|
-
|
|
|
+ if(this.isSubmiting) return
|
|
|
+
|
|
|
let bottomLink = createBottomHref(this.addDocForm.RecommendData)
|
|
|
|
|
|
sessionStorage.setItem("documentDoc",this.addDocForm.Content+bottomLink)
|
|
@@ -255,13 +257,18 @@ import {createBottomHref} from "./utils/common"
|
|
|
window.open(href, "_blank");
|
|
|
},
|
|
|
saveDocument(type){
|
|
|
- // 生成锚点
|
|
|
+ if(this.isSubmiting) return
|
|
|
this.$refs.addDocForm.validate(valid=>{
|
|
|
if(valid){
|
|
|
+ if(!this.addDocForm.Content){
|
|
|
+ this.$message.error("文章内容不能为空")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // console.log(this.addDocForm);
|
|
|
+ this.isSubmiting=true
|
|
|
if(type=="发布") this.addDocForm.Status=2
|
|
|
|
|
|
this.generateAnchor()
|
|
|
- this.addDocForm.Content=this.addDocForm.Content
|
|
|
this.addDocForm.AnchorData = this.anchorData
|
|
|
//保存
|
|
|
assistanceDocInterence.addAssistanceDoc(this.addDocForm).then(res=>{
|
|
@@ -273,8 +280,11 @@ import {createBottomHref} from "./utils/common"
|
|
|
})
|
|
|
setTimeout(()=>{
|
|
|
this.$router.back()
|
|
|
+ this.isSubmiting=false
|
|
|
},2000)
|
|
|
}
|
|
|
+ }).catch(()=>{
|
|
|
+ this.isSubmiting=false
|
|
|
})
|
|
|
}
|
|
|
})
|