fix: 企业切换数据同步(8/10页面+shared组件)
This commit is contained in:
@@ -390,9 +390,13 @@ const overviewData = ref<any>({})
|
||||
const productOptions = ref<string[]>([])
|
||||
const maxTrend = ref(0)
|
||||
|
||||
function getEntityId() {
|
||||
return Number(localStorage.getItem('cma_entity_id') || 1)
|
||||
}
|
||||
|
||||
async function loadOverview() {
|
||||
try {
|
||||
const r: any = await costApi.dashboard({ period: overviewPeriod.value })
|
||||
const r: any = await costApi.dashboard({ period: overviewPeriod.value, entity_id: getEntityId() })
|
||||
overviewData.value = r.data || r
|
||||
// 提取产品列表
|
||||
const products = overviewData.value.products || []
|
||||
@@ -423,7 +427,7 @@ const stdProductFilter = ref('')
|
||||
async function loadStandardCosts() {
|
||||
stdLoading.value = true
|
||||
try {
|
||||
const params: any = {}
|
||||
const params: any = { entity_id: getEntityId() }
|
||||
if (stdProductFilter.value) params.product_code = stdProductFilter.value
|
||||
const r: any = await costApi.listStandardCosts(params)
|
||||
standardCosts.value = r.data || []
|
||||
@@ -474,7 +478,7 @@ const actualSaving = ref(false)
|
||||
async function loadActualCosts() {
|
||||
actualLoading.value = true
|
||||
try {
|
||||
const params: any = { period: entryPeriod.value }
|
||||
const params: any = { period: entryPeriod.value, entity_id: getEntityId() }
|
||||
const r: any = await costApi.listActualCosts(params)
|
||||
actualCosts.value = r.data || []
|
||||
} catch (e) { ElMessage.error('加载实际成本失败') }
|
||||
@@ -555,7 +559,7 @@ const allocSaving = ref(false)
|
||||
async function loadAllocations() {
|
||||
allocLoading.value = true
|
||||
try {
|
||||
const r: any = await costApi.listAbcAllocations({ period: allocPeriod.value })
|
||||
const r: any = await costApi.listAbcAllocations({ period: allocPeriod.value, entity_id: getEntityId() })
|
||||
abcAllocations.value = r.data || []
|
||||
} catch (e) { /* ignore */ }
|
||||
allocLoading.value = false
|
||||
@@ -652,7 +656,7 @@ const compInsights = computed(() => compData.value.insights || [])
|
||||
async function loadComparison() {
|
||||
compLoading.value = true
|
||||
try {
|
||||
const r: any = await costApi.comparison({ entity: compEntity.value })
|
||||
const r: any = await costApi.comparison({ entity: compEntity.value, entity_id: getEntityId() })
|
||||
compData.value = r.data || r
|
||||
} catch (e) { ElMessage.error('加载对比数据失败') }
|
||||
compLoading.value = false
|
||||
|
||||
Reference in New Issue
Block a user