fix: 企业切换数据同步(8/10页面+shared组件)
This commit is contained in:
@@ -374,6 +374,10 @@ const loading = ref(false)
|
||||
const activeTab = ref('profit')
|
||||
const reportPeriod = ref('2026-06')
|
||||
|
||||
function getEntityId() {
|
||||
return Number(localStorage.getItem('cma_entity_id') || 1)
|
||||
}
|
||||
|
||||
// API 配置
|
||||
const api = axios.create({ baseURL: '/api/cma', timeout: 30000 })
|
||||
api.interceptors.request.use((config: any) => {
|
||||
@@ -411,7 +415,7 @@ async function loadNew30() {
|
||||
loadingNew30.value = true
|
||||
dualComparisonData.value = null
|
||||
try {
|
||||
const params: any = { period: reportPeriod.value }
|
||||
const params: any = { period: reportPeriod.value, entity_id: getEntityId() }
|
||||
if (new30Format.value === 'dual') {
|
||||
params.format = 'dual'
|
||||
} else {
|
||||
@@ -497,7 +501,7 @@ const restatementNetProfit = ref<any>(null)
|
||||
async function loadRestatement() {
|
||||
loadingRestatement.value = true
|
||||
try {
|
||||
const r = await api.get('/reports/restatement', { params: { period: reportPeriod.value } })
|
||||
const r = await api.get('/reports/restatement', { params: { period: reportPeriod.value, entity_id: getEntityId() } })
|
||||
const d = (r as any).data || {}
|
||||
restatementItems.value = d.items || []
|
||||
restatementSummary.value = d.summary || null
|
||||
@@ -549,14 +553,14 @@ function onPeriodChange() {
|
||||
// ── 加载 ──
|
||||
async function loadProfit() {
|
||||
try {
|
||||
const r = await api.get('/reports/profit-summary', { params: { period: reportPeriod.value } })
|
||||
const r = await api.get('/reports/profit-summary', { params: { period: reportPeriod.value, entity_id: getEntityId() } })
|
||||
profitItems.value = (r as any).data?.items || []
|
||||
} catch { profitItems.value = [] }
|
||||
}
|
||||
|
||||
async function loadBudget() {
|
||||
try {
|
||||
const params: any = { period: reportPeriod.value }
|
||||
const params: any = { period: reportPeriod.value, entity_id: getEntityId() }
|
||||
if (budgetDim.value) params.dimension = budgetDim.value
|
||||
if (budgetLevel.value) params.alert_level = budgetLevel.value
|
||||
const r = await api.get('/reports/budget-execution', { params })
|
||||
@@ -568,7 +572,7 @@ async function loadBudget() {
|
||||
|
||||
async function loadTrends() {
|
||||
try {
|
||||
const params: any = { months: trendMonths.value }
|
||||
const params: any = { months: trendMonths.value, entity_id: getEntityId() }
|
||||
if (trendKpiId.value) params.kpi_id = trendKpiId.value
|
||||
else if (trendDim.value) params.dimension = trendDim.value
|
||||
const r = await api.get('/reports/kpi-trends', { params })
|
||||
@@ -579,14 +583,14 @@ async function loadTrends() {
|
||||
|
||||
async function loadBsc() {
|
||||
try {
|
||||
const r = await api.get('/reports/bsc-scorecard', { params: { period: reportPeriod.value } })
|
||||
const r = await api.get('/reports/bsc-scorecard', { params: { period: reportPeriod.value, entity_id: getEntityId() } })
|
||||
bscData.value = (r as any).data || {}
|
||||
} catch { bscData.value = {} }
|
||||
}
|
||||
|
||||
async function loadKpiOptions() {
|
||||
try {
|
||||
const r = await api.get('/kpis', { params: { page_size: 100 } })
|
||||
const r = await api.get('/kpis', { params: { page_size: 100, entity_id: getEntityId() } })
|
||||
kpiOptions.value = (r as any).data?.data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user