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 @@
-
+
diff --git a/src/views/energyManagement/components/EnergyHistoryTable/EnergyHistoryTable.vue b/src/views/energyManagement/components/EnergyHistoryTable/EnergyHistoryTable.vue
index cf9eee1..26427d3 100644
--- a/src/views/energyManagement/components/EnergyHistoryTable/EnergyHistoryTable.vue
+++ b/src/views/energyManagement/components/EnergyHistoryTable/EnergyHistoryTable.vue
@@ -9,9 +9,13 @@ const tableData = ref([]);
const deptData = ref([]);
const elecType = ref([]);
const subSystem = ref(null);
+const loading = ref(false);
const updateTableData = (data) => {
tableData.value = data ? data : [];
};
+const setLoading = (val) => {
+ loading.value = !!val;
+};
provide("energy_table_data", {
tableData,
@@ -19,6 +23,8 @@ provide("energy_table_data", {
deptData,
elecType,
subSystem,
+ loading,
+ setLoading,
});
diff --git a/src/views/setting/components/VendorModal.vue b/src/views/setting/components/VendorModal.vue
index 4f33097..a41be03 100644
--- a/src/views/setting/components/VendorModal.vue
+++ b/src/views/setting/components/VendorModal.vue
@@ -38,6 +38,7 @@ const onCancel = () => {
const onOk = async () => {
const value = await handleSubmit(deptScheme, props.formState);
+ let res;
if (props.formState?.id) {
res = await updateOperationCompany(value);
} else {