feat(shop): 实时修复今日数据及优化商城设置与商品列表展示
- 修复 dashboard 今日数据统计,改为实时计算订单、销售额、用户数与优惠券使用量 - 统计数据写入 cmsStatistics 表,新增 couponUsedCount 状态与 getter - dashboard 页面移除原有按日期查询逻辑,优惠券使用数改为响应式读取 - 商城设置 Logo 上传改为直接调用 OSS 接口上传,移除图片库选择组件 - 新增商品列表中市场价和会员价列,数据为空时显示 "-" - 同步更新商品列表导出功能,包含新增的价格列与列宽配置 - 商品列表商品图片添加 OSS 压缩访问支持 - 调整商品分类搜索框与关键词输入框宽度以优化布局
This commit is contained in:
@@ -16,13 +16,27 @@
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商城Logo" name="shopLogo">
|
||||
<SelectFile
|
||||
:placeholder="'请选择商城Logo'"
|
||||
:limit="1"
|
||||
:data="logoList"
|
||||
@done="chooseImage"
|
||||
@del="onDeleteImage"
|
||||
<a-image
|
||||
v-if="form.shopLogo"
|
||||
width="100px"
|
||||
height="100px"
|
||||
:src="form.shopLogo"
|
||||
style="margin-right: 10px; border-radius: 6px;"
|
||||
/>
|
||||
<a-upload
|
||||
:show-upload-list="false"
|
||||
:customRequest="onUploadLogo"
|
||||
>
|
||||
<a-button class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<UploadOutlined/>
|
||||
</template>
|
||||
<span>上传</span>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<div class="ele-text-placeholder" style="margin-top: 6px;">
|
||||
建议上传 400x400 像素的正方形 Logo,图片大小不超过 10MB。
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="商城描述" name="shopDesc">
|
||||
<a-textarea
|
||||
@@ -59,7 +73,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, watch, onMounted } from 'vue';
|
||||
import { UploadOutlined } from '@ant-design/icons-vue';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -67,8 +82,8 @@ import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { batchSaveShopSetting, getShopSettingCategoryValues } from '@/api/shop/shopSetting';
|
||||
import type { ShopSetting } from '@/api/shop/shopSetting/model';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { uploadOss } from '@/api/system/file';
|
||||
import { messageLoading } from 'ele-admin-pro';
|
||||
|
||||
const category = 'basic';
|
||||
|
||||
@@ -77,7 +92,6 @@ const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const loading = ref(false);
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const logoList = ref<ItemType[]>([]);
|
||||
|
||||
const { form, assignFields } = useFormData<ShopSetting>({
|
||||
shopName: '',
|
||||
@@ -99,16 +113,27 @@ const rules = reactive({
|
||||
]
|
||||
});
|
||||
|
||||
// 选择图片
|
||||
const chooseImage = (data: FileRecord) => {
|
||||
logoList.value.push({ uid: data.id, url: data.path, status: 'done' });
|
||||
form.shopLogo = data.path;
|
||||
};
|
||||
|
||||
// 删除图片
|
||||
const onDeleteImage = (index: number) => {
|
||||
logoList.value.splice(index, 1);
|
||||
form.shopLogo = '';
|
||||
// 上传 Logo
|
||||
const onUploadLogo = (item: any) => {
|
||||
const { file } = item;
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('图片大小不能超过 10MB');
|
||||
return;
|
||||
}
|
||||
const hide = messageLoading({
|
||||
content: '上传中..',
|
||||
duration: 0,
|
||||
mask: true
|
||||
});
|
||||
uploadOss(file)
|
||||
.then((res) => {
|
||||
hide();
|
||||
form.shopLogo = res.path;
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '上传失败');
|
||||
});
|
||||
};
|
||||
|
||||
const load = async () => {
|
||||
@@ -119,11 +144,6 @@ const load = async () => {
|
||||
// 布尔值转换(后端可能返回字符串 '1'/'0'/'true'/'false')
|
||||
const raw = (values as any).shopEnabled;
|
||||
form.shopEnabled = raw === true || raw === 'true' || raw === '1' || raw === 1;
|
||||
// 回显 Logo
|
||||
logoList.value = [];
|
||||
if (form.shopLogo) {
|
||||
logoList.value.push({ uid: 1, url: form.shopLogo as string, status: '' });
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
// 未配置时忽略
|
||||
|
||||
Reference in New Issue
Block a user