refactor(statistics): 重构统计数据获取逻辑
- 使用 Promise.allSettled 替代 Promise.all,提高容错性 - 添加详细的错误处理和日志记录,便于调试 - 优化用户、订单和销售额的计算逻辑,提高数据准确性 - 移除无效的 API 调用和冗余代码,简化代码结构 - 在 dashboard 页面添加刷新统计按钮,实现统计数据的强制刷新功能
This commit is contained in:
@@ -114,9 +114,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {createVNode, ref} from 'vue';
|
||||
import {message, Modal} from 'ant-design-vue';
|
||||
import {ExclamationCircleOutlined, QrcodeOutlined} from '@ant-design/icons-vue';
|
||||
import {ref} from 'vue';
|
||||
import {message} from 'ant-design-vue';
|
||||
import {QrcodeOutlined} from '@ant-design/icons-vue';
|
||||
import type {EleProTable} from 'ele-admin-pro';
|
||||
import {toDateString} from 'ele-admin-pro';
|
||||
import type {
|
||||
@@ -127,8 +127,6 @@ import WebsiteEdit from './components/websiteEdit.vue';
|
||||
import Qrcode from '@/components/QrCode/index.vue';
|
||||
import {
|
||||
pageCmsWebsite,
|
||||
removeCmsWebsite,
|
||||
removeBatchCmsWebsite,
|
||||
updateCmsWebsite
|
||||
} from '@/api/cms/cmsWebsite';
|
||||
import type {CmsWebsite, CmsWebsiteParam} from '@/api/cms/cmsWebsite/model';
|
||||
@@ -148,8 +146,6 @@ const selection = ref<CmsWebsite[]>([]);
|
||||
const current = ref<CmsWebsite | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 是否显示二维码
|
||||
const showQrcode = ref(false);
|
||||
// 二维码内容
|
||||
@@ -265,11 +261,6 @@ const openEdit = (row?: CmsWebsite) => {
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
const updateType = (row: CmsWebsite) => {
|
||||
updateCmsWebsite(row).then((msg) => {
|
||||
message.success(msg);
|
||||
@@ -286,48 +277,6 @@ const hideShare = () => {
|
||||
showQrcode.value = false;
|
||||
}
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: CmsWebsite) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeCmsWebsite(row.websiteId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchCmsWebsite(selection.value.map((d) => d.websiteId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
// 查询订单
|
||||
|
||||
Reference in New Issue
Block a user