Files
cz-web/src/views/finance/index.vue
2026-10-01 17:24:57 +08:00

115 lines
2.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 页面:财务中心(Finance) -->
<script setup lang="ts">
import { onMounted } from 'vue'
import { storeToRefs } from 'pinia'
import { RouterLink } from 'vue-router'
import { ElMessage } from 'element-plus'
import { PageHead } from '@/components'
import { useFinanceStore } from '@/stores/modules/finance'
import FinanceChart from './cpns/FinanceChart.vue'
import FinanceOverview from './cpns/FinanceOverview.vue'
const financeStore = useFinanceStore()
const { stats } = storeToRefs(financeStore)
const ENTRIES = [
{ label: '账单明细', to: '/finance/bills' },
{ label: '待支付', to: '/finance/bills' },
{ label: '发票申请', to: '/finance/invoices' },
{ label: '报表导出', to: '' },
] as const
function onPeriodChange(period: string): void {
void financeStore.fetchStats(period)
}
async function onExport(): Promise<void> {
await financeStore.export()
ElMessage.success('报表导出成功(演示)')
}
onMounted(() => {
void financeStore.fetchStats()
})
</script>
<template>
<div class="finance">
<PageHead
title="财务中心"
slogan="账单、支付、发票统一财务管理中心"
/>
<div class="container">
<div class="finance__top">
<FinanceOverview
:stats="stats"
@period-change="onPeriodChange"
@export="onExport"
/>
<div class="finance__entries">
<template v-for="entry in ENTRIES" :key="entry.label">
<RouterLink
v-if="entry.to"
:to="entry.to"
class="finance__entry"
>
{{ entry.label }}
</RouterLink>
<button
v-else
class="finance__entry"
@click="onExport"
>
{{ entry.label }}
</button>
</template>
</div>
</div>
<FinanceChart :distribution="stats?.distribution ?? []" />
</div>
</div>
</template>
<style lang="less" scoped>
.finance {
width: 100%;
&__top {
.flex(row, flex-start, stretch);
gap: 14px;
margin-top: -56px;
}
&__entries {
.flex(row, space-between, center);
flex: 0 0 672px;
height: 135px;
padding: 0 34px;
border: 1px solid @finance-card-line;
border-radius: @radius-base;
background: @white;
box-sizing: border-box;
}
&__entry {
.flex(row, center, center);
height: 100%;
border: none;
background: transparent;
color: @finance-entry-text;
font-size: 11px;
font-weight: 400;
cursor: pointer;
transition: color 0.2s;
&:hover {
border: none;
color: @primary-strong;
}
}
}
</style>