|
|
@@ -111,6 +111,27 @@ const fetchData = async (page = 0) => {
|
|
|
totalPages: Math.ceil((result?.metadata?.total || 0) / (result?.metadata?.size || 20))
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 为团队用户获取统计信息
|
|
|
+ if (!isAdmin.value) {
|
|
|
+ await fetchDomainStatistics()
|
|
|
+ // 将统计信息合并到表格数据中
|
|
|
+ if (tableData.value.data && tableData.value.data.length > 0) {
|
|
|
+ tableData.value.data = tableData.value.data.map(domain => {
|
|
|
+ const todayStats = domainStatistics.value[domain.domain] || {}
|
|
|
+ const allStats = domainAllStatistics.value[domain.domain] || {}
|
|
|
+ return {
|
|
|
+ ...domain,
|
|
|
+ todayNewUsers: todayStats.todayNewUsers || 0,
|
|
|
+ todayActiveUsers: todayStats.todayActiveUsers || 0,
|
|
|
+ todayIncome: todayStats.todayIncome || 0,
|
|
|
+ todaySales: todayStats.todaySales || 0,
|
|
|
+ totalIncome: allStats.totalIncome || 0,
|
|
|
+ totalSales: allStats.totalSales || 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('获取域名列表失败', error)
|
|
|
@@ -186,7 +207,6 @@ const copyDomain = async (domain) => {
|
|
|
|
|
|
// 获取域名统计数据
|
|
|
const fetchDomainStatistics = async () => {
|
|
|
- if (!isAdmin.value) return
|
|
|
|
|
|
try {
|
|
|
// 获取今日统计数据
|
|
|
@@ -197,10 +217,10 @@ const fetchDomainStatistics = async () => {
|
|
|
todayStatsMap[stat.domain] = {
|
|
|
todayNewUsers: stat.todayNewUsers || 0,
|
|
|
todayIncome: stat.todayIncome || 0,
|
|
|
- todayActiveUsers: stat.todayActiveUsers || 0, // 今日活跃用户
|
|
|
+ todayActiveUsers: stat.todayActiveUsers || 0, // 今日活跃用户数
|
|
|
totalIncome: stat.totalIncome || 0, // 历史总分润收入
|
|
|
totalSales: stat.totalSales || 0, // 历史总销售额
|
|
|
- todaySales: stat.todaySales || 0 // 今日销售额
|
|
|
+ todaySales: stat.todaySales || 0 // 今日销售额
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -214,7 +234,7 @@ const fetchDomainStatistics = async () => {
|
|
|
allStatsMap[stat.domain] = {
|
|
|
totalNewUsers: stat.totalNewUsers || 0,
|
|
|
totalIncome: stat.totalIncome || 0,
|
|
|
- todayActiveUsers: stat.todayActiveUsers || 0, // 今日活跃用户
|
|
|
+ todayActiveUsers: stat.todayActiveUsers || 0, // 今日活跃用户数
|
|
|
todayIncome: stat.todayIncome || 0, // 今日分润收入
|
|
|
totalSales: stat.totalSales || 0, // 历史总销售额
|
|
|
todaySales: stat.todaySales || 0 // 今日销售额
|
|
|
@@ -235,6 +255,12 @@ const resetModel = () => {
|
|
|
domainModel.description = ''
|
|
|
}
|
|
|
|
|
|
+// 格式化金额,保留2位小数
|
|
|
+const formatAmount = (amount) => {
|
|
|
+ if (amount === undefined || amount === null) return '0.00'
|
|
|
+ return Number(amount).toFixed(2)
|
|
|
+}
|
|
|
+
|
|
|
const onEdit = async (domain = null) => {
|
|
|
resetModel()
|
|
|
|
|
|
@@ -564,6 +590,36 @@ onMounted(() => {
|
|
|
</div>
|
|
|
</template>
|
|
|
</Column>
|
|
|
+ <Column field="todayNewUsers" header="今日新增" style="min-width: 100px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="new-user-amount">{{ slotProps.data.todayNewUsers || 0 }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
+ <Column field="todayActiveUsers" header="今日活跃" style="min-width: 100px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="active-user-amount">{{ slotProps.data.todayActiveUsers || 0 }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
+ <Column field="todayIncome" header="今日分润" style="min-width: 120px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="revenue-amount">¥{{ formatAmount(slotProps.data.todayIncome) }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
+ <Column field="todaySales" header="今日销售" style="min-width: 120px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="sales-amount">¥{{ formatAmount(slotProps.data.todaySales) }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
+ <Column field="totalIncome" header="总分润" style="min-width: 120px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="revenue-amount">¥{{ formatAmount(slotProps.data.totalIncome) }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
+ <Column field="totalSales" header="总销售" style="min-width: 120px" headerClass="font-bold">
|
|
|
+ <template #body="slotProps">
|
|
|
+ <span class="sales-amount">¥{{ formatAmount(slotProps.data.totalSales) }}</span>
|
|
|
+ </template>
|
|
|
+ </Column>
|
|
|
<Column field="createdAt" header="创建时间" style="min-width: 150px" headerClass="font-bold">
|
|
|
<template #body="slotProps">
|
|
|
{{ formatDate(slotProps.data.createdAt) }}
|
|
|
@@ -832,6 +888,27 @@ onMounted(() => {
|
|
|
border-radius: 3px;
|
|
|
}
|
|
|
|
|
|
+/* 表格统计字段样式 */
|
|
|
+.revenue-amount {
|
|
|
+ color: #2563eb;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+.sales-amount {
|
|
|
+ color: #f59e0b;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+.new-user-amount {
|
|
|
+ color: #8b5cf6;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+.active-user-amount {
|
|
|
+ color: #10b981;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
.domain-actions-bottom .p-button {
|
|
|
width: 28px;
|
|
|
height: 28px;
|