mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49:19 +08:00
feat: 忘了干啥了
This commit is contained in:
+13
-15
@@ -8,11 +8,8 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createShopApi,
|
||||
updateShopApi,
|
||||
uploadShopLogoApi,
|
||||
} from '#/api/ecommerce/shop';
|
||||
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
@@ -230,11 +227,13 @@ async function uploadLogoAndGetId(): Promise<number | undefined> {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await uploadShopLogoApi(newLogoFile.value);
|
||||
return response.id;
|
||||
const fileInfo = await uploadFileToOss(newLogoFile.value, {
|
||||
category: 'shop-logo',
|
||||
errorMessage: 'Logo上传失败',
|
||||
});
|
||||
return fileInfo.id;
|
||||
} catch (error) {
|
||||
console.error('Logo上传失败:', error);
|
||||
message.error('Logo上传失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -256,13 +255,12 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="modalTitle" :confirm-loading="loading">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Modal
|
||||
:title="modalTitle"
|
||||
:confirm-loading="loading"
|
||||
content-class="px-5 py-4"
|
||||
>
|
||||
<Form ref="formRef" :model="formData">
|
||||
<Form.Item label="店铺Logo" name="logoImageId">
|
||||
<div style="display: flex; align-items: center; gap: 16px">
|
||||
<!-- Logo预览区域 -->
|
||||
|
||||
@@ -227,7 +227,7 @@ function handleModalSuccess() {
|
||||
|
||||
// 处理查看详情
|
||||
function handleViewDetails(record: ShopVO.Info) {
|
||||
router.push(`/ecom/shop/details/${record.id}`);
|
||||
router.push(`/ecom/shop/overview/${record.id}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -267,6 +267,48 @@ watch(
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
// 检查查询参数,如果有则设置时间范围
|
||||
const query = route.query;
|
||||
if (query.startDate && query.endDate) {
|
||||
const startDate = dayjs(query.startDate as string);
|
||||
const endDate = dayjs(query.endDate as string);
|
||||
const today = dayjs();
|
||||
|
||||
if (startDate.isValid() && endDate.isValid()) {
|
||||
dateRange.value = [startDate, endDate];
|
||||
// 判断时间范围类型
|
||||
const daysDiff = endDate.diff(startDate, 'day');
|
||||
const isEndDateToday = endDate.isSame(today, 'day');
|
||||
const isStartDate7DaysAgo = startDate.isSame(
|
||||
dayjs().subtract(7, 'day'),
|
||||
'day',
|
||||
);
|
||||
const isStartDate30DaysAgo = startDate.isSame(
|
||||
dayjs().subtract(30, 'day'),
|
||||
'day',
|
||||
);
|
||||
|
||||
if (daysDiff === 0 && startDate.isSame(today, 'day')) {
|
||||
activeTimeRange.value = 'today';
|
||||
} else if (
|
||||
daysDiff === 0 &&
|
||||
startDate.isSame(dayjs().subtract(1, 'day'), 'day')
|
||||
) {
|
||||
activeTimeRange.value = 'yesterday';
|
||||
} else if (isEndDateToday && isStartDate7DaysAgo) {
|
||||
// 近7天:从7天前到今天
|
||||
activeTimeRange.value = '7days';
|
||||
} else if (isEndDateToday && isStartDate30DaysAgo) {
|
||||
// 近30天:从30天前到今天
|
||||
activeTimeRange.value = '30days';
|
||||
} else {
|
||||
activeTimeRange.value = 'custom';
|
||||
customDateRange.value = [startDate, endDate];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置完时间范围后再加载数据
|
||||
if (shopId.value) {
|
||||
loadOverviewData();
|
||||
}
|
||||
@@ -274,7 +316,11 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="店铺经营概览" auto-content-height class="bg-[#f8fafc]">
|
||||
<Page
|
||||
:title="overviewData?.shopName || '店铺经营概览'"
|
||||
auto-content-height
|
||||
class="bg-[#f8fafc]"
|
||||
>
|
||||
<template #description>
|
||||
<div class="mt-1 text-sm font-bold italic text-slate-500">
|
||||
数据更新于:{{ dayjs().format('今日 HH:mm:ss') }}
|
||||
|
||||
Reference in New Issue
Block a user