From f26b4a73b1fec2f5cd07b7a3b646309989a1df2f Mon Sep 17 00:00:00 2001
From: wangjinpeng <17600579508@163.com>
Date: Tue, 13 Aug 2024 19:42:24 +0800
Subject: [PATCH] table filter code optimize
---
src/components/base/DictSelect.vue | 2 +-
src/components/base/MInput/index.vue | 4 +-
src/components/base/MenuSelect/index.vue | 19 ++--
src/components/base/MenuTree/index.vue | 4 +-
src/components/base/TreeSelect.vue | 2 +-
src/components/common/Badge.vue | 13 +--
src/components/function/FilterSetting.vue | 106 +++++++++++-----------
7 files changed, 78 insertions(+), 72 deletions(-)
diff --git a/src/components/base/DictSelect.vue b/src/components/base/DictSelect.vue
index 1736d1b..8e6fe0d 100644
--- a/src/components/base/DictSelect.vue
+++ b/src/components/base/DictSelect.vue
@@ -202,5 +202,5 @@ async function loadDictItems(
+ :options="showOptions" @click="addSelectedDictValue" />
diff --git a/src/components/base/MInput/index.vue b/src/components/base/MInput/index.vue
index 07ee7d1..11bdd8f 100644
--- a/src/components/base/MInput/index.vue
+++ b/src/components/base/MInput/index.vue
@@ -77,7 +77,7 @@ defineExpose({
@@ -87,7 +87,7 @@ defineExpose({
class="min-h-20 flex flex-wrap iw-dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow">
diff --git a/src/components/base/MenuSelect/index.vue b/src/components/base/MenuSelect/index.vue
index b7531a8..4fd3251 100644
--- a/src/components/base/MenuSelect/index.vue
+++ b/src/components/base/MenuSelect/index.vue
@@ -1,5 +1,5 @@
-
+
+
+
+
{{ dictItem.title }} void
}>()
+const emits = defineEmits(['click'])
const treeRef: Ref
= ref(null)
-const dictContainerCompRef = ref>(
+const menuSelectRef = ref>(
{} as InstanceType
)
const selectOptions = ref([])
@@ -50,21 +53,21 @@ watch(
function handleShow(
- ...args: Parameters
+ ...args: Parameters
) {
- return dictContainerCompRef.value?.show(...args)
+ return menuSelectRef.value?.show(...args)
}
function handleClose(
- ...args: Parameters
+ ...args: Parameters
) {
- return dictContainerCompRef.value?.close(...args)
+ return menuSelectRef.value?.close(...args)
}
function handleClick(e: Event) {
if (!(e.target instanceof HTMLElement)) {
return
}
- props.setFilterADictValue(e)
+ emits('click', e)
}
defineExpose({
diff --git a/src/components/base/MenuTree/index.vue b/src/components/base/MenuTree/index.vue
index b6e5163..f353dd7 100644
--- a/src/components/base/MenuTree/index.vue
+++ b/src/components/base/MenuTree/index.vue
@@ -51,8 +51,8 @@ import {
const props = defineProps<{
options: any[] | undefined
values: any
- setFilterADictValue: (e: Event) => void
}>()
+const emits = defineEmits(['click'])
const treeRef: Ref = ref(null)
const dictTreeContainerCompRef = ref>(
{} as InstanceType
@@ -93,7 +93,7 @@ function handleClick(e: Event) {
if (arrowEle) {
return
}
- props.setFilterADictValue(e)
+ emits('click', e)
}
defineExpose({
diff --git a/src/components/base/TreeSelect.vue b/src/components/base/TreeSelect.vue
index 3b384e8..1c9e1ab 100644
--- a/src/components/base/TreeSelect.vue
+++ b/src/components/base/TreeSelect.vue
@@ -202,5 +202,5 @@ async function loadDictItems(
+ :options="showOptions" @click="addSelectedDictValue" />
diff --git a/src/components/common/Badge.vue b/src/components/common/Badge.vue
index 4ee1c6a..ceebdc7 100644
--- a/src/components/common/Badge.vue
+++ b/src/components/common/Badge.vue
@@ -2,18 +2,19 @@
import * as iconSvg from '../../assets/icon'
defineProps<{
- dictItemOrRawValue: any,
+ option: any,
+ readonly?: boolean
}>()
const emits = defineEmits<{
(e: 'delete'): void
}>()
-
-
-
+
+
+
-
{{ dictItemOrRawValue.title ?? dictItemOrRawValue }}
-
+
{{ option.title ?? option }}
+
\ No newline at end of file
diff --git a/src/components/function/FilterSetting.vue b/src/components/function/FilterSetting.vue
index 51d1057..09c158c 100644
--- a/src/components/function/FilterSetting.vue
+++ b/src/components/function/FilterSetting.vue
@@ -1,5 +1,5 @@