fix: complete nested portrait views and binding alert scope

This commit is contained in:
Yvan
2026-11-05 16:55:13 +08:00
parent db11b6eb54
commit a43d140339
9 changed files with 63 additions and 8 deletions
@@ -3,7 +3,7 @@
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" :disabled="saving">
<el-form-item label="所属平台" prop="sourceDb"><el-select v-model="form.sourceDb" placeholder="请选择所属平台" clearable @change="loadOptions"><el-option v-for="(label, value) in platforms" :key="value" :label="label" :value="value" /></el-select></el-form-item>
<el-form-item label="游戏商务" prop="platformBusierId"><el-select v-model="form.platformBusierId" placeholder="请选择游戏商务" filterable clearable :disabled="!form.sourceDb" :loading="optionsLoading"><el-option v-for="item in options" :key="item.id" :label="item.account" :value="item.id" /></el-select></el-form-item>
<el-form-item label="推广类型"><el-select v-model="form.registerType"><el-option label="个人" :value="0" /><el-option label="企业" :value="1" /></el-select></el-form-item>
<el-form-item label="渠道类型"><el-select v-model="form.registerType"><el-option label="个人" :value="0" /><el-option label="公会" :value="1" /></el-select></el-form-item>
<el-form-item label="渠道账号" prop="account"><el-input v-model="form.account" placeholder="中文/英文/数字,4-30位" maxlength="30" clearable /></el-form-item>
<el-form-item label="渠道密码" prop="password"><el-input v-model="form.password" type="password" show-password placeholder="6-15位" maxlength="15" autocomplete="new-password" /></el-form-item>
</el-form>
@@ -25,8 +25,8 @@
</div>
<h3 class="profile-heading">数据趋势</h3>
<div class="profile-two-columns">
<el-card shadow="never"><template #header>{{ rangeLabel }}注册量{{ hourly ? '(按小时)' : '' }}</template><business-trend :series="profile.registerTrend" title="注册量趋势" /></el-card>
<el-card shadow="never"><template #header>{{ rangeLabel }}充值金额{{ hourly ? '(按小时)' : '' }}</template><business-trend :series="profile.payTrend" title="充值金额趋势" money color="var(--el-color-success)" /></el-card>
<el-card shadow="never"><template #header>{{ rangeLabel }}注册量{{ hourly ? '(按小时)' : '' }}</template><business-trend :series="profile.registerTrend" title="注册量趋势" :hide-date-labels="!hourly" /></el-card>
<el-card shadow="never"><template #header>{{ rangeLabel }}充值金额{{ hourly ? '(按小时)' : '' }}</template><business-trend :series="profile.payTrend" title="充值金额趋势" :hide-date-labels="!hourly" money color="var(--el-color-success)" /></el-card>
</div>
<h3 class="profile-heading">旗下渠道排行</h3>
<div class="profile-two-columns">
@@ -111,7 +111,7 @@ const loadAlerts = async () => {
const request = alertRequests.start()
alertsLoading.value = true; alertError.value = ''
try {
const res = await listAlertRecords({ platformCodes: sources.value, businessId: props.userId, pageNum: alertPage.value, pageSize: 10 }, { signal: request.signal })
const res = await listAlertRecords({ platformCodes: sources.value, businessId: props.userId, platformBusierId: props.platformBusierId || undefined, pageNum: alertPage.value, pageSize: 10 }, { signal: request.signal })
if (!request.isCurrent()) return
if (res.code === 0 && res.data.available !== false) { alerts.value = res.data.pageData.rows; alertTotal.value = res.data.pageData.total }
else { alerts.value = []; alertTotal.value = 0; alertError.value = res.code === 0 ? '渠道数据尚未接入,暂时无法核对关联预警。' : res.msg || '关联预警读取失败' }
+4 -3
View File
@@ -7,7 +7,7 @@
</g>
<polygon v-if="points.length" :points="area" :fill="color" opacity="0.08" />
<polyline :points="line" fill="none" :stroke="color" stroke-width="2.5" stroke-linejoin="round" />
<text v-for="index in labelIndexes" :key="index" :x="pointX(index)" y="244" text-anchor="middle" class="axis-text">{{ series[index]?.label }}</text>
<text v-for="index in labelIndexes" :key="index" :x="pointX(index)" y="244" text-anchor="middle" class="axis-text">{{ hourly ? `${index}:00` : series[index]?.label }}</text>
<template v-if="selected">
<line :x1="selected.x" y1="18" :x2="selected.x" y2="220" class="cursor-line" />
<circle :cx="selected.x" :cy="selected.y" r="4" :fill="color" />
@@ -22,7 +22,7 @@
<script setup>
import { computed, ref } from 'vue'
import { channelCount, channelMoney } from '../channel-display'
const props = defineProps({ series: { type: Array, default: () => [] }, title: { type: String, default: '' }, money: Boolean, color: { type: String, default: 'var(--el-color-primary)' } })
const props = defineProps({ series: { type: Array, default: () => [] }, title: { type: String, default: '' }, money: Boolean, hideDateLabels: Boolean, color: { type: String, default: 'var(--el-color-primary)' } })
const active = ref(null)
const values = computed(() => props.series.map(point => Number.isFinite(Number(point.value)) ? Number(point.value) : 0))
const maximum = computed(() => Math.max(1, ...values.value))
@@ -33,7 +33,8 @@ const points = computed(() => props.series.map((point, index) => ({ ...point, x:
const line = computed(() => points.value.map(point => `${point.x},${point.y}`).join(' '))
const area = computed(() => `52,${pointY(0)} ${line.value} ${points.value.at(-1)?.x || 52},${pointY(0)}`)
const ticks = computed(() => [0, 1, 2, 3, 4].map(index => ({ y: 220 - index * 50.5, value: minimum.value + (maximum.value - minimum.value) * index / 4 })))
const labelIndexes = computed(() => [...new Set([0, 1, 2, 3, 4].map(index => Math.round(Math.max(0, props.series.length - 1) * index / 4)))])
const hourly = computed(() => props.series.length === 24 && props.series.every(point => /^\d{1,2}:00$/.test(point.label)))
const labelIndexes = computed(() => props.hideDateLabels ? [] : hourly.value ? [0, 4, 8, 12, 16, 20] : [...new Set([0, 1, 2, 3, 4].map(index => Math.round(Math.max(0, props.series.length - 1) * index / 4)))])
const selected = computed(() => active.value == null ? null : points.value[active.value])
const compact = value => new Intl.NumberFormat('zh-CN', { notation: 'compact', maximumFractionDigits: 1 }).format(value)
const formatted = value => props.money ? channelMoney(value) : channelCount(String(value).replace(/\.0+$/, ''))
@@ -81,7 +81,7 @@ const cards = computed(() => [
const metric = profile.value?.metrics?.[card.key]
const change = metric?.changeRate ?? metric?.changeDiff
const n = change == null ? null : Number(change)
const comparison = period.value === 'total' ? '' : change == null ? `${metric?.compareLabel || ''} ${metric?.compareValue == null ? '—' : card.format(metric.compareValue)}` : `${metric?.compareLabel || ''} ${n > 0 ? '↑ ' : n < 0 ? '↓ ' : ''}${Math.abs(n).toFixed(1)}${metric?.changeRate != null ? '%' : ' 个百分点'}`
const comparison = period.value === 'total' ? '—' : change == null ? `${metric?.compareLabel || ''} ${metric?.compareValue == null ? '—' : card.format(metric.compareValue)}` : `${metric?.compareLabel || ''} ${n > 0 ? '↑ ' : n < 0 ? '↓ ' : ''}${Math.abs(n).toFixed(1)}${metric?.changeRate != null ? '%' : ' 个百分点'}`
return { ...card, value: card.format(metric?.value), comparison, tone: n == null || n === 0 ? '' : n > 0 ? 'positive' : 'negative' }
}))
const tierMeta = {