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>
114 lines
4.0 KiB
Vue
114 lines
4.0 KiB
Vue
<script setup lang="ts">
|
|
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 { token } = theme.useToken();
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const auth = useAuthStore();
|
|
const chrome = provideTreasuryPageChrome();
|
|
|
|
watch(
|
|
() => route.fullPath,
|
|
() => {
|
|
chrome.clear();
|
|
const scroller = document.querySelector('main.content');
|
|
if (scroller instanceof HTMLElement) scroller.scrollTop = 0;
|
|
},
|
|
);
|
|
|
|
const title = computed(
|
|
() =>
|
|
chrome.override.value.title ??
|
|
(typeof route.meta.treasuryTitle === 'string' ? route.meta.treasuryTitle : 'مدیریت مالی'),
|
|
);
|
|
|
|
const description = computed(
|
|
() =>
|
|
chrome.override.value.description ??
|
|
(typeof route.meta.treasuryDescription === 'string' ? route.meta.treasuryDescription : ''),
|
|
);
|
|
|
|
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="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>
|
|
</template>
|