From dea53eb473e1cf0494b52baddfab5639df91625b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 15 Oct 2021 18:03:08 +0800 Subject: [PATCH] fix issue about edit topics --- web_src/js/components/EditTopics.vue | 57 +++++++++++++++++----------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/web_src/js/components/EditTopics.vue b/web_src/js/components/EditTopics.vue index 5aa5e6e7a..8a69d1d3b 100644 --- a/web_src/js/components/EditTopics.vue +++ b/web_src/js/components/EditTopics.vue @@ -148,29 +148,37 @@ export default { params:this.params }).then((res)=>{ this.array = res.data.topics - + this.array.forEach((element,index) => { + + if (this.arrayTopics.indexOf(element.topic_name)>-1){ - this.showInitTopic.push(true) - - }else{ + } + else{ this.showInitTopic.push(false) } + this.showInputValue = true + }); + let findelement = this.array.some((item)=>{ + + return item.topic_name===this.input + }) + this.showInputValue = !findelement - }); }) - this.showInputValue = true + this.showSearchTopic = true } this.showAddTopic = false + }, @@ -249,7 +257,7 @@ export default { this.Post(data,topics) if(this.arrayTopics.length===0){ - console.log("add postTopic") + $('#repo-topics1').append('暂无标签') }else{ $('#repo-topics1').children('span').remove() @@ -282,7 +290,9 @@ export default { this.input = '' if (this.input === ''){ + this.array = this.arrayTopics + let data = [] this.showInitTopic = [] this.array.forEach((element,index) => { @@ -301,6 +311,7 @@ export default { this.showInputValue = false this.showSearchTopic = true + this.showAddTopic = false } stopPropagation(e); @@ -332,30 +343,30 @@ computed:{ }, watch: { - input(newValue){ + // input(newValue){ - if (newValue === ''){ - this.array = this.arrayTopics - let data = [] - this.showInitTopic = [] - this.array.forEach((element,index) => { + // if (newValue === ''){ + // this.array = this.arrayTopics + // let data = [] + // this.showInitTopic = [] + // this.array.forEach((element,index) => { - let item = {} - item.topic_name = element + // let item = {} + // item.topic_name = element - data.push(item) - this.showInitTopic.push(true) + // data.push(item) + // this.showInitTopic.push(true) - }); + // }); - this.array = data + // this.array = data - this.showInputValue = false - this.showSearchTopic = true - } - } + // this.showInputValue = false + // this.showSearchTopic = true + // } + // } }, mounted() { const context = this