Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
jason 2023-10-16 22:27:39 +08:00
commit ae2c3f2ad5
24 changed files with 1973 additions and 330 deletions

View File

@ -104,5 +104,5 @@ export const exportSpu = async (params) => {
// 获得商品 SPU 精简列表
export const getSpuSimpleList = async () => {
return request.get({ url: '/product/spu/get-simple-list' })
return request.get({ url: '/product/spu/list-all-simple' })
}

View File

@ -0,0 +1,42 @@
import request from '@/config/axios'
export interface ArticleVO {
id: number
categoryId: number
title: string
author: string
picUrl: string
introduction: string
browseCount: string
sort: number
status: number
spuId: number
recommendHot: boolean
recommendBanner: boolean
content: string
}
// 查询文章管理列表
export const getArticlePage = async (params) => {
return await request.get({ url: `/promotion/article/page`, params })
}
// 查询文章管理详情
export const getArticle = async (id: number) => {
return await request.get({ url: `/promotion/article/get?id=` + id })
}
// 新增文章管理
export const createArticle = async (data: ArticleVO) => {
return await request.post({ url: `/promotion/article/create`, data })
}
// 修改文章管理
export const updateArticle = async (data: ArticleVO) => {
return await request.put({ url: `/promotion/article/update`, data })
}
// 删除文章管理
export const deleteArticle = async (id: number) => {
return await request.delete({ url: `/promotion/article/delete?id=` + id })
}

View File

@ -0,0 +1,39 @@
import request from '@/config/axios'
export interface ArticleCategoryVO {
id: number
name: string
picUrl: string
status: number
sort: number
}
// 查询文章分类列表
export const getArticleCategoryPage = async (params) => {
return await request.get({ url: `/promotion/article-category/page`, params })
}
// 查询文章分类精简信息列表
export const getSimpleArticleCategoryList = async () => {
return await request.get({ url: `/promotion/article-category/list-all-simple` })
}
// 查询文章分类详情
export const getArticleCategory = async (id: number) => {
return await request.get({ url: `/promotion/article-category/get?id=` + id })
}
// 新增文章分类
export const createArticleCategory = async (data: ArticleCategoryVO) => {
return await request.post({ url: `/promotion/article-category/create`, data })
}
// 修改文章分类
export const updateArticleCategory = async (data: ArticleCategoryVO) => {
return await request.put({ url: `/promotion/article-category/update`, data })
}
// 删除文章分类
export const deleteArticleCategory = async (id: number) => {
return await request.delete({ url: `/promotion/article-category/delete?id=` + id })
}

View File

@ -0,0 +1,5 @@
/** 数据对照 Response VO */
export interface DataComparisonRespVO<T> {
value: T
reference: T
}

View File

@ -1,6 +1,6 @@
import request from '@/config/axios'
import dayjs from 'dayjs'
import { TradeStatisticsComparisonRespVO } from '@/api/mall/statistics/trade'
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
import { formatDate } from '@/utils/formatTime'
/** 会员分析 Request VO */
@ -10,17 +10,17 @@ export interface MemberAnalyseReqVO {
/** 会员分析 Response VO */
export interface MemberAnalyseRespVO {
visitorCount: number
visitUserCount: number
orderUserCount: number
payUserCount: number
atv: number
comparison: TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO>
comparison: DataComparisonRespVO<MemberAnalyseComparisonRespVO>
}
/** 会员分析对照数据 Response VO */
export interface MemberAnalyseComparisonRespVO {
userCount: number
activeUserCount: number
registerUserCount: number
visitUserCount: number
rechargeUserCount: number
}
@ -29,8 +29,8 @@ export interface MemberAreaStatisticsRespVO {
areaId: number
areaName: string
userCount: number
orderCreateCount: number
orderPayCount: number
orderCreateUserCount: number
orderPayUserCount: number
orderPayPrice: number
}
@ -54,6 +54,20 @@ export interface MemberTerminalStatisticsRespVO {
userCount: number
}
/** 会员数量统计 Response VO */
export interface MemberCountRespVO {
/** 用户访问量 */
visitUserCount: string
/** 新增用户数量 */
createUserCount: number
}
/** 会员注册数量 Response VO */
export interface MemberRegisterCountRespVO {
date: string
count: number
}
// 查询会员统计
export const getMemberSummary = () => {
return request.get<MemberSummaryRespVO>({
@ -89,3 +103,21 @@ export const getMemberTerminalStatisticsList = () => {
url: '/statistics/member/get-terminal-statistics-list'
})
}
// 获得用户数量量对照
export const getUserCountComparison = () => {
return request.get<DataComparisonRespVO<MemberCountRespVO>>({
url: '/statistics/member/user-count-comparison'
})
}
// 获得会员注册数量列表
export const getMemberRegisterCountList = (
beginTime: dayjs.ConfigType,
endTime: dayjs.ConfigType
) => {
return request.get<MemberRegisterCountRespVO[]>({
url: '/statistics/member/register-count-list',
params: { times: [formatDate(beginTime), formatDate(endTime)] }
})
}

View File

@ -0,0 +1,6 @@
import request from '@/config/axios'
/** 获取钱包充值金额 */
export const getWalletRechargePrice = async () => {
return await request.get<number>({ url: `/statistics/pay/wallet-recharge-price` })
}

View File

@ -1,12 +1,7 @@
import request from '@/config/axios'
import dayjs from 'dayjs'
import { formatDate } from '@/utils/formatTime'
/** 交易统计对照 Response VO */
export interface TradeStatisticsComparisonRespVO<T> {
value: T
reference: T
}
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
/** 交易统计 Response VO */
export interface TradeSummaryRespVO {
@ -24,46 +19,100 @@ export interface TradeTrendReqVO {
/** 交易状况统计 Response VO */
export interface TradeTrendSummaryRespVO {
time: string
turnover: number
turnoverPrice: number
orderPayPrice: number
rechargePrice: number
expensePrice: number
balancePrice: number
orderWalletPayPrice: number
brokerageSettlementPrice: number
orderRefundPrice: number
}
/** 交易订单数量 Response VO */
export interface TradeOrderCountRespVO {
/** 待发货 */
undelivered?: number
/** 待核销 */
pickUp?: number
/** 退款中 */
afterSaleApply?: number
/** 提现待审核 */
auditingWithdraw?: number
}
/** 交易订单统计 Response VO */
export interface TradeOrderSummaryRespVO {
/** 支付订单商品数 */
orderPayCount?: number
/** 总支付金额,单位:分 */
orderPayPrice?: number
}
/** 订单量趋势统计 Response VO */
export interface TradeOrderTrendRespVO {
/** 日期 */
date: string
/** 订单数量 */
orderPayCount: number
/** 订单支付金额 */
orderPayPrice: number
}
// 查询交易统计
export const getTradeStatisticsSummary = () => {
return request.get<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>>({
return request.get<DataComparisonRespVO<TradeSummaryRespVO>>({
url: '/statistics/trade/summary'
})
}
// 获得交易状况统计
export const getTradeTrendSummary = (params: TradeTrendReqVO) => {
return request.get<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>>({
return request.get<DataComparisonRespVO<TradeTrendSummaryRespVO>>({
url: '/statistics/trade/trend/summary',
params: formatDateParam(params)
})
}
// 获得交易状况明细
export const getTradeTrendList = (params: TradeTrendReqVO) => {
export const getTradeStatisticsList = (params: TradeTrendReqVO) => {
return request.get<TradeTrendSummaryRespVO[]>({
url: '/statistics/trade/trend/list',
url: '/statistics/trade/list',
params: formatDateParam(params)
})
}
// 导出交易状况明细
export const exportTradeTrend = (params: TradeTrendReqVO) => {
export const exportTradeStatisticsExcel = (params: TradeTrendReqVO) => {
return request.download({
url: '/statistics/trade/trend/export-excel',
url: '/statistics/trade/export-excel',
params: formatDateParam(params)
})
}
// 获得交易订单数量
export const getOrderCount = async () => {
return await request.get<TradeOrderCountRespVO>({ url: `/statistics/trade/order-count` })
}
// 获得交易订单数量对照
export const getOrderComparison = async () => {
return await request.get<DataComparisonRespVO<TradeOrderSummaryRespVO>>({
url: `/statistics/trade/order-comparison`
})
}
// 获得订单量趋势统计
export const getOrderCountTrendComparison = (
type: number,
beginTime: dayjs.ConfigType,
endTime: dayjs.ConfigType
) => {
return request.get<DataComparisonRespVO<TradeOrderTrendRespVO>[]>({
url: '/statistics/trade/order-count-trend',
params: { type, beginTime: formatDate(beginTime), endTime: formatDate(endTime) }
})
}
/** 时间参数需要格式化, 确保接口能识别 */
const formatDateParam = (params: TradeTrendReqVO) => {
return { times: [formatDate(params.times[0]), formatDate(params.times[1])] } as TradeTrendReqVO

View File

@ -0,0 +1,89 @@
<template>
<div class="flex flex-row items-center gap-2">
<el-radio-group v-model="shortcutDays" @change="handleShortcutDaysChange">
<el-radio-button :label="1">昨天</el-radio-button>
<el-radio-button :label="7">最近7天</el-radio-button>
<el-radio-button :label="30">最近30天</el-radio-button>
</el-radio-group>
<el-date-picker
v-model="times"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
:shortcuts="shortcuts"
class="!w-240px"
@change="emitDateRangePicker"
/>
<slot></slot>
</div>
</template>
<script lang="ts" setup>
import dayjs from 'dayjs'
import * as DateUtil from '@/utils/formatTime'
/** 快捷日期范围选择组件 */
defineOptions({ name: 'ShortcutDateRangePicker' })
const shortcutDays = ref(7) // , 7
const times = ref<[dayjs.ConfigType, dayjs.ConfigType]>(['', '']) //
defineExpose({ times }) //
/** 日期快捷选择 */
const shortcuts = [
{
text: '昨天',
value: () => DateUtil.getDayRange(new Date(), -1)
},
{
text: '最近7天',
value: () => DateUtil.getLast7Days()
},
{
text: '本月',
value: () => [dayjs().startOf('M'), dayjs().subtract(1, 'd')]
},
{
text: '最近30天',
value: () => DateUtil.getLast30Days()
},
{
text: '最近1年',
value: () => DateUtil.getLast1Year()
}
]
/** 设置时间范围 */
function setTimes() {
const beginDate = dayjs().subtract(shortcutDays.value, 'd')
const yesterday = dayjs().subtract(1, 'd')
times.value = DateUtil.getDateRange(beginDate, yesterday)
}
/** 快捷日期单选按钮选中 */
const handleShortcutDaysChange = async () => {
//
setTimes()
//
await emitDateRangePicker()
}
/** 触发事件:时间范围选中 */
const emits = defineEmits<{
(e: 'change', times: [dayjs.ConfigType, dayjs.ConfigType]): void
}>()
/** 触发时间范围选中事件 */
const emitDateRangePicker = async () => {
// , 线,
if (DateUtil.isSameDay(times.value[0], times.value[1])) {
//
times.value[0] = DateUtil.formatDate(dayjs(times.value[0]).subtract(1, 'd'))
}
emits('change', times.value)
}
/** 初始化 **/
onMounted(() => {
handleShortcutDaysChange()
})
</script>

View File

@ -233,3 +233,16 @@ export const yuanToFen = (amount: string | number): number => {
export const fenToYuan = (price: string | number): number => {
return formatToFraction(price)
}
/**
*
*
* @param value
* @param reference
*/
export const calculateRelativeRate = (value?: number, reference?: number) => {
// 防止除0
if (!reference) return 0
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
}

View File

@ -0,0 +1,42 @@
<template>
<div class="flex flex-col gap-2 bg-[var(--el-bg-color-overlay)] p-6">
<div class="flex items-center justify-between text-gray-500">
<span>{{ title }}</span>
<el-tag>{{ tag }}</el-tag>
</div>
<div class="flex flex-row items-baseline justify-between">
<CountTo :prefix="prefix" :end-val="value" :decimals="decimals" class="text-3xl" />
<span :class="toNumber(percent) > 0 ? 'text-red-500' : 'text-green-500'">
{{ Math.abs(toNumber(percent)) }}%
<Icon :icon="toNumber(percent) > 0 ? 'ep:caret-top' : 'ep:caret-bottom'" class="!text-sm" />
</span>
</div>
<el-divider class="mb-1! mt-2!" />
<div class="flex flex-row items-center justify-between text-sm">
<span class="text-gray-500">昨日数据</span>
<span>{{ prefix || '' }}{{ reference }}</span>
</div>
</div>
</template>
<script lang="ts" setup>
import { propTypes } from '@/utils/propTypes'
import { toNumber } from 'lodash-es'
import { calculateRelativeRate } from '@/utils'
/** 交易对照卡片 */
defineOptions({ name: 'ComparisonCard' })
const props = defineProps({
title: propTypes.string.def('').isRequired,
tag: propTypes.string.def(''),
prefix: propTypes.string.def(''),
value: propTypes.number.def(0).isRequired,
reference: propTypes.number.def(0).isRequired,
decimals: propTypes.number.def(0)
})
//
const percent = computed(() =>
calculateRelativeRate(props.value as number, props.reference as number)
)
</script>

View File

@ -0,0 +1,91 @@
<template>
<el-card shadow="never">
<template #header>
<CardTitle title="用户统计" />
</template>
<!-- 折线图 -->
<Echart :height="300" :options="lineChartOptions" />
</el-card>
</template>
<script lang="ts" setup>
import dayjs from 'dayjs'
import { EChartsOption } from 'echarts'
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
import { formatDate } from '@/utils/formatTime'
import { CardTitle } from '@/components/Card'
/** 会员用户统计卡片 */
defineOptions({ name: 'MemberStatisticsCard' })
const loading = ref(true) //
/** 折线图配置 */
const lineChartOptions = reactive<EChartsOption>({
dataset: {
dimensions: ['date', 'count'],
source: []
},
grid: {
left: 20,
right: 20,
bottom: 20,
top: 80,
containLabel: true
},
legend: {
top: 50
},
series: [{ name: '注册量', type: 'line', smooth: true, areaStyle: {} }],
toolbox: {
feature: {
//
dataZoom: {
yAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '会员统计' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
padding: [5, 10]
},
xAxis: {
type: 'category',
boundaryGap: false,
axisTick: {
show: false
},
axisLabel: {
formatter: (date: string) => formatDate(date, 'MM-DD')
}
},
yAxis: {
axisTick: {
show: false
}
}
}) as EChartsOption
const getMemberRegisterCountList = async () => {
loading.value = true
//
const beginTime = dayjs().subtract(30, 'd').startOf('d')
const endTime = dayjs().endOf('d')
const list = await MemberStatisticsApi.getMemberRegisterCountList(beginTime, endTime)
// Echarts
if (lineChartOptions.dataset && lineChartOptions.dataset['source']) {
lineChartOptions.dataset['source'] = list
}
loading.value = false
}
/** 初始化 **/
onMounted(() => {
getMemberRegisterCountList()
})
</script>

View File

@ -0,0 +1,91 @@
<template>
<el-card shadow="never">
<template #header>
<CardTitle title="运营数据" />
</template>
<div class="flex flex-row flex-wrap items-center gap-8 p-4">
<div
v-for="item in data"
:key="item.name"
class="h-20 w-20% flex flex-col cursor-pointer items-center justify-center gap-2"
@click="handleClick(item.routerName)"
>
<CountTo
:prefix="item.prefix"
:end-val="item.value"
:decimals="item.decimals"
class="text-3xl"
/>
<span class="text-center">{{ item.name }}</span>
</div>
</div>
</el-card>
</template>
<script lang="ts" setup>
import * as ProductSpuApi from '@/api/mall/product/spu'
import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
import * as PayStatisticsApi from '@/api/mall/statistics/pay'
import { CardTitle } from '@/components/Card'
/** 运营数据卡片 */
defineOptions({ name: 'OperationDataCard' })
const router = useRouter() //
/** 数据 */
const data = reactive({
orderUndelivered: { name: '待发货订单', value: 9, routerName: 'TradeOrder' },
orderAfterSaleApply: { name: '退款中订单', value: 4, routerName: 'TradeAfterSale' },
orderWaitePickUp: { name: '待核销订单', value: 0, routerName: 'TradeOrder' },
productAlertStock: { name: '库存预警', value: 0, routerName: 'ProductSpu' },
productForSale: { name: '上架商品', value: 0, routerName: 'ProductSpu' },
productInWarehouse: { name: '仓库商品', value: 0, routerName: 'ProductSpu' },
withdrawAuditing: { name: '提现待审核', value: 0, routerName: 'TradeBrokerageWithdraw' },
rechargePrice: {
name: '账户充值',
value: 0.0,
prefix: '¥',
decimals: 2,
routerName: 'PayWalletRecharge'
}
})
/** 查询订单数据 */
const getOrderData = async () => {
const orderCount = await TradeStatisticsApi.getOrderCount()
data.orderUndelivered.value = orderCount.undelivered
data.orderAfterSaleApply.value = orderCount.afterSaleApply
data.orderWaitePickUp.value = orderCount.pickUp
data.withdrawAuditing.value = orderCount.auditingWithdraw
}
/** 查询商品数据 */
const getProductData = async () => {
// TODO: @
const productCount = await ProductSpuApi.getTabsCount()
data.productForSale.value = productCount['0']
data.productInWarehouse.value = productCount['1']
data.productAlertStock.value = productCount['3']
}
/** 查询钱包充值数据 */
const getWalletRechargeData = async () => {
data.rechargePrice.value = await PayStatisticsApi.getWalletRechargePrice()
}
/**
* 跳转到对应页面
*
* @param routerName 路由页面组件的名称
*/
const handleClick = (routerName: string) => {
router.push({ name: routerName })
}
/** 初始化 **/
onMounted(() => {
getOrderData()
getProductData()
getWalletRechargeData()
})
</script>

View File

@ -0,0 +1,79 @@
<template>
<el-card shadow="never">
<template #header>
<CardTitle title="快捷入口" />
</template>
<div class="flex flex-row flex-wrap gap-8 p-4">
<div
v-for="menu in menuList"
:key="menu.name"
class="h-20 w-20% flex flex-col cursor-pointer items-center justify-center gap-2"
@click="handleMenuClick(menu.routerName)"
>
<div :class="menu.bgColor" class="rounded p-3 text-white">
<Icon :icon="menu.icon" class="text-7.5!" />
</div>
<span>{{ menu.name }}</span>
</div>
</div>
</el-card>
</template>
<script lang="ts" setup>
/** 快捷入口卡片 */
import { CardTitle } from '@/components/Card'
defineOptions({ name: 'ShortcutCard' })
const router = useRouter() //
/** 菜单列表 */
const menuList = [
{ name: '用户管理', icon: 'ep:user-filled', bgColor: 'bg-red-400', routerName: 'MemberUser' },
{
name: '商品管理',
icon: 'fluent-mdl2:product',
bgColor: 'bg-orange-400',
routerName: 'ProductSpu'
},
{ name: '订单管理', icon: 'ep:list', bgColor: 'bg-yellow-500', routerName: 'TradeOrder' },
{
name: '售后管理',
icon: 'ri:refund-2-line',
bgColor: 'bg-green-600',
routerName: 'TradeAfterSale'
},
{
name: '分销管理',
icon: 'fa-solid:project-diagram',
bgColor: 'bg-cyan-500',
routerName: 'TradeBrokerageUser'
},
{
name: '优惠券',
icon: 'ep:ticket',
bgColor: 'bg-blue-500',
routerName: 'PromotionCoupon'
},
{
name: '拼团活动',
icon: 'fa:group',
bgColor: 'bg-purple-500',
routerName: 'PromotionBargainActivity'
},
{
name: '佣金提现',
icon: 'vaadin:money-withdraw',
bgColor: 'bg-rose-500',
routerName: 'TradeBrokerageWithdraw'
}
]
/**
* 跳转到菜单对应页面
*
* @param routerName 路由页面组件的名称
*/
const handleMenuClick = (routerName: string) => {
router.push({ name: routerName })
}
</script>

View File

@ -0,0 +1,208 @@
<template>
<el-card shadow="never">
<template #header>
<div class="flex flex-row items-center justify-between">
<CardTitle title="交易量趋势" />
<!-- 查询条件 -->
<div class="flex flex-row items-center gap-2">
<el-radio-group v-model="timeRangeType" @change="handleTimeRangeTypeChange">
<el-radio-button v-for="[key, value] in timeRange.entries()" :key="key" :label="key">
{{ value.name }}
</el-radio-button>
</el-radio-group>
</div>
</div>
</template>
<!-- 折线图 -->
<Echart :height="300" :options="eChartOptions" />
</el-card>
</template>
<script lang="ts" setup>
import dayjs, { Dayjs } from 'dayjs'
import { EChartsOption } from 'echarts'
import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
import { fenToYuan } from '@/utils'
import { formatDate } from '@/utils/formatTime'
import { CardTitle } from '@/components/Card'
/** 交易量趋势 */
defineOptions({ name: 'TradeTrendCard' })
enum TimeRangeTypeEnum {
DAY30 = 1,
WEEK = 7,
MONTH = 30,
YEAR = 365
} //
const timeRangeType = ref(TimeRangeTypeEnum.DAY30) // , 30
const loading = ref(true) //
// Map
const timeRange = new Map()
.set(TimeRangeTypeEnum.DAY30, {
name: '30天',
series: [
{ name: '订单金额', type: 'bar', smooth: true, data: [] },
{ name: '订单数量', type: 'line', smooth: true, data: [] }
]
})
.set(TimeRangeTypeEnum.WEEK, {
name: '周',
series: [
{ name: '上周金额', type: 'bar', smooth: true, data: [] },
{ name: '本周金额', type: 'bar', smooth: true, data: [] },
{ name: '上周数量', type: 'line', smooth: true, data: [] },
{ name: '本周数量', type: 'line', smooth: true, data: [] }
]
})
.set(TimeRangeTypeEnum.MONTH, {
name: '月',
series: [
{ name: '上月金额', type: 'bar', smooth: true, data: [] },
{ name: '本月金额', type: 'bar', smooth: true, data: [] },
{ name: '上月数量', type: 'line', smooth: true, data: [] },
{ name: '本月数量', type: 'line', smooth: true, data: [] }
]
})
.set(TimeRangeTypeEnum.YEAR, {
name: '年',
series: [
{ name: '去年金额', type: 'bar', smooth: true, data: [] },
{ name: '今年金额', type: 'bar', smooth: true, data: [] },
{ name: '去年数量', type: 'line', smooth: true, data: [] },
{ name: '今年数量', type: 'line', smooth: true, data: [] }
]
})
/** 图表配置 */
const eChartOptions = reactive<EChartsOption>({
grid: {
left: 20,
right: 20,
bottom: 20,
top: 80,
containLabel: true
},
legend: {
top: 50,
data: []
},
series: [],
toolbox: {
feature: {
//
dataZoom: {
yAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '订单量趋势' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
padding: [5, 10]
},
xAxis: {
type: 'category',
inverse: true,
boundaryGap: false,
axisTick: {
show: false
},
data: [],
axisLabel: {
formatter: (date: string) => {
switch (timeRangeType.value) {
case TimeRangeTypeEnum.DAY30:
return formatDate(date, 'MM-DD')
case TimeRangeTypeEnum.WEEK:
let weekDay = formatDate(date, 'ddd')
if (weekDay == '0') weekDay = '日'
return '周' + weekDay
case TimeRangeTypeEnum.MONTH:
return formatDate(date, 'D')
case TimeRangeTypeEnum.YEAR:
return formatDate(date, 'M') + '月'
default:
return date
}
}
}
},
yAxis: {
axisTick: {
show: false
}
}
}) as EChartsOption
/** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => {
//
let beginTime: Dayjs
let endTime: Dayjs
switch (timeRangeType.value) {
case TimeRangeTypeEnum.WEEK:
beginTime = dayjs().startOf('week')
endTime = dayjs().endOf('week')
break
case TimeRangeTypeEnum.MONTH:
beginTime = dayjs().startOf('month')
endTime = dayjs().endOf('month')
break
case TimeRangeTypeEnum.YEAR:
beginTime = dayjs().startOf('year')
endTime = dayjs().endOf('year')
break
case TimeRangeTypeEnum.DAY30:
default:
beginTime = dayjs().subtract(30, 'day').startOf('d')
endTime = dayjs().endOf('d')
break
}
//
await getOrderCountTrendComparison(beginTime, endTime)
}
/** 查询订单数量趋势对照数据 */
const getOrderCountTrendComparison = async (
beginTime: dayjs.ConfigType,
endTime: dayjs.ConfigType
) => {
loading.value = true
//
const list = await TradeStatisticsApi.getOrderCountTrendComparison(
timeRangeType.value,
beginTime,
endTime
)
//
const dates: string[] = []
const series = [...timeRange.get(timeRangeType.value).series]
for (let item of list) {
dates.push(item.value.date)
if (series.length === 2) {
series[0].data.push(fenToYuan(item?.value?.orderPayPrice || 0)) //
series[1].data.push(fenToYuan(item?.value?.orderPayCount || 0)) //
} else {
series[0].data.push(fenToYuan(item?.reference?.orderPayPrice || 0)) //
series[1].data.push(fenToYuan(item?.value?.orderPayPrice || 0)) //
series[2].data.push(item?.reference?.orderPayCount || 0) //
series[3].data.push(item?.value?.orderPayCount || 0) //
}
}
eChartOptions.xAxis!['data'] = dates
eChartOptions.series = series
// legend424
eChartOptions.legend['data'] = series.map((item) => item.name)
loading.value = false
}
/** 初始化 **/
onMounted(() => {
handleTimeRangeTypeChange()
})
</script>

View File

@ -0,0 +1,111 @@
<template>
<div class="flex flex-col">
<!-- 数据对照 -->
<el-row :gutter="16" class="row">
<el-col :md="6" :sm="12" :xs="24" :loading="loading">
<ComparisonCard
tag="今日"
title="销售额"
prefix="¥"
::decimals="2"
:value="fenToYuan(orderComparison?.value?.orderPayPrice || 0)"
:reference="fenToYuan(orderComparison?.reference?.orderPayPrice || 0)"
/>
</el-col>
<el-col :md="6" :sm="12" :xs="24" :loading="loading">
<ComparisonCard
tag="今日"
title="用户访问量"
:value="userComparison?.value?.visitUserCount || 0"
:reference="userComparison?.reference?.visitUserCount || 0"
/>
</el-col>
<el-col :md="6" :sm="12" :xs="24" :loading="loading">
<ComparisonCard
tag="今日"
title="订单量"
:value="fenToYuan(orderComparison?.value?.orderPayCount || 0)"
:reference="fenToYuan(orderComparison?.reference?.orderPayCount || 0)"
/>
</el-col>
<el-col :md="6" :sm="12" :xs="24" :loading="loading">
<ComparisonCard
tag="今日"
title="新增用户"
:value="userComparison?.value?.createUserCount || 0"
:reference="userComparison?.reference?.createUserCount || 0"
/>
</el-col>
</el-row>
<el-row :gutter="16" class="row">
<el-col :md="12">
<!-- 快捷入口 -->
<ShortcutCard />
</el-col>
<el-col :md="12">
<!-- 运营数据 -->
<OperationDataCard />
</el-col>
</el-row>
<el-row :gutter="16" class="mb-4">
<el-col :md="18" :sm="24">
<!-- 会员概览 -->
<MemberFunnelCard />
</el-col>
<el-col :md="6" :sm="24">
<!-- 会员终端 -->
<MemberTerminalCard />
</el-col>
</el-row>
<!-- 交易量趋势 -->
<TradeTrendCard class="mb-4" />
<!-- 会员统计 -->
<MemberStatisticsCard />
</div>
</template>
<script lang="ts" setup>
import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
import { TradeOrderSummaryRespVO } from '@/api/mall/statistics/trade'
import { MemberCountRespVO } from '@/api/mall/statistics/member'
import { fenToYuan } from '@/utils'
import ComparisonCard from './components/ComparisonCard.vue'
import MemberStatisticsCard from './components/MemberStatisticsCard.vue'
import OperationDataCard from './components/OperationDataCard.vue'
import ShortcutCard from './components/ShortcutCard.vue'
import TradeTrendCard from './components/TradeTrendCard.vue'
import MemberTerminalCard from '@/views/mall/statistics/member/components/MemberTerminalCard.vue'
import MemberFunnelCard from '@/views/mall/statistics/member/components/MemberFunnelCard.vue'
/** 商城首页 */
defineOptions({ name: 'MallHome' })
const loading = ref(true) //
const orderComparison = ref<DataComparisonRespVO<TradeOrderSummaryRespVO>>() //
const userComparison = ref<DataComparisonRespVO<MemberCountRespVO>>() //
/** 查询交易对照卡片数据 */
const getOrderComparison = async () => {
orderComparison.value = await TradeStatisticsApi.getOrderComparison()
}
/** 查询会员用户数量对照卡片数据 */
const getUserCountComparison = async () => {
userComparison.value = await MemberStatisticsApi.getUserCountComparison()
}
/** 初始化 **/
onMounted(async () => {
loading.value = true
await Promise.all([getOrderComparison(), getUserCountComparison()])
loading.value = false
})
</script>
<style lang="scss" scoped>
.row {
.el-col {
margin-bottom: 1rem;
}
}
</style>

View File

@ -0,0 +1,238 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle" width="70%">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="110px"
>
<el-row>
<el-col :span="12">
<el-form-item label="文章标题" prop="title">
<el-input v-model="formData.title" placeholder="请输入文章标题" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="文章分类" prop="categoryId">
<el-select v-model="formData.categoryId" placeholder="请选择">
<el-option
v-for="item in categoryList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="文章作者" prop="author">
<el-input v-model="formData.author" placeholder="请输入文章作者" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="文章简介" prop="introduction">
<el-input v-model="formData.introduction" placeholder="请输入文章简介" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="文章封面" prop="picUrl">
<UploadImg v-model="formData.picUrl" height="80px" />
</el-form-item>
</el-col>
<!-- TODO @puhui999浏览次数不能修改 -->
<el-col :span="12">
<el-form-item label="浏览次数" prop="browseCount">
<el-input-number
v-model="formData.browseCount"
:min="0"
clearable
controls-position="right"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序" prop="sort">
<el-input-number v-model="formData.sort" :min="0" clearable controls-position="right" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<!-- TODO @puhui999可以使用 SpuTableSelect -->
<el-col :span="12">
<el-form-item label="商品关联" prop="spuId">
<el-select v-model="formData.spuId" placeholder="请选择">
<el-option
v-for="item in spuList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否热门" prop="recommendHot">
<el-radio-group v-model="formData.recommendHot">
<el-radio
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否轮播图" prop="recommendBanner">
<el-radio-group v-model="formData.recommendBanner">
<el-radio
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="文章内容">
<Editor v-model="formData.content" height="150px" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
import * as ArticleApi from '@/api/mall/promotion/article'
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
import * as ProductSpuApi from '@/api/mall/product/spu'
defineOptions({ name: 'PromotionArticleForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
categoryId: undefined,
title: undefined,
author: undefined,
picUrl: undefined,
introduction: undefined,
browseCount: 0,
sort: 0,
status: 0,
spuId: undefined,
recommendHot: false,
recommendBanner: false,
content: undefined
})
const formRules = reactive({
categoryId: [{ required: true, message: '分类id不能为空', trigger: 'blur' }],
title: [{ required: true, message: '文章标题不能为空', trigger: 'blur' }],
picUrl: [{ required: true, message: '文章封面图片地址不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
spuId: [{ required: true, message: '商品关联id不能为空', trigger: 'blur' }],
recommendHot: [{ required: true, message: '是否热门(小程序)不能为空', trigger: 'blur' }],
recommendBanner: [{ required: true, message: '是否轮播图(小程序)不能为空', trigger: 'blur' }],
content: [{ required: true, message: '文章内容不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await ArticleApi.getArticle(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as ArticleApi.ArticleVO
if (formType.value === 'create') {
await ArticleApi.createArticle(data)
message.success(t('common.createSuccess'))
} else {
await ArticleApi.updateArticle(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
categoryId: undefined,
title: undefined,
author: undefined,
picUrl: undefined,
introduction: undefined,
browseCount: 0,
sort: 0,
status: 0,
spuId: undefined,
recommendHot: false,
recommendBanner: false,
content: undefined
}
formRef.value?.resetFields()
}
const categoryList = ref<ArticleCategoryApi.ArticleCategoryVO[]>([])
const spuList = ref<ProductSpuApi.Spu[]>([])
onMounted(async () => {
categoryList.value =
(await ArticleCategoryApi.getSimpleArticleCategoryList()) as ArticleCategoryApi.ArticleCategoryVO[]
spuList.value = (await ProductSpuApi.getSpuSimpleList()) as ProductSpuApi.Spu[]
})
</script>

View File

@ -0,0 +1,120 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="100px"
>
<el-form-item label="分类名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="图标地址" prop="picUrl">
<UploadImg v-model="formData.picUrl" height="80px" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input-number v-model="formData.sort" :min="0" clearable controls-position="right" />
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
import { CommonStatusEnum } from '@/utils/constants'
defineOptions({ name: 'PromotionArticleCategoryForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
name: undefined,
picUrl: undefined,
status: undefined,
sort: undefined
})
const formRules = reactive({
name: [{ required: true, message: '分类名称不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await ArticleCategoryApi.getArticleCategory(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as ArticleCategoryApi.ArticleCategoryVO
if (formType.value === 'create') {
await ArticleCategoryApi.createArticleCategory(data)
message.success(t('common.createSuccess'))
} else {
await ArticleCategoryApi.updateArticleCategory(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
picUrl: undefined,
status: CommonStatusEnum.ENABLE,
sort: 0
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,199 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="分类名称" prop="name">
<el-input
v-model="queryParams.name"
class="!w-240px"
clearable
placeholder="请输入分类名称"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button
v-hasPermi="['promotion:article-category:create']"
plain
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" min-width="100" />
<el-table-column align="center" label="分类名称" prop="name" min-width="240" />
<el-table-column label="分类图图" min-width="80">
<template #default="{ row }">
<el-image :src="row.picUrl" class="h-30px w-30px" @click="imagePreview(row.picUrl)" />
</template>
</el-table-column>
<el-table-column align="center" label="状态" prop="status" min-width="150">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column align="center" label="排序" prop="sort" min-width="150" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="操作">
<template #default="scope">
<el-button
v-hasPermi="['promotion:article-category:update']"
link
type="primary"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['promotion:article-category:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<ArticleCategoryForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
import ArticleCategoryForm from './ArticleCategoryForm.vue'
import { createImageViewer } from '@/components/ImageViewer'
defineOptions({ name: 'PromotionArticleCategory' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
status: null,
createTime: []
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 分类图预览 */
const imagePreview = (imgUrl: string) => {
createImageViewer({
urlList: [imgUrl]
})
}
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ArticleCategoryApi.getArticleCategoryPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ArticleCategoryApi.deleteArticleCategory(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -0,0 +1,229 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="80px"
>
<el-form-item label="文章分类" prop="categoryId">
<el-select
v-model="queryParams.categoryId"
class="!w-240px"
placeholder="全部"
@keyup.enter="handleQuery"
>
<el-option
v-for="item in categoryList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="文章标题" prop="title">
<el-input
v-model="queryParams.title"
class="!w-240px"
clearable
placeholder="请输入文章标题"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button
v-hasPermi="['promotion:article:create']"
plain
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" min-width="60" />
<el-table-column align="center" label="封面" prop="picUrl" min-width="80">
<template #default="{ row }">
<el-image :src="row.picUrl" class="h-30px w-30px" @click="imagePreview(row.picUrl)" />
</template>
</el-table-column>
<el-table-column align="center" label="标题" prop="title" min-width="180" />
<el-table-column align="center" label="分类" prop="categoryId" min-width="180">
<template #default="scope">
{{ categoryList.find((item) => item.id === scope.row.categoryId)?.name }}
</template>
</el-table-column>
<el-table-column align="center" label="浏览量" prop="browseCount" min-width="180" />
<el-table-column align="center" label="作者" prop="author" min-width="180" />
<el-table-column align="center" label="文章简介" prop="introduction" min-width="250" />
<el-table-column align="center" label="排序" prop="sort" min-width="60" />
<el-table-column align="center" label="状态" prop="status" min-width="60">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="发布时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" fixed="right" label="操作" width="120">
<template #default="scope">
<el-button
v-hasPermi="['promotion:article:update']"
link
type="primary"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['promotion:article:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<ArticleForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as ArticleApi from '@/api/mall/promotion/article'
import ArticleForm from './ArticleForm.vue'
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
import * as ProductSpuApi from '@/api/mall/product/spu'
import { createImageViewer } from '@/components/ImageViewer'
defineOptions({ name: 'PromotionArticle' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
categoryId: undefined,
title: null,
status: undefined,
spuId: undefined,
createTime: []
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 文章封面预览 */
const imagePreview = (imgUrl: string) => {
createImageViewer({
urlList: [imgUrl]
})
}
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ArticleApi.getArticlePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ArticleApi.deleteArticle(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
const categoryList = ref<ArticleCategoryApi.ArticleCategoryVO[]>([])
const spuList = ref<ProductSpuApi.Spu[]>([])
onMounted(async () => {
await getList()
//
categoryList.value =
(await ArticleCategoryApi.getSimpleArticleCategoryList()) as ArticleCategoryApi.ArticleCategoryVO[]
spuList.value = (await ProductSpuApi.getSpuSimpleList()) as ProductSpuApi.Spu[]
})
</script>

View File

@ -0,0 +1,119 @@
<template>
<el-card shadow="never">
<template #header>
<div class="my--1.5 flex flex-row items-center justify-between">
<CardTitle title="会员概览" />
<!-- 查询条件 -->
<ShortcutDateRangePicker @change="handleTimeRangeChange" />
</div>
</template>
<div class="min-w-225 py-1.75" v-loading="loading">
<div class="relative h-24 flex">
<div class="h-full w-75% bg-blue-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-col justify-center">
<div class="font-bold">
注册用户数量{{ analyseData?.comparison?.value?.registerUserCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.registerUserCount,
analyseData?.comparison?.reference?.registerUserCount
)
}}%
</div>
</div>
</div>
<div
class="trapezoid1 ml--38.5 mt-1.5 h-full w-77 flex flex-col items-center justify-center bg-blue-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.visitUserCount || 0 }}</span>
<span>访客</span>
</div>
</div>
<div class="relative h-24 flex">
<div class="h-full w-75% flex bg-cyan-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-col justify-center">
<div class="font-bold">
活跃用户数量{{ analyseData?.comparison?.value?.visitUserCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.visitUserCount,
analyseData?.comparison?.reference?.visitUserCount
)
}}%
</div>
</div>
</div>
<div
class="trapezoid2 ml--28 mt-1.7 h-25 w-56 flex flex-col items-center justify-center bg-cyan-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.orderUserCount || 0 }}</span>
<span>下单</span>
</div>
</div>
<div class="relative h-24 flex">
<div class="w-75% flex bg-slate-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-row gap-x-16">
<div class="flex flex-col justify-center">
<div class="font-bold">
充值用户数量{{ analyseData?.comparison?.value?.rechargeUserCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.rechargeUserCount,
analyseData?.comparison?.reference?.rechargeUserCount
)
}}%
</div>
</div>
<div class="flex flex-col justify-center">
<div class="font-bold">客单价{{ fenToYuan(analyseData?.atv || 0) }}</div>
</div>
</div>
</div>
<div
class="trapezoid3 ml--18 mt-3.25 h-23 w-36 flex flex-col items-center justify-center bg-slate-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.payUserCount || 0 }}</span>
<span>成交用户</span>
</div>
</div>
</div>
</el-card>
</template>
<script lang="ts" setup>
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
import dayjs from 'dayjs'
import { calculateRelativeRate, fenToYuan } from '@/utils'
import { MemberAnalyseRespVO } from '@/api/mall/statistics/member'
import { CardTitle } from '@/components/Card'
/** 会员概览卡片 */
defineOptions({ name: 'MemberFunnelCard' })
const loading = ref(true) //
const analyseData = ref<MemberAnalyseRespVO>() //
/** 查询会员概览数据列表 */
const handleTimeRangeChange = async (times: [dayjs.ConfigType, dayjs.ConfigType]) => {
loading.value = true
//
analyseData.value = await MemberStatisticsApi.getMemberAnalyse({ times })
loading.value = false
}
</script>
<style lang="scss" scoped>
.trapezoid1 {
transform: perspective(5em) rotateX(-11deg);
}
.trapezoid2 {
transform: perspective(7em) rotateX(-20deg);
}
.trapezoid3 {
transform: perspective(3em) rotateX(-13deg);
}
</style>

View File

@ -0,0 +1,69 @@
<template>
<el-card shadow="never" v-loading="loading">
<template #header>
<CardTitle title="会员终端" />
</template>
<Echart :height="300" :options="terminalChartOptions" />
</el-card>
</template>
<script lang="ts" setup>
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
import { EChartsOption } from 'echarts'
import { MemberTerminalStatisticsRespVO } from '@/api/mall/statistics/member'
import { DICT_TYPE, DictDataType, getIntDictOptions } from '@/utils/dict'
import { CardTitle } from '@/components/Card'
/** 会员终端卡片 */
defineOptions({ name: 'MemberTerminalCard' })
const loading = ref(true) //
/** 会员终端统计图配置 */
const terminalChartOptions = reactive<EChartsOption>({
tooltip: {
trigger: 'item',
confine: true,
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
orient: 'vertical',
left: 'right'
},
roseType: 'area',
series: [
{
name: '会员终端',
type: 'pie',
label: {
show: false
},
labelLine: {
show: false
},
data: []
}
]
}) as EChartsOption
/** 按照终端,查询会员统计列表 */
const getMemberTerminalStatisticsList = async () => {
loading.value = true
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList()
const dictDataList = getIntDictOptions(DICT_TYPE.TERMINAL)
terminalChartOptions.series![0].data = dictDataList.map((dictData: DictDataType) => {
const userCount = list.find(
(item: MemberTerminalStatisticsRespVO) => item.terminal === dictData.value
)?.userCount
return {
name: dictData.label,
value: userCount || 0
}
})
loading.value = false
}
/** 初始化 **/
onMounted(() => {
getMemberTerminalStatisticsList()
})
</script>

View File

@ -44,118 +44,20 @@
</el-row>
<el-row :gutter="16" class="mb-4">
<el-col :md="18" :sm="24">
<el-card shadow="never">
<template #header>
<div class="flex flex-row items-center justify-between">
<span>会员概览</span>
<!-- 查询条件 -->
<div class="my--2 flex flex-row items-center gap-2">
<el-radio-group v-model="shortcutDays" @change="handleDateTypeChange">
<el-radio-button :label="1">昨天</el-radio-button>
<el-radio-button :label="7">最近7天</el-radio-button>
<el-radio-button :label="30">最近30天</el-radio-button>
</el-radio-group>
<el-date-picker
v-model="queryParams.times"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
:shortcuts="shortcuts"
class="!w-240px"
@change="getMemberAnalyse"
/>
</div>
</div>
</template>
<div class="min-w-225 py-1.75" v-loading="analyseLoading">
<div class="relative h-24 flex">
<div class="h-full w-75% bg-blue-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-col justify-center">
<div class="font-bold">
注册用户数量{{ analyseData?.comparison?.value?.userCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.userCount,
analyseData?.comparison?.reference?.userCount
)
}}%
</div>
</div>
</div>
<div
class="trapezoid1 ml--38.5 mt-1.5 h-full w-77 flex flex-col items-center justify-center bg-blue-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.visitorCount || 0 }}</span>
<span>访客</span>
</div>
</div>
<div class="relative h-24 flex">
<div class="h-full w-75% flex bg-cyan-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-col justify-center">
<div class="font-bold">
活跃用户数量{{ analyseData?.comparison?.value?.activeUserCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.activeUserCount,
analyseData?.comparison?.reference?.activeUserCount
)
}}%
</div>
</div>
</div>
<div
class="trapezoid2 ml--28 mt-1.7 h-25 w-56 flex flex-col items-center justify-center bg-cyan-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.orderUserCount || 0 }}</span>
<span>下单</span>
</div>
</div>
<div class="relative h-24 flex">
<div class="w-75% flex bg-slate-50 <lg:w-35% <xl:w-55%">
<div class="ml-15 h-full flex flex-row gap-x-16">
<div class="flex flex-col justify-center">
<div class="font-bold">
充值用户数量{{ analyseData?.comparison?.value?.rechargeUserCount || 0 }}
</div>
<div class="mt-2 text-3.5">
环比增长率{{
calculateRelativeRate(
analyseData?.comparison?.value?.rechargeUserCount,
analyseData?.comparison?.reference?.rechargeUserCount
)
}}%
</div>
</div>
<div class="flex flex-col justify-center">
<div class="font-bold">客单价{{ fenToYuan(analyseData?.atv || 0) }}</div>
</div>
</div>
</div>
<div
class="trapezoid3 ml--18 mt-3.25 h-23 w-36 flex flex-col items-center justify-center bg-slate-5 text-3.5 text-white"
>
<span class="text-6 font-bold">{{ analyseData?.payUserCount || 0 }}</span>
<span>成交用户</span>
</div>
</div>
</div>
</el-card>
<!-- 会员概览 -->
<MemberFunnelCard />
</el-col>
<el-col :md="6" :sm="24">
<el-card shadow="never" header="会员终端" v-loading="loading">
<Echart :height="300" :options="terminalChartOptions" />
</el-card>
<!-- 会员终端 -->
<MemberTerminalCard />
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :md="18" :sm="24">
<el-card shadow="never" header="会员地域分布">
<el-card shadow="never">
<template #header>
<CardTitle title="会员地域分布" />
</template>
<el-row v-loading="loading">
<el-col :span="10">
<Echart :height="300" :options="areaChartOptions" />
@ -180,14 +82,14 @@
/>
<el-table-column
label="订单创建数量"
prop="orderCreateCount"
prop="orderCreateUserCount"
align="center"
min-width="135"
sortable
/>
<el-table-column
label="订单支付数量"
prop="orderPayCount"
prop="orderPayUserCount"
align="center"
min-width="135"
sortable
@ -206,7 +108,10 @@
</el-card>
</el-col>
<el-col :md="6" :sm="24">
<el-card shadow="never" header="会员性别比例" v-loading="loading">
<el-card shadow="never" v-loading="loading">
<template #header>
<CardTitle title="会员性别比例" />
</template>
<Echart :height="300" :options="sexChartOptions" />
</el-card>
</el-col>
@ -214,62 +119,33 @@
</div>
</template>
<script lang="ts" setup>
import * as TradeMemberApi from '@/api/mall/statistics/member'
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
import TradeTrendValue from '../trade/components/TradeTrendValue.vue'
import { EChartsOption } from 'echarts'
import china from '@/assets/map/json/china.json'
import dayjs from 'dayjs'
import { fenToYuan } from '@/utils'
import * as DateUtil from '@/utils/formatTime'
import {
MemberAnalyseRespVO,
MemberAreaStatisticsRespVO,
MemberSexStatisticsRespVO,
MemberAnalyseReqVO,
MemberSummaryRespVO,
MemberTerminalStatisticsRespVO
} from '@/api/mall/statistics/member'
import { DICT_TYPE, DictDataType, getIntDictOptions } from '@/utils/dict'
import echarts from '@/plugins/echarts'
import { fenToYuanFormat } from '@/utils/formatter'
import MemberFunnelCard from './components/MemberFunnelCard.vue'
import MemberTerminalCard from './components/MemberTerminalCard.vue'
import { CardTitle } from '@/components/Card'
/** 会员统计 */
defineOptions({ name: 'MemberStatistics' })
const loading = ref(true) //
const analyseLoading = ref(true) //
const queryParams = reactive<MemberAnalyseReqVO>({ times: ['', ''] }) //
const shortcutDays = ref(7) // , 7
const summary = ref<MemberSummaryRespVO>() //
const analyseData = ref<MemberAnalyseRespVO>() //
const areaStatisticsList = shallowRef<MemberAreaStatisticsRespVO[]>() //
//
echarts?.registerMap('china', china!)
/** 日期快捷选择 */
const shortcuts = [
{
text: '昨天',
value: () => DateUtil.getDayRange(new Date(), -1)
},
{
text: '最近7天',
value: () => DateUtil.getLast7Days()
},
{
text: '本月',
value: () => [dayjs().startOf('M'), dayjs().subtract(1, 'd')]
},
{
text: '最近30天',
value: () => DateUtil.getLast30Days()
},
{
text: '最近1年',
value: () => DateUtil.getLast1Year()
}
]
echarts?.registerMap('china', china as any)
/** 会员终端统计图配置 */
const terminalChartOptions = reactive<EChartsOption>({
@ -331,8 +207,8 @@ const areaChartOptions = reactive<EChartsOption>({
formatter: (params: any) => {
return `${params?.data?.areaName || params?.name}<br/>
会员数量${params?.data?.userCount || 0}<br/>
订单创建数量${params?.data?.orderCreateCount || 0}<br/>
订单支付数量${params?.data?.orderPayCount || 0}<br/>
订单创建数量${params?.data?.orderCreateUserCount || 0}<br/>
订单支付数量${params?.data?.orderPayUserCount || 0}<br/>
订单支付金额${fenToYuan(params?.data?.orderPayPrice || 0)}`
}
},
@ -357,37 +233,14 @@ const areaChartOptions = reactive<EChartsOption>({
]
}) as EChartsOption
/** 计算环比 */
const calculateRelativeRate = (value?: number, reference?: number) => {
// 0
if (!reference) return 0
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
}
/** 设置时间范围 */
function setTimes() {
const beginDate = dayjs().subtract(shortcutDays.value, 'd')
const yesterday = dayjs().subtract(1, 'd')
queryParams.times = DateUtil.getDateRange(beginDate, yesterday)
}
/** 处理会员概览查询(日期单选按钮组选择后) */
const handleDateTypeChange = async () => {
//
setTimes()
//
await getMemberAnalyse()
}
/** 查询会员统计 */
const getMemberSummary = async () => {
summary.value = await TradeMemberApi.getMemberSummary()
summary.value = await MemberStatisticsApi.getMemberSummary()
}
/** 按照省份,查询会员统计列表 */
const getMemberAreaStatisticsList = async () => {
const list = await TradeMemberApi.getMemberAreaStatisticsList()
const list = await MemberStatisticsApi.getMemberAreaStatisticsList()
areaStatisticsList.value = list.map((item: MemberAreaStatisticsRespVO) => {
return {
...item,
@ -401,20 +254,21 @@ const getMemberAreaStatisticsList = async () => {
})
let min = 0
let max = 0
areaChartOptions.series[0].data = areaStatisticsList.value.map((item) => {
min = Math.min(min, item.orderPayCount)
max = Math.max(max, item.orderPayCount)
return { ...item, name: item.areaName, value: item.orderPayCount || 0 }
areaChartOptions.series![0].data = areaStatisticsList.value.map((item) => {
min = Math.min(min, item.orderPayUserCount || 0)
max = Math.max(max, item.orderPayUserCount || 0)
return { ...item, name: item.areaName, value: item.orderPayUserCount || 0 }
})
areaChartOptions.visualMap.min = min
areaChartOptions.visualMap.max = max
areaChartOptions.visualMap!['min'] = min
areaChartOptions.visualMap!['max'] = max
}
/** 按照性别,查询会员统计列表 */
const getMemberSexStatisticsList = async () => {
const list = await TradeMemberApi.getMemberSexStatisticsList()
const list = await MemberStatisticsApi.getMemberSexStatisticsList()
const dictDataList = getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)
sexChartOptions.series[0].data = dictDataList.map((dictData: DictDataType) => {
dictDataList.push({ label: '未知', value: null } as any)
sexChartOptions.series![0].data = dictDataList.map((dictData: DictDataType) => {
const userCount = list.find((item: MemberSexStatisticsRespVO) => item.sex === dictData.value)
?.userCount
return {
@ -426,8 +280,9 @@ const getMemberSexStatisticsList = async () => {
/** 按照终端,查询会员统计列表 */
const getMemberTerminalStatisticsList = async () => {
const list = await TradeMemberApi.getMemberTerminalStatisticsList()
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList()
const dictDataList = getIntDictOptions(DICT_TYPE.TERMINAL)
dictDataList.push({ label: '未知', value: null } as any)
terminalChartOptions.series![0].data = dictDataList.map((dictData: DictDataType) => {
const userCount = list.find(
(item: MemberTerminalStatisticsRespVO) => item.terminal === dictData.value
@ -439,20 +294,6 @@ const getMemberTerminalStatisticsList = async () => {
})
}
/** 查询会员概览数据列表 */
const getMemberAnalyse = async () => {
analyseLoading.value = true
const times = queryParams.times
// , ,
if (DateUtil.isSameDay(times[0], times[1])) {
//
times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd'))
}
//
analyseData.value = await TradeMemberApi.getMemberAnalyse({ times })
analyseLoading.value = false
}
/** 初始化 **/
onMounted(async () => {
loading.value = true
@ -460,8 +301,7 @@ onMounted(async () => {
getMemberSummary(),
getMemberTerminalStatisticsList(),
getMemberAreaStatisticsList(),
getMemberSexStatisticsList(),
handleDateTypeChange()
getMemberSexStatisticsList()
])
loading.value = false
})
@ -472,13 +312,4 @@ onMounted(async () => {
margin-bottom: 1rem;
}
}
.trapezoid1 {
transform: perspective(5em) rotateX(-11deg);
}
.trapezoid2 {
transform: perspective(7em) rotateX(-20deg);
}
.trapezoid3 {
transform: perspective(3em) rotateX(-13deg);
}
</style>

View File

@ -59,25 +59,9 @@
<template #header>
<!-- 标题 -->
<div class="flex flex-row items-center justify-between">
<span>交易状况</span>
<CardTitle title="交易状况" />
<!-- 查询条件 -->
<div class="flex flex-row items-center gap-2">
<el-radio-group v-model="shortcutDays" @change="handleDateTypeChange">
<el-radio-button :label="1">昨天</el-radio-button>
<el-radio-button :label="7">最近7天</el-radio-button>
<el-radio-button :label="30">最近30天</el-radio-button>
</el-radio-group>
<el-date-picker
v-model="queryParams.times"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
:shortcuts="shortcuts"
class="!w-240px"
@change="getTradeTrendData"
/>
<ShortcutDateRangePicker ref="shortcutDateRangePicker" @change="getTradeTrendData">
<el-button
class="ml-4"
@click="handleExport"
@ -86,7 +70,7 @@
>
<Icon icon="ep:download" class="mr-1" />导出
</el-button>
</div>
</ShortcutDateRangePicker>
</div>
</template>
<!-- 统计值 -->
@ -100,11 +84,11 @@
icon-bg-color="text-blue-500"
prefix="¥"
:decimals="2"
:value="fenToYuan(trendSummary?.value?.turnover || 0)"
:value="fenToYuan(trendSummary?.value?.turnoverPrice || 0)"
:percent="
calculateRelativeRate(
trendSummary?.value?.turnover,
trendSummary?.reference?.turnover
trendSummary?.value?.turnoverPrice,
trendSummary?.reference?.turnoverPrice
)
"
/>
@ -172,11 +156,11 @@
icon-bg-color="text-cyan-500"
prefix="¥"
:decimals="2"
:value="fenToYuan(trendSummary?.value?.balancePrice || 0)"
:value="fenToYuan(trendSummary?.value?.orderWalletPayPrice || 0)"
:percent="
calculateRelativeRate(
trendSummary?.value?.balancePrice,
trendSummary?.reference?.balancePrice
trendSummary?.value?.orderWalletPayPrice,
trendSummary?.reference?.orderWalletPayPrice
)
"
/>
@ -230,58 +214,27 @@ import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
import TradeStatisticValue from './components/TradeStatisticValue.vue'
import TradeTrendValue from './components/TradeTrendValue.vue'
import { EChartsOption } from 'echarts'
import {
TradeStatisticsComparisonRespVO,
TradeSummaryRespVO,
TradeTrendReqVO,
TradeTrendSummaryRespVO
} from '@/api/mall/statistics/trade'
import dayjs from 'dayjs'
import { fenToYuan } from '@/utils'
import * as DateUtil from '@/utils/formatTime'
import { DataComparisonRespVO } from '@/api/mall/statistics/common'
import { TradeSummaryRespVO, TradeTrendSummaryRespVO } from '@/api/mall/statistics/trade'
import { calculateRelativeRate, fenToYuan } from '@/utils'
import download from '@/utils/download'
import { CardTitle } from '@/components/Card'
/** 交易统计 */
defineOptions({ name: 'TradeStatistics' })
const message = useMessage() //
const loading = ref(true) //
const trendLoading = ref(true) //
const exportLoading = ref(false) //
const queryParams = reactive<TradeTrendReqVO>({ times: ['', ''] }) //
const shortcutDays = ref(7) // , 7
const summary = ref<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>>() //
const trendSummary = ref<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>>() //
/** 日期快捷选择 */
const shortcuts = [
{
text: '昨天',
value: () => DateUtil.getDayRange(new Date(), -1)
},
{
text: '最近7天',
value: () => DateUtil.getLast7Days()
},
{
text: '本月',
value: () => [dayjs().startOf('M'), dayjs().subtract(1, 'd')]
},
{
text: '最近30天',
value: () => DateUtil.getLast30Days()
},
{
text: '最近1年',
value: () => DateUtil.getLast1Year()
}
]
const summary = ref<DataComparisonRespVO<TradeSummaryRespVO>>() //
const trendSummary = ref<DataComparisonRespVO<TradeTrendSummaryRespVO>>() //
const shortcutDateRangePicker = ref()
/** 折线图配置 */
const lineChartOptions = reactive<EChartsOption>({
dataset: {
dimensions: ['date', 'turnover', 'orderPayPrice', 'rechargePrice', 'expensePrice'],
dimensions: ['date', 'turnoverPrice', 'orderPayPrice', 'rechargePrice', 'expensePrice'],
source: []
},
grid: {
@ -333,33 +286,10 @@ const lineChartOptions = reactive<EChartsOption>({
}
}) as EChartsOption
/** 计算环比 */
const calculateRelativeRate = (value?: number, reference?: number) => {
// 0
if (!reference) return 0
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
}
/** 设置时间范围 */
function setTimes() {
const beginDate = dayjs().subtract(shortcutDays.value, 'd')
const yesterday = dayjs().subtract(1, 'd')
queryParams.times = DateUtil.getDateRange(beginDate, yesterday)
}
/** 处理交易状况查询(日期单选按钮组选择后) */
const handleDateTypeChange = async () => {
//
setTimes()
//
await getTradeTrendData()
}
/** 处理交易状况查询 */
const getTradeTrendData = async () => {
trendLoading.value = true
await Promise.all([getTradeTrendSummary(), getTradeTrendList()])
await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()])
trendLoading.value = false
}
@ -370,24 +300,18 @@ const getTradeStatisticsSummary = async () => {
/** 查询交易状况数据统计 */
const getTradeTrendSummary = async () => {
loading.value = true
trendSummary.value = await TradeStatisticsApi.getTradeTrendSummary(queryParams)
loading.value = false
const times = shortcutDateRangePicker.value.times
trendSummary.value = await TradeStatisticsApi.getTradeTrendSummary({ times })
}
/** 查询交易状况数据列表 */
const getTradeTrendList = async () => {
const times = queryParams.times
// , 线,
if (DateUtil.isSameDay(times[0], times[1])) {
//
times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd'))
}
const getTradeStatisticsList = async () => {
//
const list = await TradeStatisticsApi.getTradeTrendList({ times })
const times = shortcutDateRangePicker.value.times
const list = await TradeStatisticsApi.getTradeStatisticsList({ times })
//
for (let item of list) {
item.turnover = fenToYuan(item.turnover)
item.turnoverPrice = fenToYuan(item.turnoverPrice)
item.orderPayPrice = fenToYuan(item.orderPayPrice)
item.rechargePrice = fenToYuan(item.rechargePrice)
item.expensePrice = fenToYuan(item.expensePrice)
@ -405,7 +329,8 @@ const handleExport = async () => {
await message.exportConfirm()
//
exportLoading.value = true
const data = await TradeStatisticsApi.exportTradeTrend(queryParams)
const times = shortcutDateRangePicker.value.times
const data = await TradeStatisticsApi.exportTradeStatisticsExcel({ times })
download.excel(data, '交易状况.xls')
} catch {
} finally {
@ -416,7 +341,6 @@ const handleExport = async () => {
/** 初始化 **/
onMounted(async () => {
await getTradeStatisticsSummary()
await handleDateTypeChange()
})
</script>
<style lang="scss" scoped>

View File

@ -15,7 +15,21 @@
type="textarea"
/>
</el-form-item>
<el-form-item label="接收人" prop="userId">
<el-form-item label="用户类型" prop="userType">
<el-radio-group v-model="formData.userType">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
:key="dict.value"
:label="dict.value as number"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-show="formData.userType === 1" label="接收人ID" prop="userId">
<el-input v-model="formData.userId" style="width: 160px" />
</el-form-item>
<el-form-item v-show="formData.userType === 2" label="接收人" prop="userId">
<el-select v-model="formData.userId" placeholder="请选择接收人">
<el-option
v-for="item in userOption"
@ -46,6 +60,7 @@
<script lang="ts" setup>
import * as UserApi from '@/api/system/user'
import * as NotifyTemplateApi from '@/api/system/notify/template'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
defineOptions({ name: 'SystemNotifyTemplateSendForm' })
@ -57,6 +72,7 @@ const formData = ref({
content: '',
params: {},
userId: null,
userType: 1,
templateCode: '',
templateParams: new Map()
})
@ -122,7 +138,8 @@ const resetForm = () => {
params: {},
mobile: '',
templateCode: '',
templateParams: new Map()
templateParams: new Map(),
userType: 1
} as any
formRef.value?.resetFields()
}