From 032db927a117a4d581b3e97dd1f25b9715cfa46f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 19 Mar 2026 19:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96RightToolbar=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A0=8F=E5=88=87=E6=8D=A2=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RightToolbar/index.vue | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue index 68eb0f0..0a1592d 100644 --- a/src/components/RightToolbar/index.vue +++ b/src/components/RightToolbar/index.vue @@ -94,8 +94,35 @@ const isIndeterminate = computed(() => Array.isArray(props.columns) ? props.colu const transferData = computed(() => Array.isArray(props.columns) ? props.columns.map((item, index) => ({ key: index, label: item.label })) : Object.keys(props.columns).map((key, index) => ({ key: index, label: props.columns[key].label }))) // 搜索 +const { proxy } = getCurrentInstance() function toggleSearch() { - emits("update:showSearch", !props.showSearch) + let el = proxy.$el + let formEl = null + while ((el = el.parentElement) && el !== document.body) { + if ((formEl = el.querySelector('.el-form'))) break + } + if (!formEl) return emits('update:showSearch', !props.showSearch) + animateSearch(formEl, props.showSearch) +} +function animateSearch(el, isHide) { + const DURATION = 260 + const TRANSITION = 'max-height 0.25s ease, opacity 0.2s ease' + const clear = () => Object.assign(el.style, { transition: '', maxHeight: '', opacity: '', overflow: '' }) + Object.assign(el.style, { overflow: 'hidden', transition: '' }) + if (isHide) { + Object.assign(el.style, { maxHeight: el.scrollHeight + 'px', opacity: '1', transition: TRANSITION }) + requestAnimationFrame(() => Object.assign(el.style, { maxHeight: '0', opacity: '0' })) + setTimeout(() => { emits('update:showSearch', false); clear() }, DURATION) + } else { + emits('update:showSearch', true) + nextTick(() => { + Object.assign(el.style, { maxHeight: '0', opacity: '0' }) + requestAnimationFrame(() => requestAnimationFrame(() => { + Object.assign(el.style, { transition: TRANSITION, maxHeight: el.scrollHeight + 'px', opacity: '1' }) + })) + setTimeout(clear, DURATION) + }) + } } // 刷新