新增:统计订单总额功能
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
VITE_APP_NAME=后台管理(开发环境)
|
||||
#VITE_API_URL=http://127.0.0.1:9200/api
|
||||
VITE_API_URL=http://127.0.0.1:9200/api
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 268 B |
106
src/api/cms/cmsStatistics/index.ts
Normal file
106
src/api/cms/cmsStatistics/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CmsStatistics, CmsStatisticsParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询站点统计信息表
|
||||
*/
|
||||
export async function pageCmsStatistics(params: CmsStatisticsParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CmsStatistics>>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点统计信息表列表
|
||||
*/
|
||||
export async function listCmsStatistics(params?: CmsStatisticsParam) {
|
||||
const res = await request.get<ApiResult<CmsStatistics[]>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加站点统计信息表
|
||||
*/
|
||||
export async function addCmsStatistics(data: CmsStatistics) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改站点统计信息表
|
||||
*/
|
||||
export async function updateCmsStatistics(data: CmsStatistics) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除站点统计信息表
|
||||
*/
|
||||
export async function removeCmsStatistics(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除站点统计信息表
|
||||
*/
|
||||
export async function removeBatchCmsStatistics(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询站点统计信息表
|
||||
*/
|
||||
export async function getCmsStatistics(id: number) {
|
||||
const res = await request.get<ApiResult<CmsStatistics>>(
|
||||
MODULES_API_URL + '/cms/cms-statistics/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
79
src/api/cms/cmsStatistics/model/index.ts
Normal file
79
src/api/cms/cmsStatistics/model/index.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 站点统计信息表
|
||||
*/
|
||||
export interface CmsStatistics {
|
||||
// 自增ID
|
||||
id?: number;
|
||||
// 站点ID
|
||||
websiteId?: number;
|
||||
// 用户总数
|
||||
userCount?: number;
|
||||
// 订单总数
|
||||
orderCount?: number;
|
||||
// 商品总数
|
||||
productCount?: number;
|
||||
// 总销售额
|
||||
totalSales?: number;
|
||||
// 本月销售额
|
||||
monthSales?: number;
|
||||
// 今日销售额
|
||||
todaySales?: number;
|
||||
// 昨日销售额
|
||||
yesterdaySales?: number;
|
||||
// 本周销售额
|
||||
weekSales?: number;
|
||||
// 本年销售额
|
||||
yearSales?: number;
|
||||
// 今日订单数
|
||||
todayOrders?: number;
|
||||
// 本月订单数
|
||||
monthOrders?: number;
|
||||
// 今日新增用户
|
||||
todayUsers?: number;
|
||||
// 本月新增用户
|
||||
monthUsers?: number;
|
||||
// 今日访问量
|
||||
todayVisits?: number;
|
||||
// 总访问量
|
||||
totalVisits?: number;
|
||||
// 商户总数
|
||||
merchantCount?: number;
|
||||
// 活跃用户数
|
||||
activeUsers?: number;
|
||||
// 转化率(%)
|
||||
conversionRate?: string;
|
||||
// 平均订单金额
|
||||
avgOrderAmount?: string;
|
||||
// 统计日期
|
||||
statisticsDate?: string;
|
||||
// 统计类型: 1日统计, 2月统计, 3年统计
|
||||
statisticsType?: number;
|
||||
// 运行天数
|
||||
runDays?: number;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 操作用户ID
|
||||
userId?: number;
|
||||
// 商户ID
|
||||
merchantId?: number;
|
||||
// 状态: 0禁用, 1启用
|
||||
status?: string;
|
||||
// 是否删除: 0否, 1是
|
||||
deleted?: string;
|
||||
// 租户ID
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 站点统计信息表搜索条件
|
||||
*/
|
||||
export interface CmsStatisticsParam extends PageParam {
|
||||
id?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -118,3 +118,19 @@ export async function repairOrder(data: ShopOrder) {
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计订单总金额(只统计有效订单)
|
||||
*/
|
||||
export async function shopOrderTotal(params?: ShopOrderParam) {
|
||||
const res = await request.get<ApiResult<ShopOrder[]>>(
|
||||
MODULES_API_URL + '/shop/shop-order/total',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
387
src/views/cms/cmsStatistics/components/cmsStatisticsEdit.vue
Normal file
387
src/views/cms/cmsStatistics/components/cmsStatisticsEdit.vue
Normal file
@@ -0,0 +1,387 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑站点统计信息表' : '添加站点统计信息表'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="站点ID" name="websiteId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入站点ID"
|
||||
v-model:value="form.websiteId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="用户总数" name="userCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入用户总数"
|
||||
v-model:value="form.userCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单总数" name="orderCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入订单总数"
|
||||
v-model:value="form.orderCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品总数" name="productCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入商品总数"
|
||||
v-model:value="form.productCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="总销售额" name="totalSales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入总销售额"
|
||||
v-model:value="form.totalSales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="本月销售额" name="monthSales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入本月销售额"
|
||||
v-model:value="form.monthSales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="今日销售额" name="todaySales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入今日销售额"
|
||||
v-model:value="form.todaySales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="昨日销售额" name="yesterdaySales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入昨日销售额"
|
||||
v-model:value="form.yesterdaySales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="本周销售额" name="weekSales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入本周销售额"
|
||||
v-model:value="form.weekSales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="本年销售额" name="yearSales">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入本年销售额"
|
||||
v-model:value="form.yearSales"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="今日订单数" name="todayOrders">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入今日订单数"
|
||||
v-model:value="form.todayOrders"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="本月订单数" name="monthOrders">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入本月订单数"
|
||||
v-model:value="form.monthOrders"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="今日新增用户" name="todayUsers">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入今日新增用户"
|
||||
v-model:value="form.todayUsers"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="本月新增用户" name="monthUsers">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入本月新增用户"
|
||||
v-model:value="form.monthUsers"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="今日访问量" name="todayVisits">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入今日访问量"
|
||||
v-model:value="form.todayVisits"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="总访问量" name="totalVisits">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入总访问量"
|
||||
v-model:value="form.totalVisits"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商户总数" name="merchantCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入商户总数"
|
||||
v-model:value="form.merchantCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="活跃用户数" name="activeUsers">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入活跃用户数"
|
||||
v-model:value="form.activeUsers"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="转化率(%)" name="conversionRate">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入转化率(%)"
|
||||
v-model:value="form.conversionRate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="平均订单金额" name="avgOrderAmount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入平均订单金额"
|
||||
v-model:value="form.avgOrderAmount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="统计日期" name="statisticsDate">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入统计日期"
|
||||
v-model:value="form.statisticsDate"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="统计类型: 1日统计, 2月统计, 3年统计" name="statisticsType">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入统计类型: 1日统计, 2月统计, 3年统计"
|
||||
v-model:value="form.statisticsType"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="9999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="操作用户ID" name="userId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入操作用户ID"
|
||||
v-model:value="form.userId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商户ID" name="merchantId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入商户ID"
|
||||
v-model:value="form.merchantId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="状态: 0禁用, 1启用" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">显示</a-radio>
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否删除: 0否, 1是" name="deleted">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入是否删除: 0否, 1是"
|
||||
v-model:value="form.deleted"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="修改时间" name="updateTime">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入修改时间"
|
||||
v-model:value="form.updateTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import { addCmsStatistics, updateCmsStatistics } from '@/api/cms/cmsStatistics';
|
||||
import { CmsStatistics } from '@/api/cms/cmsStatistics/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: CmsStatistics | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<CmsStatistics>({
|
||||
id: undefined,
|
||||
websiteId: undefined,
|
||||
userCount: undefined,
|
||||
orderCount: undefined,
|
||||
productCount: undefined,
|
||||
totalSales: undefined,
|
||||
monthSales: undefined,
|
||||
todaySales: undefined,
|
||||
yesterdaySales: undefined,
|
||||
weekSales: undefined,
|
||||
yearSales: undefined,
|
||||
todayOrders: undefined,
|
||||
monthOrders: undefined,
|
||||
todayUsers: undefined,
|
||||
monthUsers: undefined,
|
||||
todayVisits: undefined,
|
||||
totalVisits: undefined,
|
||||
merchantCount: undefined,
|
||||
activeUsers: undefined,
|
||||
conversionRate: undefined,
|
||||
avgOrderAmount: undefined,
|
||||
statisticsDate: undefined,
|
||||
statisticsType: undefined,
|
||||
sortNumber: undefined,
|
||||
userId: undefined,
|
||||
merchantId: undefined,
|
||||
status: undefined,
|
||||
deleted: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined,
|
||||
cmsStatisticsId: undefined,
|
||||
cmsStatisticsName: '',
|
||||
status: 0,
|
||||
comments: '',
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
cmsStatisticsName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写站点统计信息表名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const chooseImage = (data: FileRecord) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
form.image = data.path;
|
||||
};
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.image = '';
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateCmsStatistics : addCmsStatistics;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if(props.data.image){
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
url: props.data.image,
|
||||
status: 'done'
|
||||
})
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
42
src/views/cms/cmsStatistics/components/search.vue
Normal file
42
src/views/cms/cmsStatistics/components/search.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
163
src/views/cms/cmsStatistics/index.vue
Normal file
163
src/views/cms/cmsStatistics/index.vue
Normal file
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-row :gutter="16">
|
||||
<!-- 统计数据卡片 -->
|
||||
<a-col :span="6">
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="用户总数"
|
||||
:value="statistics.userCount"
|
||||
:value-style="{ color: '#3f8600' }"
|
||||
>
|
||||
<template #prefix>
|
||||
<UserOutlined/>
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="6">
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="订单总数"
|
||||
:value="statistics.orderCount"
|
||||
:value-style="{ color: '#1890ff' }"
|
||||
>
|
||||
<template #prefix>
|
||||
<AccountBookOutlined/>
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="6">
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="总营业额"
|
||||
:value="statistics.totalSales"
|
||||
:value-style="{ color: '#cf1322' }"
|
||||
>
|
||||
<template #prefix>
|
||||
<MoneyCollectOutlined/>
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="6">
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="系统运行天数"
|
||||
:value="statistics.runDays"
|
||||
suffix="天"
|
||||
:value-style="{ color: '#722ed1' }"
|
||||
>
|
||||
<template #prefix>
|
||||
<ClockCircleOutlined/>
|
||||
</template>
|
||||
</a-statistic>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, onMounted} from 'vue';
|
||||
import {
|
||||
UserOutlined,
|
||||
CalendarOutlined,
|
||||
QrcodeOutlined,
|
||||
ShopOutlined,
|
||||
ClockCircleOutlined,
|
||||
SettingOutlined,
|
||||
AccountBookOutlined,
|
||||
FileTextOutlined,
|
||||
MoneyCollectOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import {getSiteInfo} from "@/api/layout";
|
||||
import {CmsWebsite} from "@/api/cms/cmsWebsite/model";
|
||||
import {pageUsers} from "@/api/system/user";
|
||||
import {pageShopOrder} from "@/api/shop/shopOrder";
|
||||
import {getPageTitle, openNew} from "@/utils/common";
|
||||
import {listCmsStatistics} from "@/api/cms/cmsStatistics";
|
||||
|
||||
// 当前小程序项目
|
||||
const siteInfo = ref<CmsWebsite>({});
|
||||
|
||||
// 系统信息
|
||||
const systemInfo = ref({
|
||||
name: '小程序开发',
|
||||
description: '基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
|
||||
version: '2.0.0',
|
||||
status: '运行中',
|
||||
logo: '/logo.png',
|
||||
environment: '生产环境',
|
||||
database: 'MySQL 8.0',
|
||||
server: 'Linux CentOS 7.9',
|
||||
expirationTime: '2024-01-01 09:00:00'
|
||||
});
|
||||
|
||||
// 统计数据
|
||||
const statistics = ref({
|
||||
userCount: 0,
|
||||
orderCount: 0,
|
||||
todayVisit: 0,
|
||||
runDays: 365
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 加载系统信息和统计数据
|
||||
loadSystemInfo();
|
||||
loadStatistics();
|
||||
});
|
||||
|
||||
const loadSystemInfo = async () => {
|
||||
// TODO: 调用API获取系统信息
|
||||
siteInfo.value = await getSiteInfo();
|
||||
if (siteInfo.value.createTime) {
|
||||
// 根据创建时间计算运行天数
|
||||
statistics.value.runDays = Math.floor((new Date().getTime() - new Date(siteInfo.value.createTime).getTime()) / (24 * 60 * 60 * 1000))
|
||||
}
|
||||
};
|
||||
|
||||
const loadStatistics = async () => {
|
||||
// TODO: 调用API获取统计数据
|
||||
const users = await pageUsers({})
|
||||
const orders = await pageShopOrder({})
|
||||
if (users) {
|
||||
console.log(users.count)
|
||||
statistics.value.userCount = users.count
|
||||
}
|
||||
if (orders) {
|
||||
statistics.value.orderCount = orders.count
|
||||
}
|
||||
// 获取统计表数据
|
||||
const data = await listCmsStatistics({});
|
||||
if (data) {
|
||||
// 统计数据
|
||||
statistics.value.totalSales = data[0].totalSales;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.system-info h2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
text-align: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.stat-card :deep(.ant-statistic-title) {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.stat-card :deep(.ant-statistic-content) {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -26,7 +26,9 @@
|
||||
<template #content>
|
||||
<p><img :src="siteInfo.websiteDarkLogo" alt="小程序码" width="300" height="300"></p>
|
||||
</template>
|
||||
<a-tag><QrcodeOutlined/></a-tag>
|
||||
<a-tag>
|
||||
<QrcodeOutlined/>
|
||||
</a-tag>
|
||||
</a-popover>
|
||||
</a-space>
|
||||
</div>
|
||||
@@ -45,7 +47,7 @@
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="用户总数"
|
||||
:value="statistics.userCount"
|
||||
:value="form.userCount"
|
||||
:value-style="{ color: '#3f8600' }"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -59,7 +61,7 @@
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="订单总数"
|
||||
:value="statistics.orderCount"
|
||||
:value="form.orderCount"
|
||||
:value-style="{ color: '#1890ff' }"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -72,8 +74,8 @@
|
||||
<a-col :span="6">
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="今日营业额"
|
||||
:value="statistics.todayVisit"
|
||||
title="总营业额"
|
||||
:value="form.totalSales"
|
||||
:value-style="{ color: '#cf1322' }"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -87,7 +89,7 @@
|
||||
<a-card :bordered="false" class="stat-card">
|
||||
<a-statistic
|
||||
title="系统运行天数"
|
||||
:value="statistics.runDays"
|
||||
:value="runDays"
|
||||
suffix="天"
|
||||
:value-style="{ color: '#722ed1' }"
|
||||
>
|
||||
@@ -162,7 +164,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, onMounted} from 'vue';
|
||||
import {ref, reactive, onMounted} from 'vue';
|
||||
import {
|
||||
UserOutlined,
|
||||
CalendarOutlined,
|
||||
@@ -174,11 +176,15 @@ import {
|
||||
FileTextOutlined,
|
||||
MoneyCollectOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import {assignObject} from 'ele-admin-pro';
|
||||
import {getSiteInfo} from "@/api/layout";
|
||||
import {CmsWebsite} from "@/api/cms/cmsWebsite/model";
|
||||
import {pageUsers} from "@/api/system/user";
|
||||
import {pageShopOrder} from "@/api/shop/shopOrder";
|
||||
import {addShopOrder, pageShopOrder, shopOrderTotal} from "@/api/shop/shopOrder";
|
||||
import {openNew} from "@/utils/common";
|
||||
import {addCmsStatistics, listCmsStatistics, updateCmsStatistics} from "@/api/cms/cmsStatistics";
|
||||
import {CmsStatistics} from "@/api/cms/cmsStatistics/model";
|
||||
import {addCmsArticle, updateCmsArticle} from "@/api/cms/cmsArticle";
|
||||
|
||||
// 当前小程序项目
|
||||
const siteInfo = ref<CmsWebsite>({});
|
||||
@@ -196,12 +202,71 @@ const systemInfo = ref({
|
||||
expirationTime: '2024-01-01 09:00:00'
|
||||
});
|
||||
|
||||
const runDays = ref<number>(0)
|
||||
|
||||
// 统计数据
|
||||
const statistics = ref({
|
||||
userCount: 0,
|
||||
orderCount: 0,
|
||||
todayVisit: 3456,
|
||||
runDays: 365
|
||||
const form = reactive<CmsStatistics>({
|
||||
websiteId: undefined,
|
||||
// 用户总数
|
||||
userCount: undefined,
|
||||
// 订单总数
|
||||
orderCount: undefined,
|
||||
// 商品总数
|
||||
productCount: undefined,
|
||||
// 总销售额
|
||||
totalSales: undefined,
|
||||
// 本月销售额
|
||||
monthSales: undefined,
|
||||
// 今日销售额
|
||||
todaySales: undefined,
|
||||
// 昨日销售额
|
||||
yesterdaySales: undefined,
|
||||
// 本周销售额
|
||||
weekSales: undefined,
|
||||
// 本年销售额
|
||||
yearSales: undefined,
|
||||
// 今日订单数
|
||||
todayOrders: undefined,
|
||||
// 本月订单数
|
||||
monthOrders: undefined,
|
||||
// 今日新增用户
|
||||
todayUsers: undefined,
|
||||
// 本月新增用户
|
||||
monthUsers: undefined,
|
||||
// 今日访问量
|
||||
todayVisits: undefined,
|
||||
// 总访问量
|
||||
totalVisits: undefined,
|
||||
// 商户总数
|
||||
merchantCount: undefined,
|
||||
// 活跃用户数
|
||||
activeUsers: undefined,
|
||||
// 转化率(%)
|
||||
conversionRate: undefined,
|
||||
// 平均订单金额
|
||||
avgOrderAmount: undefined,
|
||||
// 统计日期
|
||||
statisticsDate: undefined,
|
||||
// 统计类型: 1日统计, 2月统计, 3年统计
|
||||
statisticsType: undefined,
|
||||
// 运行天数
|
||||
runDays: undefined,
|
||||
// 排序号
|
||||
sortNumber: undefined,
|
||||
// 操作用户ID
|
||||
userId: undefined,
|
||||
// 商户ID
|
||||
merchantId: undefined,
|
||||
// 状态: 0禁用, 1启用
|
||||
status: undefined,
|
||||
// 是否删除: 0否, 1是
|
||||
deleted: undefined,
|
||||
// 租户ID
|
||||
tenantId: undefined,
|
||||
// 创建时间
|
||||
createTime: undefined,
|
||||
// 修改时间
|
||||
updateTime: undefined,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
@@ -215,7 +280,7 @@ const loadSystemInfo = async () => {
|
||||
siteInfo.value = await getSiteInfo();
|
||||
if (siteInfo.value.createTime) {
|
||||
// 根据创建时间计算运行天数
|
||||
statistics.value.runDays = Math.floor((new Date().getTime() - new Date(siteInfo.value.createTime).getTime()) / (24 * 60 * 60 * 1000))
|
||||
runDays.value = Math.floor((new Date().getTime() - new Date(siteInfo.value.createTime).getTime()) / (24 * 60 * 60 * 1000))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -223,13 +288,31 @@ const loadStatistics = async () => {
|
||||
// TODO: 调用API获取统计数据
|
||||
const users = await pageUsers({})
|
||||
const orders = await pageShopOrder({})
|
||||
if(users){
|
||||
console.log(users.count)
|
||||
statistics.value.userCount = users.count
|
||||
const total = await shopOrderTotal()
|
||||
const data = await listCmsStatistics({});
|
||||
|
||||
// 获取统计表数据
|
||||
if (data) {
|
||||
const saveOrUpdate = data.length > 0 ? updateCmsStatistics : addCmsStatistics;
|
||||
if (data.length > 0) {
|
||||
const saveData = data[0]
|
||||
assignObject(form, saveData);
|
||||
// 更新数据
|
||||
setTimeout(() => {
|
||||
if (saveData && users && orders) {
|
||||
const id = saveData.id
|
||||
saveOrUpdate({
|
||||
id,
|
||||
userCount: users.count,
|
||||
orderCount: orders.count,
|
||||
totalSales: Number(total),
|
||||
})
|
||||
}
|
||||
if(orders){
|
||||
statistics.value.orderCount = orders.count
|
||||
},2000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user