feat: 优化实体列表搜索框的删除按钮显示与隐藏
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="advanced-search"
|
class="advanced-search"
|
||||||
|
@mouseenter="showCloseIcon = true"
|
||||||
|
@mouseleave="showCloseIcon = false"
|
||||||
>
|
>
|
||||||
<text-mode
|
<text-mode
|
||||||
v-if="searchMode === 'text'"
|
v-if="searchMode === 'text'"
|
||||||
@@ -10,6 +12,7 @@
|
|||||||
:show-list="showList"
|
:show-list="showList"
|
||||||
@changeMode="changeMode"
|
@changeMode="changeMode"
|
||||||
@search="search"
|
@search="search"
|
||||||
|
:show-close-icon="showCloseIcon"
|
||||||
></text-mode>
|
></text-mode>
|
||||||
<tag-mode
|
<tag-mode
|
||||||
v-if="searchMode === 'tag'"
|
v-if="searchMode === 'tag'"
|
||||||
@@ -41,7 +44,8 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
str: null,
|
str: null,
|
||||||
metaList: null
|
metaList: null,
|
||||||
|
showCloseIcon: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
:content="$t('entity.switchToAdvancedSearch')"
|
:content="$t('entity.switchToAdvancedSearch')"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<i class="cn-icon cn-icon-filter" @click="changeMode"></i>
|
<i class="cn-icon cn-icon-filter margin-r-12" @click="changeMode"></i>
|
||||||
</template>
|
</template>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div class="search__suffix-close" @click="cleanParams">
|
<div v-show="isCloseIcon" class="search__suffix-close" @click="cleanParams">
|
||||||
<i class="el-icon-error"></i>
|
<i class="el-icon-error"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="search__suffix" :class="showList ? 'new-search__suffix' : 'entity-explorer-search'" @click="search">
|
<div class="search__suffix" :class="showList ? 'new-search__suffix' : 'entity-explorer-search'" @click="search">
|
||||||
@@ -43,11 +43,14 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
columnList: Array,
|
columnList: Array,
|
||||||
str: String,
|
str: String,
|
||||||
showList: Boolean
|
showList: Boolean,
|
||||||
|
showCloseIcon: Boolean
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
codeMirror: null
|
codeMirror: null,
|
||||||
|
isCloseIcon: this.showCloseIcon,
|
||||||
|
isEdit: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['changeMode', 'search'],
|
emits: ['changeMode', 'search'],
|
||||||
@@ -69,6 +72,24 @@ export default {
|
|||||||
this.codeMirror.setOption('extraKeys', {
|
this.codeMirror.setOption('extraKeys', {
|
||||||
Enter: (cm) => {}
|
Enter: (cm) => {}
|
||||||
})
|
})
|
||||||
|
const str = this.codeMirror.getValue().trim()
|
||||||
|
this.codeMirror.on('focus', () => {
|
||||||
|
if (str !== '') {
|
||||||
|
this.isEdit = true
|
||||||
|
this.isCloseIcon = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.codeMirror.on('blur', () => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
this.isEdit = false
|
||||||
|
this.isCloseIcon = false
|
||||||
|
clearTimeout(timer)
|
||||||
|
}, 200)
|
||||||
|
})
|
||||||
|
this.codeMirror.on('update', () => {
|
||||||
|
this.isEdit = true
|
||||||
|
this.isCloseIcon = true
|
||||||
|
})
|
||||||
},
|
},
|
||||||
search () {
|
search () {
|
||||||
const str = this.codeMirror.getValue().trim()
|
const str = this.codeMirror.getValue().trim()
|
||||||
@@ -180,6 +201,14 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
showCloseIcon (n) {
|
||||||
|
if (!this.isEdit) {
|
||||||
|
const str = this.codeMirror.getValue().trim()
|
||||||
|
if (str !== '') {
|
||||||
|
this.isCloseIcon = n
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@@ -197,6 +226,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
toRaw(this.codeMirror).setValue(q)
|
toRaw(this.codeMirror).setValue(q)
|
||||||
|
} else {
|
||||||
|
this.isCloseIcon = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const vm = this
|
const vm = this
|
||||||
@@ -209,10 +240,14 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.search__suffix-close {
|
.search__suffix-close {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
margin-top: -9px;
|
||||||
|
|
||||||
.el-icon-error {
|
.el-icon-error {
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
color: #C4C4C4;
|
color: #C4C4C4;
|
||||||
margin: 0 12px;
|
margin-right: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,4 +270,7 @@ export default {
|
|||||||
color: #3976CB;
|
color: #3976CB;
|
||||||
margin-top: -2px;
|
margin-top: -2px;
|
||||||
}
|
}
|
||||||
|
.margin-r-12 {
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user