订单统计筛选
This commit is contained in:
parent
f75fcab291
commit
9f92b4da87
@ -26,8 +26,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ProTable ref="tableRef" :request-api="orderPageGet" :columns="columns" :pagination="true"
|
||||
:tool-button="true" @search="fetchStats" @reset="fetchStats">
|
||||
<ProTable ref="tableRef" :request-api="wrappedOrderPageGet" :columns="columns" :pagination="true"
|
||||
:tool-button="true">
|
||||
<template #tools>
|
||||
<el-button v-auth="'order:export'" type="primary" :loading="exportLoading" @click="handleExport">
|
||||
<template #icon>
|
||||
@ -105,7 +105,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { Download } from '@element-plus/icons-vue';
|
||||
import ProTable from '/@/components/ProTable/index.vue';
|
||||
@ -152,24 +152,31 @@ const animateNumber = (key, targetValue) => {
|
||||
};
|
||||
|
||||
// 获取统计数据
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
statsLoading.value = true;
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
const searchParams = tableRef.value?.searchParam || {};
|
||||
const { succeeded, data } = await orderStatsGet(searchParams);
|
||||
if (succeeded && data) {
|
||||
statsData.value = data;
|
||||
animateNumber('totalOriginalAmount', data.totalOriginalAmount);
|
||||
animateNumber('totalDiscountAmount', data.totalDiscountAmount);
|
||||
animateNumber('totalActualAmount', data.totalActualAmount);
|
||||
animateNumber('totalRefundAmount', data.totalRefundAmount);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取统计数据失败:', error);
|
||||
} finally {
|
||||
statsLoading.value = false;
|
||||
}
|
||||
const fetchStats = async (searchParams) => {
|
||||
try {
|
||||
statsLoading.value = true;
|
||||
const params = searchParams || tableRef.value?.searchParam || {};
|
||||
const { succeeded, data } = await orderStatsGet(params);
|
||||
if (succeeded && data) {
|
||||
statsData.value = data;
|
||||
animateNumber('totalOriginalAmount', data.totalOriginalAmount);
|
||||
animateNumber('totalDiscountAmount', data.totalDiscountAmount);
|
||||
animateNumber('totalActualAmount', data.totalActualAmount);
|
||||
animateNumber('totalRefundAmount', data.totalRefundAmount);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取统计数据失败:', error);
|
||||
} finally {
|
||||
statsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 包装 orderPageGet,在数据加载完成后调用 fetchStats
|
||||
const wrappedOrderPageGet = async (params) => {
|
||||
const result = await orderPageGet(params);
|
||||
// 等待结果返回后调用 fetchStats
|
||||
fetchStats(params);
|
||||
return result;
|
||||
};
|
||||
|
||||
const formData = ref({
|
||||
@ -330,9 +337,7 @@ const handleExport = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchStats();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user