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(() => {