修复:百色中学排行榜统计金额和仪表盘的统计数不一致的问题
This commit is contained in:
@@ -6,26 +6,43 @@
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
<a-tooltip title="获得捐款总金额" class="flex px-4">
|
||||
<span class="text-gray-400">捐款总金额:</span>
|
||||
<span class="text-gray-700 font-bold">¥{{ formatNumber(totalPriceAmount) }}</span>
|
||||
<a-tooltip title="实际订单总金额(来自订单表)" class="flex px-4">
|
||||
<span class="text-gray-400">实际订单总金额:</span>
|
||||
<span class="text-gray-700 font-bold">¥{{ formatNumber(bszxTotalPrice) }}</span>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip title="排行榜统计金额(来自排行榜表)" class="flex px-4 ml-4">
|
||||
<span class="text-gray-400">排行榜统计金额:</span>
|
||||
<span class="text-gray-700 font-bold">¥{{ formatNumber(rankingTotalPrice) }}</span>
|
||||
</a-tooltip>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useSearch from "@/utils/use-search";
|
||||
import { watch,ref } from 'vue';
|
||||
import { watch, ref, computed } from 'vue';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import {BszxPayRankingParam} from "@/api/bszx/bszxPayRanking/model";
|
||||
import { BszxPayRankingParam } from "@/api/bszx/bszxPayRanking/model";
|
||||
import { useBszxStatisticsStore } from '@/store/modules/bszx-statistics';
|
||||
|
||||
// 使用百色中学统计数据 store
|
||||
const bszxStatisticsStore = useBszxStatisticsStore();
|
||||
|
||||
// 从 store 中获取总金额
|
||||
const bszxTotalPrice = computed(() => bszxStatisticsStore.bszxTotalPrice);
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
// 保留这个属性以保持向后兼容,但不再使用
|
||||
totalPriceAmount?: number;
|
||||
// 排行榜统计金额
|
||||
rankingTotalPrice?: number;
|
||||
}>(),
|
||||
{}
|
||||
{
|
||||
rankingTotalPrice: 0
|
||||
}
|
||||
);
|
||||
|
||||
// 日期范围选择
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
:totalPriceAmount="totalPriceAmount.toFixed(2)"
|
||||
:rankingTotalPrice="rankingTotalPrice"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
@@ -53,7 +53,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {createVNode, ref} from 'vue';
|
||||
import {createVNode, ref, onMounted} from 'vue';
|
||||
import {message, Modal} from 'ant-design-vue';
|
||||
import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
|
||||
import type {EleProTable} from 'ele-admin-pro';
|
||||
@@ -67,6 +67,10 @@ import {removeBszxPayRanking, removeBatchBszxPayRanking, ranking} from '@/api/bs
|
||||
import type {BszxPayRanking, BszxPayRankingParam} from '@/api/bszx/bszxPayRanking/model';
|
||||
import {getPageTitle} from "@/utils/common";
|
||||
import Extra from "@/views/bsyx/extra.vue";
|
||||
import { useBszxStatisticsStore } from '@/store/modules/bszx-statistics';
|
||||
|
||||
// 使用百色中学统计数据 store
|
||||
const bszxStatisticsStore = useBszxStatisticsStore();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
@@ -81,18 +85,23 @@ const showEdit = ref(false);
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 合计总金额
|
||||
const totalPriceAmount = ref<number>(0);
|
||||
// 排行榜总金额(本地计算)
|
||||
const rankingTotalPrice = ref<number>(0);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({where}) => {
|
||||
return ranking({...where}).then(data => {
|
||||
totalPriceAmount.value = 0;
|
||||
data.map((item) => {
|
||||
// 计算排行榜总金额(用于对比显示)
|
||||
let total = 0;
|
||||
data.forEach((item) => {
|
||||
if (item.totalPrice) {
|
||||
totalPriceAmount.value += item.totalPrice
|
||||
total += item.totalPrice;
|
||||
}
|
||||
})
|
||||
});
|
||||
rankingTotalPrice.value = total;
|
||||
|
||||
// 不再在这里更新 store 数据,因为这里的数据是排行榜数据,不是真实的订单统计
|
||||
// store 中的数据应该来自 bszxOrderTotal API,代表真实的订单金额
|
||||
return data;
|
||||
});
|
||||
};
|
||||
@@ -140,6 +149,16 @@ const reload = (where?: BszxPayRankingParam) => {
|
||||
tableRef?.value?.reload({where: where});
|
||||
};
|
||||
|
||||
// 初始化数据
|
||||
onMounted(async () => {
|
||||
try {
|
||||
// 初始化百色中学统计数据
|
||||
await bszxStatisticsStore.fetchBszxStatistics();
|
||||
} catch (error) {
|
||||
console.error('初始化百色中学统计数据失败:', error);
|
||||
}
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: BszxPayRanking) => {
|
||||
current.value = row ?? null;
|
||||
|
||||
Reference in New Issue
Block a user