feat(web): share the page header and icon finance fields.
Remaining screens and finance use the shared page header, tab icons sit closer to their labels, and the active workspace tab no longer paints a broken corner. Treasury selects and the money field show a leading icon. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,15 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from 'vue';
|
||||
import { RouterView, useRoute } from 'vue-router';
|
||||
import { Flex as AFlex, Grid, Typography, theme } from 'ant-design-vue';
|
||||
import TreasuryNav from '@/components/treasury/TreasuryNav.vue';
|
||||
import { computed, watch, type Component } from 'vue';
|
||||
import { RouterView, useRoute, useRouter } from 'vue-router';
|
||||
import { Flex as AFlex, theme } from 'ant-design-vue';
|
||||
import { treasurySectionAllowed, type TreasurySectionKey } from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderTab } from '@/components/page';
|
||||
import {
|
||||
ArrowDownOutlined,
|
||||
ArrowUpOutlined,
|
||||
BankOutlined,
|
||||
BarChartOutlined,
|
||||
ClockCircleOutlined,
|
||||
DollarOutlined,
|
||||
HistoryOutlined,
|
||||
HomeOutlined,
|
||||
SyncOutlined,
|
||||
TagOutlined,
|
||||
WalletOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { provideTreasuryPageChrome } from './treasuryPageChrome';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
const screens = Grid.useBreakpoint();
|
||||
const isMobile = computed(() => !screens.value.md);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const chrome = provideTreasuryPageChrome();
|
||||
|
||||
watch(
|
||||
@@ -33,29 +48,65 @@ const description = computed(
|
||||
(typeof route.meta.treasuryDescription === 'string' ? route.meta.treasuryDescription : ''),
|
||||
);
|
||||
|
||||
const headerStyle = computed(() =>
|
||||
isMobile.value
|
||||
? undefined
|
||||
: {
|
||||
minHeight: `${token.value.controlHeightLG + token.value.fontSizeLG + token.value.marginXXS}px`,
|
||||
},
|
||||
const links = computed(() => {
|
||||
const role = auth.user?.role;
|
||||
const permissions = auth.user?.permissions;
|
||||
const all: Array<{
|
||||
value: string;
|
||||
label: string;
|
||||
exact?: boolean;
|
||||
section: TreasurySectionKey;
|
||||
icon: Component;
|
||||
}> = [
|
||||
{ value: '/finance', label: 'داشبورد', exact: true, section: 'treasury_dashboard', icon: HomeOutlined },
|
||||
{ value: '/finance/incomes', label: 'دریافتها و درآمدها', section: 'treasury_incomes', icon: ArrowDownOutlined },
|
||||
{ value: '/finance/expenses', label: 'پرداختها و هزینهها', section: 'treasury_expenses', icon: ArrowUpOutlined },
|
||||
{ value: '/finance/receivables', label: 'اقساط و مطالبات', section: 'treasury_receivables', icon: ClockCircleOutlined },
|
||||
{ value: '/finance/accounts', label: 'صندوق و حسابها', section: 'treasury_accounts', icon: BankOutlined },
|
||||
{ value: '/finance/payroll', label: 'حقوق', section: 'treasury_payroll', icon: WalletOutlined },
|
||||
{ value: '/finance/recurring', label: 'تکرارشونده', section: 'treasury_recurring', icon: SyncOutlined },
|
||||
{ value: '/finance/reports', label: 'گزارش', section: 'treasury_reports', icon: BarChartOutlined },
|
||||
{ value: '/finance/audit', label: 'سوابق', section: 'treasury_audit', icon: HistoryOutlined },
|
||||
{ value: '/finance/categories', label: 'دستهبندی', section: 'treasury_categories', icon: TagOutlined },
|
||||
];
|
||||
return all.filter((link) => treasurySectionAllowed(role, permissions, link.section));
|
||||
});
|
||||
|
||||
const headerTabs = computed<PageHeaderTab[]>(() =>
|
||||
links.value.map((link) => ({ key: link.value, label: link.label, icon: link.icon })),
|
||||
);
|
||||
|
||||
const activeTab = computed(() => {
|
||||
const path = route.path;
|
||||
for (const link of links.value) {
|
||||
if (link.exact) {
|
||||
if (path === link.value) return link.value;
|
||||
} else if (path === link.value || path.startsWith(`${link.value}/`)) {
|
||||
return link.value;
|
||||
}
|
||||
}
|
||||
return '/finance';
|
||||
});
|
||||
|
||||
const backTo = computed(() => (route.name === 'finance-account' ? '/finance/accounts' : undefined));
|
||||
|
||||
function onTabChange(key: string | number | undefined) {
|
||||
const next = String(key ?? '');
|
||||
if (next && next !== route.path) void router.push(next);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="isMobile ? token.marginSM : token.margin" :style="{ width: '100%' }">
|
||||
<div :style="headerStyle">
|
||||
<a-typography-title :level="isMobile ? 4 : 3" :style="{ margin: 0 }">{{ title }}</a-typography-title>
|
||||
<a-typography-text
|
||||
type="secondary"
|
||||
:ellipsis="description ? { tooltip: description } : false"
|
||||
:style="{ display: 'block', margin: 0 }"
|
||||
>
|
||||
{{ description || '\u00a0' }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
|
||||
<TreasuryNav />
|
||||
<a-flex vertical :gap="token.margin" :style="{ width: '100%' }">
|
||||
<PageHeader
|
||||
:title="title"
|
||||
:subtitle="description || undefined"
|
||||
:icon="DollarOutlined"
|
||||
:tabs="headerTabs"
|
||||
:active-tab="activeTab"
|
||||
:back-to="backTo"
|
||||
@update:active-tab="onTabChange"
|
||||
/>
|
||||
|
||||
<RouterView />
|
||||
</a-flex>
|
||||
|
||||
Reference in New Issue
Block a user