From 0670e596abd199dc489aa2cf18e6687fe0e66418 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Wed, 19 Nov 2025 14:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E6=BA=90=E7=AE=A1=E7=90=86=20:=20?= =?UTF-8?q?=E6=AD=B7=E5=8F=B2table=20=E6=96=B0=E5=A2=9E=20loading=20?= =?UTF-8?q?=E7=8B=80=E6=85=8B=E7=AE=A1=E7=90=86=20|=20=E8=B2=A0=E8=B2=AC?= =?UTF-8?q?=E5=BB=A0=E5=95=86:=20=E6=8F=90=E4=BA=A4bug=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EnergyHistoryTable/EnergyActionButton.vue | 69 +++++++++++-------- .../EnergyHistoryTable/EnergyDataTable.vue | 6 +- .../EnergyHistoryTable/EnergyHistoryTable.vue | 6 ++ src/views/setting/components/VendorModal.vue | 1 + 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/views/energyManagement/components/EnergyHistoryTable/EnergyActionButton.vue b/src/views/energyManagement/components/EnergyHistoryTable/EnergyActionButton.vue index eff1440..57e91bd 100644 --- a/src/views/energyManagement/components/EnergyHistoryTable/EnergyActionButton.vue +++ b/src/views/energyManagement/components/EnergyHistoryTable/EnergyActionButton.vue @@ -12,7 +12,7 @@ const props = defineProps({ form: Object, }); -const { updateTableData } = inject("energy_table_data"); +const { updateTableData, loading, setLoading } = inject("energy_table_data"); let isToastOpen = ref({ open: false, @@ -30,6 +30,9 @@ const submit = async (e, type = "") => { e?.preventDefault(); e?.stopPropagation(); + // 若正在 loading 則直接阻止再次觸發 + if (loading.value) return; + const formData = new FormData(props.form); let params = {}; @@ -38,39 +41,45 @@ const submit = async (e, type = "") => { params = { ...params, [pair[0]]: pair[1] }; } - if (type === "export") { - const res = await getHistoryExportData({ - ...params, - ...searchParams.value, - Type: - route.params.type != 1 - ? 2 - : searchParams.value.Type - ? searchParams.value.Type - : 1, - table_type: route.params.type, - }).catch((err) => { - isToastOpen.value = { - open: true, - content: err.msg, - }; - }); - } else { - const res = await getHistoryData({ - ...searchParams.value, - Type: - route.params.type != 1 - ? 2 - : searchParams.value.Type - ? searchParams.value.Type - : 1, - table_type: route.params.type, - }); - updateTableData(res.data); + try { + setLoading(true); + if (type === "export") { + await getHistoryExportData({ + ...params, + ...searchParams.value, + Type: + route.params.type != 1 + ? 2 + : searchParams.value.Type + ? searchParams.value.Type + : 1, + table_type: route.params.type, + }).catch((err) => { + isToastOpen.value = { + open: true, + content: err.msg, + }; + }); + } else { + const res = await getHistoryData({ + ...searchParams.value, + Type: + route.params.type != 1 + ? 2 + : searchParams.value.Type + ? searchParams.value.Type + : 1, + table_type: route.params.type, + }); + updateTableData(res.data); + } + } finally { + setLoading(false); } }; const isSearchButtonDisabled = computed(() => { + if (loading.value) return true; if ( !searchParams.value.Points?.length || !searchParams.value.Device_list?.length diff --git a/src/views/energyManagement/components/EnergyHistoryTable/EnergyDataTable.vue b/src/views/energyManagement/components/EnergyHistoryTable/EnergyDataTable.vue index ec0aa70..bfd6ace 100644 --- a/src/views/energyManagement/components/EnergyHistoryTable/EnergyDataTable.vue +++ b/src/views/energyManagement/components/EnergyHistoryTable/EnergyDataTable.vue @@ -1,13 +1,13 @@