mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +08:00
enhance ui text for SearchSourceTipText
This commit is contained in:
@@ -70,25 +70,7 @@
|
|||||||
<div v-if="element.type === 'search'">
|
<div v-if="element.type === 'search'">
|
||||||
<div flex flex-items-center>
|
<div flex flex-items-center>
|
||||||
<span color-orange align-self-end mr10px>
|
<span color-orange align-self-end mr10px>
|
||||||
<template v-if="!element?.children?.length">
|
{{ getSearchSourceTipText(element) }}
|
||||||
添加一个关键词后方可启用->
|
|
||||||
</template>
|
|
||||||
<template
|
|
||||||
v-else-if="
|
|
||||||
element.enabled &&
|
|
||||||
element?.children?.every((it) => !(it.enabled && !!it.keyword?.trim()))
|
|
||||||
"
|
|
||||||
>
|
|
||||||
启用下方任一非空项后方可启用
|
|
||||||
</template>
|
|
||||||
<template
|
|
||||||
v-else-if="
|
|
||||||
element.enabled &&
|
|
||||||
element?.children?.some((it) => it.enabled && !it.keyword?.trim())
|
|
||||||
"
|
|
||||||
>
|
|
||||||
空项会被跳过
|
|
||||||
</template>
|
|
||||||
</span>
|
</span>
|
||||||
<el-button
|
<el-button
|
||||||
p-0
|
p-0
|
||||||
@@ -148,7 +130,7 @@
|
|||||||
() => {
|
() => {
|
||||||
if (!searchItem.keyword?.trim()) {
|
if (!searchItem.keyword?.trim()) {
|
||||||
Message.info({
|
Message.info({
|
||||||
message: '关键词为空,请输入要搜索的关键词',
|
message: '该条关键词为空,请输入要搜索的关键词',
|
||||||
grouping: true
|
grouping: true
|
||||||
})
|
})
|
||||||
} else if (!element.enabled) {
|
} else if (!element.enabled) {
|
||||||
@@ -190,7 +172,7 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
import { ElMessage as Message } from 'element-plus'
|
import { ElMessage as Message } from 'element-plus'
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array
|
type: Array
|
||||||
}
|
}
|
||||||
@@ -223,6 +205,42 @@ function addSearchKeyword(item) {
|
|||||||
function removeSearchKeywordByIndex(item, index) {
|
function removeSearchKeywordByIndex(item, index) {
|
||||||
item.children?.splice(index, 1)
|
item.children?.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
const searchKeywordCountMap = computed(() => {
|
||||||
|
const target = props.modelValue?.find((it) => it.type === 'search' && it.enabled)
|
||||||
|
if (!target || !target?.children?.length) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
const map = {}
|
||||||
|
target.children?.forEach((it) => {
|
||||||
|
if (!it.keyword) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!map[it.keyword]) {
|
||||||
|
map[it.keyword] = 0
|
||||||
|
}
|
||||||
|
map[it.keyword]++
|
||||||
|
})
|
||||||
|
|
||||||
|
return map
|
||||||
|
})
|
||||||
|
|
||||||
|
const getSearchSourceTipText = (element) => {
|
||||||
|
if (!element?.children?.length) {
|
||||||
|
return `添加一个关键词后方可启用->`
|
||||||
|
}
|
||||||
|
const seg: string[] = []
|
||||||
|
if (element.enabled) {
|
||||||
|
if (element.children?.every((it) => !(it.enabled && !!it.keyword?.trim()))) {
|
||||||
|
seg.push(`启用下方任一非空项后方可启用`)
|
||||||
|
} else if (element.children?.some((it) => it.enabled && !it.keyword?.trim())) {
|
||||||
|
seg.push(`空项会被跳过`)
|
||||||
|
}
|
||||||
|
if (Object.values(searchKeywordCountMap.value).some((n) => n > 1)) {
|
||||||
|
seg.push(`重复项仅取第一个启用的项`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return seg.join(';')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user