feat: 新30号准则适配 — 三表完善+认证头修复+企业联动
This commit is contained in:
@@ -4,6 +4,15 @@
|
||||
<div class="report-header">
|
||||
<h3 class="page-title">📊 CMA管理报表</h3>
|
||||
<div class="header-right">
|
||||
<el-select
|
||||
v-model="currentEntityId"
|
||||
size="small"
|
||||
style="width:180px"
|
||||
placeholder="选择企业"
|
||||
@change="onEntityChange"
|
||||
>
|
||||
<el-option v-for="e in entities" :key="e.id" :label="e.short_name + ' / ' + e.name" :value="e.id" />
|
||||
</el-select>
|
||||
<el-date-picker
|
||||
v-model="reportPeriod"
|
||||
type="month"
|
||||
@@ -568,15 +577,50 @@ const loading = ref(false)
|
||||
const activeTab = ref('profit')
|
||||
const reportPeriod = ref('2026-06')
|
||||
|
||||
// ── 企业选择(新30号准则报表联动)──
|
||||
const entities = ref<any[]>([])
|
||||
const currentEntityId = ref(Number(localStorage.getItem('cma_entity_id') || 1))
|
||||
|
||||
function getEntityId() {
|
||||
return Number(localStorage.getItem('cma_entity_id') || 1)
|
||||
return Number(localStorage.getItem('cma_entity_id') || currentEntityId.value || 1)
|
||||
}
|
||||
|
||||
async function loadEntities() {
|
||||
try {
|
||||
const r: any = await api.get('/entities')
|
||||
entities.value = r.data || r || []
|
||||
const e = entities.value.find((x: any) => x.id === currentEntityId.value)
|
||||
if (e) localStorage.setItem('cma_entity_name', e.short_name || e.name || '')
|
||||
} catch {
|
||||
entities.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function onEntityChange(id: number) {
|
||||
localStorage.setItem('cma_entity_id', String(id))
|
||||
const e = entities.value.find((x: any) => x.id === id)
|
||||
if (e) localStorage.setItem('cma_entity_name', e.short_name || e.name || '')
|
||||
ElMessage.success(`已切换企业:${e ? e.short_name + ' / ' + e.name : id}`)
|
||||
loadAll()
|
||||
loadStatutory()
|
||||
}
|
||||
|
||||
// 跨页面同步:其他页面切换企业时联动刷新
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('storage', (ev: StorageEvent) => {
|
||||
if (ev.key === 'cma_entity_id' && ev.newValue) {
|
||||
currentEntityId.value = Number(ev.newValue)
|
||||
loadAll()
|
||||
loadStatutory()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// API 配置
|
||||
const api = axios.create({ baseURL: '/api/cma', timeout: 30000 })
|
||||
api.interceptors.request.use((config: any) => {
|
||||
const token = localStorage.getItem('cma_token')
|
||||
if (token) config.headers.Authorization = `'Bearer ' + token`
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
})
|
||||
|
||||
@@ -658,7 +702,8 @@ function switchNew30Format(fmt: string) {
|
||||
}
|
||||
|
||||
function exportNew30() {
|
||||
ElMessage.success('导出功能将在P2实现')
|
||||
// 新30号准则利润表导出 → 复用对外法定报表Excel(Sheet1=五板块利润表+附注)
|
||||
exportStatutory()
|
||||
}
|
||||
|
||||
function openSubjectManage() {
|
||||
@@ -784,6 +829,7 @@ function bscScoreColor(score: number): string {
|
||||
|
||||
function onPeriodChange() {
|
||||
loadAll()
|
||||
loadStatutory()
|
||||
}
|
||||
|
||||
// ── 加载 ──
|
||||
@@ -888,6 +934,7 @@ function onBudgetSort(sort: any) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadEntities()
|
||||
loadKpiOptions()
|
||||
loadAll()
|
||||
loadStatutory()
|
||||
|
||||
@@ -104,7 +104,7 @@ import axios from 'axios'
|
||||
const api = axios.create({ baseURL: '/api/cma', timeout: 30000 })
|
||||
api.interceptors.request.use((config: any) => {
|
||||
const token = localStorage.getItem('cma_token')
|
||||
if (token) config.headers.Authorization = `'Bearer ' + token`
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user