From 924a173d6b1f1f218ad36319fa15d75c80e66107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 17 Sep 2022 21:54:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=82=B9=E5=87=BB=E7=A1=AE=E5=AE=9A=E4=BC=9A?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E8=B0=83=E7=94=A8=E4=B8=A4=E6=AC=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ChartDataAjax/index.vue | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue index 6b13d9eb..82be64ef 100644 --- a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataAjax/index.vue @@ -96,6 +96,7 @@ import { SelectHttpType } from '../../index.d' import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow' import { useTargetData } from '../../../hooks/useTargetData.hook' import { isDev, newFunctionHandle } from '@/utils' +import debounce from 'lodash/debounce' const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5 const { targetData, chartEditStore } = useTargetData() @@ -123,23 +124,27 @@ const requestModelHandle = () => { } // 发送请求 -const sendHandle = async () => { - if(!targetData.value?.request) return - loading.value = true - try { - const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig)) - loading.value = false - if (res && res.data) { - targetData.value.option.dataset = newFunctionHandle(res.data, targetData.value.filter) - showMatching.value = true - return +const sendHandle = debounce( + async () => { + if (!targetData.value?.request) return + loading.value = true + try { + const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig)) + loading.value = false + if (res && res.data) { + targetData.value.option.dataset = newFunctionHandle(res.data, targetData.value.filter) + showMatching.value = true + return + } + window['$message'].warning('数据异常,请检查参数!') + } catch (error) { + loading.value = false + window['$message'].warning('数据异常,请检查参数!') } - window['$message'].warning('数据异常,请检查参数!') - } catch (error) { - loading.value = false - window['$message'].warning('数据异常,请检查参数!') - } -} + }, + 2000, + { leading: true } +) // 颜色 const themeColor = computed(() => { @@ -152,7 +157,7 @@ watchEffect(() => { lastFilter = filter sendHandle() } - firstFocus ++ + firstFocus++ }) onBeforeUnmount(() => {