完成首页统计

This commit is contained in:
hupeng
2023-07-26 14:48:47 +08:00
parent 2524f558b5
commit 55a8cc243f
4 changed files with 455 additions and 341 deletions

View File

@ -105,3 +105,7 @@ export const getOrderHtml = async (param1,param2) => {
return await request.get({ url: `/order/store-order/printOrder?id=` + param1 + `&electId=` + param2})
}
export const getShopCount = async () => {
return await request.get({ url: `/order/store-order/count`})
}

View File

@ -1,136 +1,83 @@
<template>
<div>
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="flex items-center">
<img :src="avatar" alt="" class="w-70px h-70px rounded-[50%] mr-20px" />
<div>
<div class="text-20px text-700">
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
</div>
<div class="mt-10px text-14px text-gray-500">
{{ t('workplace.toady') }}20 - 32
</div>
<div class="divBox">
<el-row :gutter="24" class="baseInfo">
<el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
<el-card :bordered="false" dis-hover :padding="12">
<template #header>
<div class="acea-row row-between-wrapper">
<span>会员总数</span>
<el-tag type="success">全平台</el-tag>
</div>
</template>
<div class="content" v-if="count">
<span class="content-number spBlock mb15"><count-to :start-val="0" :end-val="count.userCount" :duration="2600" class="card-panel-num" /></span>
<el-divider />
<div class="acea-row row-between-wrapper">
<span class="content-time">今日订单数</span>
<span>{{ count.todayCount }} 单</span>
</div>
</div>
</el-col>
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="flex h-70px items-center justify-end <sm:mt-10px">
<div class="px-8px text-right">
<div class="text-14px text-gray-400 mb-20px">{{ t('workplace.project') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.project"
:duration="2600"
/>
</el-card>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
<el-card :bordered="false" dis-hover :padding="12">
<template #header>
<div class="acea-row row-between-wrapper">
<span>订单总数</span>
<el-tag type="success">全平台</el-tag>
</div>
<el-divider direction="vertical" />
<div class="px-8px text-right">
<div class="text-14px text-gray-400 mb-20px">{{ t('workplace.toDo') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.todo"
:duration="2600"
/>
</div>
<el-divider direction="vertical" border-style="dashed" />
<div class="px-8px text-right">
<div class="text-14px text-gray-400 mb-20px">{{ t('workplace.access') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.access"
:duration="2600"
/>
</template>
<div class="content" v-if="count">
<span class="content-number spBlock mb15"><count-to :start-val="0" :end-val="count.orderCount" :duration="3000" class="card-panel-num" /></span>
<el-divider />
<div class="acea-row row-between-wrapper">
<span class="content-time">昨日订单数</span>
<span>{{ count.proCount }} 单</span>
</div>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</div>
<el-row class="mt-5px" :gutter="20" justify="space-between">
<el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-10px">
<el-card shadow="never">
<template #header>
<div class="flex justify-between h-3">
<span>{{ t('workplace.project') }}</span>
<el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col
v-for="(item, index) in projects"
:key="`card-${index}`"
:xl="8"
:lg="8"
:md="8"
:sm="24"
:xs="24"
>
<el-card shadow="hover">
<div class="flex items-center">
<Icon :icon="item.icon" :size="25" class="mr-10px" />
<span class="text-16px">{{ item.name }}</span>
</div>
<div class="mt-15px text-14px text-gray-400">{{ t(item.message) }}</div>
<div class="mt-20px text-12px text-gray-400 flex justify-between">
<span>{{ item.personal }}</span>
<span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
</div>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
<el-card shadow="never" class="mt-5px">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="pieOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="barOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-10px">
<el-card shadow="never">
<template #header>
<div class="flex justify-between h-3">
<span>{{ t('workplace.shortcutOperation') }}</span>
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-10px">
<div class="flex items-center">
<Icon :icon="item.icon" class="mr-10px" />
<el-link type="default" :underline="false" @click="setWatermark(item.name)">
{{ item.name }}
</el-link>
</el-card>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
<el-card :bordered="false" dis-hover :padding="12">
<template #header>
<div class="acea-row row-between-wrapper">
<span>总金额</span>
<el-tag type="success">全平台</el-tag>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</template>
<div class="content" v-if="count">
<span class="content-number spBlock mb15"><count-to :start-val="0" :end-val="count.priceCount" :duration="3200" class="card-panel-num" /></span>
<el-divider />
<div class="acea-row row-between-wrapper">
<span class="content-time">近七天订单数</span>
<span>{{ count.lastWeekCount }} 单</span>
</div>
</div>
</el-card>
</el-col>
<el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
<el-card :bordered="false" dis-hover :padding="12">
<template #header>
<div class="acea-row row-between-wrapper">
<span>商品总数</span>
<el-tag type="success">全平台</el-tag>
</div>
</template>
<div class="content" v-if="count">
<span class="content-number spBlock mb15"><count-to :start-val="0" :end-val="count.goodsCount" :duration="3600" class="card-panel-num" /></span>
<el-divider />
<div class="acea-row row-between-wrapper">
<span class="content-time">本月订单数</span>
<span>{{ count.monthCount }} 单</span>
</div>
</div>
</el-card>
</el-col>
</el-row>
</div>
<PanelGroupT />
<div class="divBox">
<el-card shadow="never" class="mt-10px">
<template #header>
<div class="flex justify-between h-3">
@ -144,12 +91,10 @@
<img :src="avatar" alt="" class="w-35px h-35px rounded-[50%] mr-20px" />
<div>
<div class="text-14px">
<Highlight :keys="item.keys.map((v) => t(v))">
{{ item.type }} : {{ item.title }}
</Highlight>
{{ item.type == 1 ? '通知' : '公告' }} : {{ item.title }}
</div>
<div class="mt-15px text-12px text-gray-400">
{{ formatTime(item.date, 'yyyy-MM-dd') }}
{{ formatTime(item.createTime, 'yyyy-MM-dd') }}
</div>
</div>
</div>
@ -157,223 +102,216 @@
</div>
</el-skeleton>
</el-card>
</el-col>
</el-row>
</div>
</div>
</template>
<script setup lang="ts" name="Home">
import { set } from 'lodash-es'
import { EChartsOption } from 'echarts'
<script setup lang="ts">
import * as StoreOrderApi from '@/api/mall/order/storeOrder'
import * as NoticeApi from '@/api/system/notice'
import PanelGroupT from './PanelGroupT.vue'
import { formatTime } from '@/utils'
import { useUserStore } from '@/store/modules/user'
import { useWatermark } from '@/hooks/web/useWatermark'
import avatarImg from '@/assets/imgs/avatar.gif'
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
import { pieOptions, barOptions } from './echarts-data'
const { t } = useI18n()
const userStore = useUserStore()
const { setWatermark } = useWatermark()
const loading = ref(true)
const avatar = userStore.getUser.avatar ? userStore.getUser.avatar : avatarImg
const username = userStore.getUser.nickname
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
// 获取统计数
let totalSate = reactive<WorkplaceTotal>({
project: 0,
access: 0,
todo: 0
const { t } = useI18n()
const count = ref({
todayPrice: 0,
todayCount: 0,
proPrice: 0,
proCount: 0,
monthPrice: 0,
monthCount: 0,
lastWeekCount: 0,
lastWeekPrice: 0,
userCount: 0,
orderCount: 0,
priceCount: 0,
goodsCount: 0
})
const loading = ref(true)
const notice = ref([])
/** 查询列表 */
const getData = async () => {
try {
const data = await StoreOrderApi.getShopCount()
count.value = data
} finally {
}
}
/** 查询公告列表 */
const getList = async () => {
loading.value = true
try {
const data = await NoticeApi.getNoticePage({})
notice.value = data.list
} finally {
}
}
/** 初始化 **/
onMounted(() => {
getData()
getList()
loading.value = false
})
const getCount = async () => {
const data = {
project: 40,
access: 2340,
todo: 10
}
totalSate = Object.assign(totalSate, data)
}
// 获取项目数
let projects = reactive<Project[]>([])
const getProject = async () => {
const data = [
{
name: 'Github',
icon: 'akar-icons:github-fill',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vue',
icon: 'logos:vue',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Angular',
icon: 'logos:angular-icon',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'React',
icon: 'logos:react',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Webpack',
icon: 'logos:webpack',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
}
]
projects = Object.assign(projects, data)
}
// 获取通知公告
let notice = reactive<Notice[]>([])
const getNotice = async () => {
const data = [
{
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
},
{
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
}
]
notice = Object.assign(notice, data)
}
// 获取快捷入口
let shortcut = reactive<Shortcut[]>([])
const getShortcut = async () => {
const data = [
{
name: 'Github',
icon: 'akar-icons:github-fill',
url: 'github.io'
},
{
name: 'Vue',
icon: 'logos:vue',
url: 'vuejs.org'
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
url: 'https://vitejs.dev/'
},
{
name: 'Angular',
icon: 'logos:angular-icon',
url: 'github.io'
},
{
name: 'React',
icon: 'logos:react',
url: 'github.io'
},
{
name: 'Webpack',
icon: 'logos:webpack',
url: 'github.io'
}
]
shortcut = Object.assign(shortcut, data)
}
// 用户来源
const getUserAccessSource = async () => {
const data = [
{ value: 335, name: 'analysis.directAccess' },
{ value: 310, name: 'analysis.mailMarketing' },
{ value: 234, name: 'analysis.allianceAdvertising' },
{ value: 135, name: 'analysis.videoAdvertising' },
{ value: 1548, name: 'analysis.searchEngines' }
]
set(
pieOptionsData,
'legend.data',
data.map((v) => t(v.name))
)
pieOptionsData!.series![0].data = data.map((v) => {
return {
name: t(v.name),
value: v.value
}
})
}
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
// 周活跃量
const getWeeklyUserActivity = async () => {
const data = [
{ value: 13253, name: 'analysis.monday' },
{ value: 34235, name: 'analysis.tuesday' },
{ value: 26321, name: 'analysis.wednesday' },
{ value: 12340, name: 'analysis.thursday' },
{ value: 24643, name: 'analysis.friday' },
{ value: 1322, name: 'analysis.saturday' },
{ value: 1324, name: 'analysis.sunday' }
]
set(
barOptionsData,
'xAxis.data',
data.map((v) => t(v.name))
)
set(barOptionsData, 'series', [
{
name: t('analysis.activeQuantity'),
data: data.map((v) => v.value),
type: 'bar'
}
])
}
const getAllApi = async () => {
await Promise.all([
getCount(),
getProject(),
getNotice(),
getShortcut(),
getUserAccessSource(),
getWeeklyUserActivity()
])
loading.value = false
}
getAllApi()
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.acea-row {
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-lines: multiple;
-moz-box-lines: multiple;
-o-box-lines: multiple;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
/* 辅助类 */
}
/* 上下两边居中对齐 */
.acea-row.row-between-wrapper {
-webkit-box-align: center;
-moz-box-align: center;
-o-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: justify;
-moz-box-pack: justify;
-o-box-pack: justify;
-ms-flex-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
}
.panel-group {
margin-top: 18px;
.card-panel-col {
margin-bottom: 32px;
}
.card-panel {
height: 108px;
cursor: pointer;
font-size: 12px;
position: relative;
overflow: hidden;
color: #666;
background: #fff;
box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
border-color: rgba(0, 0, 0, 0.05);
.icon-people {
color: #40c9c6;
}
.icon-message {
color: #36a3f7;
}
.icon-money {
color: #f4516c;
}
.icon-shopping {
color: #34bfa3;
}
.card-panel-icon-wrapper {
float: left;
margin: 14px 0 0 14px;
padding: 16px;
transition: all 0.38s ease-out;
border-radius: 6px;
}
.card-panel-icon {
float: left;
font-size: 48px;
}
.card-panel-description {
float: right;
font-weight: bold;
margin: 26px;
margin-left: 0px;
.card-panel-text {
line-height: 18px;
color: rgba(0, 0, 0, 0.45);
font-size: 16px;
margin-bottom: 12px;
}
.card-panel-num {
font-size: 20px;
}
}
}
}
@media (max-width: 550px) {
.card-panel-description {
display: none;
}
.card-panel-icon-wrapper {
float: none !important;
width: 100%;
height: 100%;
margin: 0 !important;
.svg-icon {
display: block;
margin: 14px auto !important;
float: none !important;
}
}
}
.baseInfo {
::v-deep .el-card__header {
padding: 15px 20px !important;
}
}
.ivu-mb {
margin-bottom: 10px;
}
.up,
.el-icon-caret-top {
color: #f5222d;
font-size: 12px;
opacity: 1 !important;
}
.down,
.el-icon-caret-bottom {
color: #39c15b;
font-size: 12px;
/*opacity: 100% !important;*/
}
.content {
&-number {
font-size: 30px;
}
&-time {
font-size: 14px;
/*color: #8C8C8C;*/
}
}
.spBlock {
display: block;
}
</style>

View File

@ -0,0 +1,172 @@
<template>
<div class="divBox">
<el-row :gutter="24" class="dashboard-console-grid">
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '/mall/product/store-product' }">
<Icon icon="ep:goods" style="color: #69c0ff" :size="35" />
<p>商品管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '/mall/member/user' }">
<Icon icon="ep:user" style="color: #95de64" :size="35" />
<p>会员管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '/mall/order/store-order' }">
<Icon icon="ep:list" style="color: #ff9c6e" :size="35" />
<p>订单管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '' }" @click="warnTis">
<Icon icon="ep:ticket" style="color: #b37feb" :size="35" />
<p>电子券管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '' }" @click="warnTis">
<Icon icon="ep:postcard" style="color: #ffd666" :size="35" />
<p>营销管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '' }" @click="warnTis">
<Icon icon="ep:notebook" style="color: #5cdbd3" :size="35" />
<p>分销管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '/pay/merchant-details' }">
<Icon icon="ep:money" style="color: #ff85c0" :size="35" />
<p>支付管理</p>
</router-link>
</el-card>
</el-col>
<el-col v-bind="grid" class="ivu-mb">
<el-card :bordered="false">
<router-link :to="{ path: '/message/wechat-templateo' }">
<Icon icon="ep:message" style="color: #ffc069" :size="35" />
<p>消息管理</p>
</router-link>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script setup lang="ts">
const message = useMessage() // 消息弹窗
const grid =ref({
xl: 3,
lg: 3,
md: 6,
sm: 8,
xs: 8,
})
const warnTis = () => {
return message.warning('还在开发中...')
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.panel-group {
margin-top: 18px;
.card-panel-col{
margin-bottom: 32px;
}
.card-panel {
height: 108px;
font-size: 12px;
position: relative;
overflow: hidden;
cursor: pointer;
color: #666;
background: #fff;
box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
border-color: rgba(0, 0, 0, .05);
.icon-people {
color: #40c9c6;
}
.icon-message {
color: #36a3f7;
}
.icon-money {
color: #f4516c;
}
.icon-shopping {
color: #34bfa3
}
.card-panel-icon-wrapper {
float: left;
margin: 14px 0 0 14px;
padding: 16px;
transition: all 0.38s ease-out;
border-radius: 6px;
}
.card-panel-icon {
float: left;
font-size: 48px;
}
.card-panel-description {
float: right;
font-weight: bold;
margin: 26px;
margin-left: 0px;
.card-panel-text {
line-height: 18px;
color: rgba(0, 0, 0, 0.45);
font-size: 16px;
margin-bottom: 12px;
}
.card-panel-num {
font-size: 20px;
}
}
}
}
.ivu-mb {
margin-bottom: 10px;
}
.divBox {
// padding: 0 20px !important;
}
.dashboard-console-grid {
text-align: center;
.ivu-card-body {
padding: 0;
}
i {
font-size: 32px;
}
a {
display: block;
color: inherit;
}
p {
margin-top: 8px;
}
}
</style>

View File

@ -67,7 +67,7 @@ const formRules = reactive({
title: [{ required: true, message: '公告标题不能为空', trigger: 'blur' }],
type: [{ required: true, message: '公告类型不能为空', trigger: 'change' }],
status: [{ required: true, message: '状态不能为空', trigger: 'change' }],
content: [{ required: true, message: '公告内容不能为空', trigger: 'blur' }]
// content: [{ required: true, message: '公告内容不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref