Preserve the local Ant UI work across views/components and add the new home dashboard chart panels before merging latest main.
61 lines
1.8 KiB
Vue
61 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { Menu as AMenu } from 'ant-design-vue';
|
|
import type { MenuProps } from 'ant-design-vue';
|
|
import { useAuthStore } from '@/stores/auth';
|
|
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const auth = useAuthStore();
|
|
const canPayroll = computed(
|
|
() =>
|
|
auth.user?.role === 'owner' ||
|
|
auth.user?.role === 'admin' ||
|
|
Boolean(auth.user?.permissions?.includes('treasury_payroll')),
|
|
);
|
|
|
|
const links = computed(() => [
|
|
{ to: '/finance', label: 'داشبورد', exact: true },
|
|
{ to: '/finance/incomes', label: 'دریافتها و درآمدها' },
|
|
{ to: '/finance/expenses', label: 'پرداختها و هزینهها' },
|
|
{ to: '/finance/receivables', label: 'اقساط و مطالبات' },
|
|
{ to: '/finance/accounts', label: 'صندوق و حسابها' },
|
|
...(canPayroll.value ? [{ to: '/finance/payroll', label: 'حقوق' }] : []),
|
|
{ to: '/finance/recurring', label: 'تکرارشونده' },
|
|
{ to: '/finance/reports', label: 'گزارش' },
|
|
{ to: '/finance/audit', label: 'سوابق' },
|
|
{ to: '/finance/categories', label: 'دستهبندیها' },
|
|
]);
|
|
|
|
function on(path: string, exact?: boolean) {
|
|
if (exact) return route.path === path;
|
|
return route.path === path || route.path.startsWith(`${path}/`);
|
|
}
|
|
|
|
const selectedKeys = computed(() => {
|
|
const match = links.value.find((link) => on(link.to, link.exact));
|
|
return match ? [match.to] : [];
|
|
});
|
|
|
|
const items = computed<MenuProps['items']>(() =>
|
|
links.value.map((link) => ({
|
|
key: link.to,
|
|
label: link.label,
|
|
})),
|
|
);
|
|
|
|
const onClick: MenuProps['onClick'] = ({ key }) => {
|
|
void router.push(String(key));
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<a-menu
|
|
mode="horizontal"
|
|
:selected-keys="selectedKeys"
|
|
:items="items"
|
|
@click="onClick"
|
|
/>
|
|
</template>
|