diff --git a/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue b/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue index 28d485e6a..9f5457e9f 100644 --- a/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue +++ b/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue @@ -1,24 +1,29 @@ @@ -60,13 +95,28 @@ export default { } } }, - searchDetailObj: { + selectValue: { type: Object } }, + computed: { + }, data () { return { - detailSearchListCopy: {} + detailSearchListCopy: {}, + searchStr: '' + } + }, + methods: { + searchStrChange (val, key) { + this.detailSearchListCopy[key].searchStr = val + this.detailSearchListCopy[key].children = this.detailSearchListCopy[key].oldChildren.filter(children => children.name.indexOf(val) !== -1) + }, + getSearchStr (oldChildren, label) { + const arr = label.split('-') + const obj = oldChildren.find(item => item.id == arr[0]) + const children = obj.children.find(item => item.id == arr[1]) + return children.name } }, watch: { @@ -74,14 +124,17 @@ export default { immediate: true, deep: true, handler (n) { - console.log(n) this.detailSearchListCopy = JSON.parse(JSON.stringify(n)) + Object.keys(this.detailSearchListCopy).forEach(key => { + this.detailSearchListCopy[key].searchStr = '' + this.detailSearchListCopy[key].oldChildren = JSON.parse(JSON.stringify(this.detailSearchListCopy[key].children)) + }) + console.log(this.detailSearchListCopy) } }, - searchDetailObj: { + selectValue: { deep: true, handler (n) { - console.log(n, 123123123) this.$emit('reload', n) } } @@ -90,7 +143,15 @@ export default {