数据分析ui补充完善,接入数据库
This commit is contained in:
@@ -201,12 +201,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { onLoad, onShow, reactive, ref } from 'vue'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
|
||||
import AnalyticsSidebarMenu from '@/components/analytics/AnalyticsSidebarMenu.uvue'
|
||||
import AnalyticsTopBar from '@/components/analytics/AnalyticsTopBar.uvue'
|
||||
import { fetchReport, fetchReportMetrics, fetchReportRows, fetchReportInsights, fetchRelatedReports } from '@/services/analytics/reportDetailService.uts'
|
||||
import { mapAnalyticsError } from '@/services/analytics/errorMapper.uts'
|
||||
import { formatTime } from '@/utils/utils.uts'
|
||||
|
||||
import type { ReportType, MetricType, ChartTabType, ChartLegendType, TableColumnType, InsightType } from '@/types/analytics/report-detail.uts'
|
||||
|
||||
@@ -233,14 +235,19 @@ const dataInsights = reactive<Array<InsightType>>([])
|
||||
const relatedReports = reactive<Array<ReportType>>([])
|
||||
|
||||
const sortIndex = ref(0)
|
||||
const sortOptions = ref<Array<string>>([])
|
||||
const sortOptions: Array<string> = []
|
||||
|
||||
const limitIndex = ref(1)
|
||||
const limitOptions = ref<Array<string>>(['10条', '20条', '50条', '100条'])
|
||||
const limitOptions: Array<string> = ['10条', '20条', '50条', '100条']
|
||||
|
||||
const currentPage = ref(1)
|
||||
const totalPages = ref(1)
|
||||
|
||||
const autoRefresh = ref(false)
|
||||
|
||||
const intervalIndex = ref(1)
|
||||
const intervalOptions = ref<Array<string>>(['1分钟', '5分钟', '10分钟', '30分钟', '1小时'])
|
||||
const intervalOptions: Array<string> = ['1分钟', '5分钟', '10分钟', '30分钟', '1小时']
|
||||
|
||||
const emailNotify = ref(false)
|
||||
|
||||
onLoad((options: any) => {
|
||||
@@ -302,7 +309,7 @@ async function loadReportDetail(reportId: string) {
|
||||
{ key: 'avg_value', title: '客单价', width: '120rpx', type: 'currency' }
|
||||
)
|
||||
|
||||
sortOptions.value = ['按日期降序', '按销售额降序', '按订单数降序', '按转化率降序']
|
||||
sortOptions.splice(0, sortOptions.length, '按日期降序', '按销售额降序', '按订单数降序', '按转化率降序')
|
||||
|
||||
const rows = await fetchReportRows(reportId)
|
||||
allRows.splice(0, allRows.length, ...rows)
|
||||
@@ -326,7 +333,7 @@ async function loadReportDetail(reportId: string) {
|
||||
|
||||
function updateTotalPages() {
|
||||
const total = allRows.length
|
||||
const limit = parseInt(limitOptions.value[limitIndex.value])
|
||||
const limit = parseInt(limitOptions[limitIndex.value])
|
||||
totalPages.value = total > 0 ? Math.ceil(total / limit) : 1
|
||||
}
|
||||
|
||||
@@ -336,7 +343,7 @@ function generateTableData() {
|
||||
if (total === 0) {
|
||||
return
|
||||
}
|
||||
const limit = parseInt(limitOptions.value[limitIndex.value])
|
||||
const limit = parseInt(limitOptions[limitIndex.value])
|
||||
const start = (currentPage.value - 1) * limit
|
||||
const end = Math.min(start + limit, total)
|
||||
|
||||
@@ -377,9 +384,7 @@ function formatMetricValue(value: number, format: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(timeStr: string): string {
|
||||
return timeStr.replace('T', ' ').split('.')[0]
|
||||
}
|
||||
|
||||
|
||||
function getInsightIcon(type: string): string {
|
||||
const icons: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user