|
@@ -17,19 +17,19 @@
|
|
</div>
|
|
</div>
|
|
<div class="document-options-form">
|
|
<div class="document-options-form">
|
|
<el-form :model="addDocForm" ref="addDocForm" :rules="addDocRules">
|
|
<el-form :model="addDocForm" ref="addDocForm" :rules="addDocRules">
|
|
- <el-form-item label="文章标题" prop="title">
|
|
|
|
- <el-input v-model="addDocForm.title" placeholder="请输入文章标题"></el-input>
|
|
|
|
|
|
+ <el-form-item label="文章标题" prop="Title">
|
|
|
|
+ <el-input v-model="addDocForm.Title" placeholder="请输入文章标题"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="所属分类" prop="classify">
|
|
|
|
|
|
+ <el-form-item label="所属分类" prop="ClassifyId">
|
|
<el-cascader style="width: 100%;"
|
|
<el-cascader style="width: 100%;"
|
|
- v-model="addDocForm.classify" :options="classifyList"
|
|
|
|
- :props="{value:'id',label:'text',children:'child'}" placeholder="所属分类"/>
|
|
|
|
|
|
+ v-model="addDocForm.ClassifyId" :options="classifyList"
|
|
|
|
+ :props="{value:'ClassifyId',label:'ClassifyName',children:'Children',emitPath:false}" placeholder="所属分类"/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="文章作者" prop="author">
|
|
|
|
- <el-input v-model="addDocForm.author" placeholder="请输入文章作者"></el-input>
|
|
|
|
|
|
+ <el-form-item label="文章作者" prop="Author">
|
|
|
|
+ <el-input v-model="addDocForm.Author" placeholder="请输入文章作者"></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="相关推荐">
|
|
<el-form-item label="相关推荐">
|
|
- <div v-for="(item,index) in addDocForm.recommendedLink" :key="index" class="form-item-recommendedLink">
|
|
|
|
|
|
+ <div v-for="(item,index) in recommendedLink" :key="index" class="form-item-recommendedLink">
|
|
<el-input v-model="item.linkName" placeholder="请输入链接名称" style="width: 190px;"></el-input>
|
|
<el-input v-model="item.linkName" placeholder="请输入链接名称" style="width: 190px;"></el-input>
|
|
<div class="recommendedLink-line"></div>
|
|
<div class="recommendedLink-line"></div>
|
|
<el-input v-model="item.linkUrl" placeholder="请输入链接" style="width: 190px;"></el-input>
|
|
<el-input v-model="item.linkUrl" placeholder="请输入链接" style="width: 190px;"></el-input>
|
|
@@ -42,17 +42,11 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import {assistanceDocInterence} from "@/api/api.js"
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name:"assistanceDocAdd",
|
|
name:"assistanceDocAdd",
|
|
data() {
|
|
data() {
|
|
- this.classifyList=[
|
|
|
|
- {id:1,text:"分类介绍",child:[{id:11,text:"分类介绍1",child:[{id:111,text:"分类介绍11",child:null}]}]},
|
|
|
|
- {id:2,text:"ETA使用",child:[{id:22,text:"ETA使用1",child:[{id:222,text:"ETA使用11",child:null}]}]},
|
|
|
|
- {id:3,text:"ETA移动",child:[{id:33,text:"ETA移动1",child:[{id:333,text:"ETA移动11",child:null}]}]},
|
|
|
|
- {id:4,text:"指标成图",child:[{id:44,text:"指标成图1",child:[{id:444,text:"指标成图11",child:null}]}]},
|
|
|
|
- {id:5,text:"图表分析",child:[{id:55,text:"图表分析1",child:[{id:555,text:"图表分析11",child:null}]}]}
|
|
|
|
- ]
|
|
|
|
const that = this;
|
|
const that = this;
|
|
return {
|
|
return {
|
|
editor: null,
|
|
editor: null,
|
|
@@ -133,35 +127,59 @@
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ classifyList:[],
|
|
addDocForm:{
|
|
addDocForm:{
|
|
- title:"",
|
|
|
|
- classify:"",
|
|
|
|
- author:"",
|
|
|
|
- recommendedLink:[{linkName:"",linkUrl:""},{linkName:"",linkUrl:""}],
|
|
|
|
- Content:''
|
|
|
|
|
|
+ Title:"",
|
|
|
|
+ ClassifyId:"",
|
|
|
|
+ Author:"",
|
|
|
|
+ Status:1,
|
|
|
|
+ Content:'',
|
|
|
|
+ AnchorData:[]
|
|
},
|
|
},
|
|
|
|
+ recommendedLink:[{linkName:"",linkUrl:""},{linkName:"",linkUrl:""}],
|
|
addDocRules:{
|
|
addDocRules:{
|
|
- title:{required:true,message:'文章标题不能为空',trigger:'blur'},
|
|
|
|
- classify:{required:true,message:'文章所属分类不能为空',trigger:'change'},
|
|
|
|
- author:{required:true,message:'文章作者不能为空',trigger:'blur'}
|
|
|
|
|
|
+ Title:{required:true,message:'文章标题不能为空',trigger:'blur'},
|
|
|
|
+ ClassifyId:{required:true,message:'文章所属分类不能为空',trigger:'change'},
|
|
|
|
+ Author:{required:true,message:'文章作者不能为空',trigger:'blur'}
|
|
},
|
|
},
|
|
anchorData:[]
|
|
anchorData:[]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
- if(this.$route.query.id){
|
|
|
|
|
|
+ this.getclassifyData()
|
|
|
|
+ if(this.$route.query.DocId){
|
|
//TODO: 详情接口
|
|
//TODO: 详情接口
|
|
console.log("详情接口");
|
|
console.log("详情接口");
|
|
|
|
+ assistanceDocInterence.getAssistanceDoc({DocId:this.$route.query.DocId}).then(res=>{
|
|
|
|
+ if(res.Ret == 200){
|
|
|
|
+ this.addDocForm={
|
|
|
|
+ Title:res.Data.Title,
|
|
|
|
+ ClassifyId:res.Data.ClassifyId,
|
|
|
|
+ Author:res.Data.Author,
|
|
|
|
+ Status:res.Data.Status,
|
|
|
|
+ Content:res.Data.Content,
|
|
|
|
+ }
|
|
|
|
+ // this.addDocForm.AnchorData:res.Data.Anchor,
|
|
|
|
+ // this.recommendedLink=[{linkName:"",linkUrl:""},{linkName:"",linkUrl:""}],
|
|
|
|
+
|
|
|
|
+ console.log(res);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ getclassifyData(){
|
|
|
|
+ assistanceDocInterence.getAssistanceClassifyList().then(res=>{
|
|
|
|
+ if(res.Ret == 200){
|
|
|
|
+ this.classifyList = res.Data?res.Data.AllNodes||[]:[]
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 生成锚点
|
|
// 生成锚点
|
|
generateAnchor(){
|
|
generateAnchor(){
|
|
// 搜索富文本中的h1和h2标签 当做一级和二级的锚点
|
|
// 搜索富文本中的h1和h2标签 当做一级和二级的锚点
|
|
this.searchTitleTag(0,1)
|
|
this.searchTitleTag(0,1)
|
|
// console.log(this.addDocForm.Content,this.anchorData);
|
|
// console.log(this.addDocForm.Content,this.anchorData);
|
|
- // window.anchorData = this.anchorData
|
|
|
|
- console.log(this.anchorData);
|
|
|
|
},
|
|
},
|
|
// 搜索标题标签h1,h2
|
|
// 搜索标题标签h1,h2
|
|
searchTitleTag(searchPosition,firstLevel){
|
|
searchTitleTag(searchPosition,firstLevel){
|
|
@@ -183,7 +201,6 @@
|
|
let secondLevel=1
|
|
let secondLevel=1
|
|
while (!(H2Posiiton==-1 || H2Posiiton>nextH1Posiiton)) {
|
|
while (!(H2Posiiton==-1 || H2Posiiton>nextH1Posiiton)) {
|
|
// 找到了,并且位置小于下一个h1的位置
|
|
// 找到了,并且位置小于下一个h1的位置
|
|
- console.log(H2Posiiton,nextH1Posiiton);
|
|
|
|
let anchorTextH2=`id="doc_anchor_${firstLevel}_${secondLevel}"`
|
|
let anchorTextH2=`id="doc_anchor_${firstLevel}_${secondLevel}"`
|
|
// console.log(H2Posiiton,secondLevel,'secondLevel');
|
|
// console.log(H2Posiiton,secondLevel,'secondLevel');
|
|
this.addDocForm.Content = this.addDocForm.Content.substring(0, H2Posiiton+3)
|
|
this.addDocForm.Content = this.addDocForm.Content.substring(0, H2Posiiton+3)
|
|
@@ -208,7 +225,7 @@
|
|
// 生成底部的两个链接
|
|
// 生成底部的两个链接
|
|
createBottomHref(){
|
|
createBottomHref(){
|
|
let hrefStringBuiler='<ul style="margin-top:40px">'
|
|
let hrefStringBuiler='<ul style="margin-top:40px">'
|
|
- this.addDocForm.recommendedLink.map(item =>{
|
|
|
|
|
|
+ this.recommendedLink.map(item =>{
|
|
if(item.linkName){
|
|
if(item.linkName){
|
|
hrefStringBuiler+=`<li><a href="${item.linkUrl}" target="_blank" style="text-decoration: underline;">${item.linkName}</a></li>`
|
|
hrefStringBuiler+=`<li><a href="${item.linkUrl}" target="_blank" style="text-decoration: underline;">${item.linkName}</a></li>`
|
|
}
|
|
}
|
|
@@ -216,9 +233,9 @@
|
|
return hrefStringBuiler+"</ul>"
|
|
return hrefStringBuiler+"</ul>"
|
|
},
|
|
},
|
|
previewDocument(){
|
|
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>`
|
|
|
|
|
|
+ // 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>`
|
|
// 生成锚点
|
|
// 生成锚点
|
|
- this.generateAnchor()
|
|
|
|
|
|
+ // this.generateAnchor()
|
|
let bottomLink = this.createBottomHref()
|
|
let bottomLink = this.createBottomHref()
|
|
|
|
|
|
sessionStorage.setItem("documentDoc",this.addDocForm.Content+bottomLink)
|
|
sessionStorage.setItem("documentDoc",this.addDocForm.Content+bottomLink)
|
|
@@ -226,17 +243,34 @@
|
|
window.open(href, "_blank");
|
|
window.open(href, "_blank");
|
|
},
|
|
},
|
|
saveDocument(type){
|
|
saveDocument(type){
|
|
|
|
+ // 生成锚点
|
|
|
|
+ console.log(this.addDocForm);
|
|
this.$refs.addDocForm.validate(valid=>{
|
|
this.$refs.addDocForm.validate(valid=>{
|
|
if(valid){
|
|
if(valid){
|
|
- console.log(this.addDocForm);
|
|
|
|
//TODO: 保存文章和发布文章
|
|
//TODO: 保存文章和发布文章
|
|
- if(type=="发布"){
|
|
|
|
- // 发布
|
|
|
|
- }
|
|
|
|
- if(this.addDocForm.id){
|
|
|
|
|
|
+ if(type=="发布") this.addDocForm.Status=2
|
|
|
|
+
|
|
|
|
+ this.generateAnchor()
|
|
|
|
+ let bottomLink = this.createBottomHref()
|
|
|
|
+ this.addDocForm.Content=this.addDocForm.Content+bottomLink
|
|
|
|
+ this.addDocForm.AnchorData = this.anchorData
|
|
|
|
+ console.log(this.addDocForm);
|
|
|
|
+ if(this.addDocForm.Id){
|
|
//编辑
|
|
//编辑
|
|
}else{
|
|
}else{
|
|
//新增
|
|
//新增
|
|
|
|
+ assistanceDocInterence.addAssistanceDoc(this.addDocForm).then(res=>{
|
|
|
|
+ if(res.Ret == 200){
|
|
|
|
+ this.$message({
|
|
|
|
+ type:'success',
|
|
|
|
+ message:'新增成功',
|
|
|
|
+ duration:2000
|
|
|
|
+ })
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
+ this.$router.back()
|
|
|
|
+ },2000)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
// this.$message({
|
|
// this.$message({
|
|
// type:'success',
|
|
// type:'success',
|