From 7210f85a17fabb2518a9cc9ec825ed572c2b9aab Mon Sep 17 00:00:00 2001 From: xuyiming Date: Thu, 29 Oct 2020 15:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=96=87=E6=A1=A3fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/doc-width-nav.vue | 91 ++++++++++--------- .../technical-support/doc-manage/list.vue | 2 + 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/src/components/doc-width-nav.vue b/src/components/doc-width-nav.vue index a60ab7d..0a3f055 100644 --- a/src/components/doc-width-nav.vue +++ b/src/components/doc-width-nav.vue @@ -65,57 +65,60 @@ export default { }, methods: { translate() { - let content = this.richText; - let titles = - content.match( - /||/g - ) || []; - let time = new Date().getTime(); - let pre_h1_index = 0; - let pre_h2_index = 0; - let pre_h3_index = 0; - let newTitles = titles - .map((title, index) => { - let newTitle = title; - let level = 0; - let id = ""; + let content = this.richText || ""; - if (title.match(//g)) { - pre_h1_index++; - pre_h2_index = 0; - pre_h3_index = 0; - level = 1; - id = `nav_${pre_h1_index}` + "_" + time; + if (content) { + let titles = + content.match( + /||/g + ) || []; + let time = new Date().getTime(); + let pre_h1_index = 0; + let pre_h2_index = 0; + let pre_h3_index = 0; + let newTitles = titles + .map((title, index) => { + let newTitle = title; + let level = 0; + let id = ""; - newTitle = title.replace(/

/g)) { - pre_h2_index++; - pre_h3_index = 0; - level = 2; - id = `nav_${pre_h1_index}_${pre_h2_index}` + "_" + time; + if (title.match(//g)) { + pre_h1_index++; + pre_h2_index = 0; + pre_h3_index = 0; + level = 1; + id = `nav_${pre_h1_index}` + "_" + time; - newTitle = title.replace(/

/g)) { - pre_h3_index++; - level = 3; - id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}`; + newTitle = title.replace(/

/g)) { + pre_h2_index++; + pre_h3_index = 0; + level = 2; + id = `nav_${pre_h1_index}_${pre_h2_index}` + "_" + time; - newTitle = title.replace(/

/g)) { + pre_h3_index++; + level = 3; + id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}`; - content = content.replace(new RegExp(title), newTitle); + newTitle = title.replace(/

/g, ""), - }; - }) - .filter((item) => item.title); + content = content.replace(new RegExp(title), newTitle); - this.content = content; - this.navTree = newTitles; - this.curNav = (newTitles[0] && newTitles[0].id) || ""; + return { + level, + id, + title: title.replace(/<\/?.+?>/g, ""), + }; + }) + .filter((item) => item.title); + + this.content = content; + this.navTree = newTitles; + this.curNav = (newTitles[0] && newTitles[0].id) || ""; + } }, clickNav(item) { let target = document.querySelector(`#${item.id}`); diff --git a/src/pages/technical-support/doc-manage/list.vue b/src/pages/technical-support/doc-manage/list.vue index cf99770..78c25f4 100644 --- a/src/pages/technical-support/doc-manage/list.vue +++ b/src/pages/technical-support/doc-manage/list.vue @@ -272,6 +272,7 @@ export default { this.$http .get("/apaas/support/document/list", { params: { + search: fullFilter.name, style: fullFilter.type, start: fullFilter.time && fullFilter.time[0], end: fullFilter.time && fullFilter.time[1], @@ -350,6 +351,7 @@ export default { style: 0, title: "", }; + this.$refs.addForm && this.$refs.addForm.clearValidate(); this.$refs.addDialog.show(); }, AddCancelAction() { -- 2.26.0