refactor: handle roles executive
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 8s

This commit is contained in:
Thanaphon Frappet 2025-03-05 16:52:36 +07:00
parent 724f71ae4f
commit 49d860a108
4 changed files with 11 additions and 18 deletions

View file

@ -1344,10 +1344,7 @@ export default {
Document: 'Document Status Report', Document: 'Document Status Report',
Invoice: 'Payment Report', Invoice: 'Payment Report',
Product: 'Product and Service Report', Product: 'Product and Service Report',
admin: { Sale: 'Sales Summary Report',
Product: 'Product Movement Report',
Sale: 'Sales Summary Report',
},
}, },
document: { document: {
code: 'Code', code: 'Code',

View file

@ -1322,10 +1322,7 @@ export default {
Document: 'รายงานสถานะเอกสาร', Document: 'รายงานสถานะเอกสาร',
Invoice: 'รายงานการชำระเงิน', Invoice: 'รายงานการชำระเงิน',
Product: 'รายงานสินค้าและบริการ', Product: 'รายงานสินค้าและบริการ',
admin: { Sale: 'รายงานสรุปยอดขาย',
Product: 'รายงานการเคลื่อนไหวของสินค้า',
Sale: 'รายงานสรุปยอดขาย',
},
}, },
document: { document: {
code: 'รหัส', code: 'รหัส',

View file

@ -62,24 +62,23 @@ onMounted(async () => {
navigatorStore.current.path = [{ text: '' }]; navigatorStore.current.path = [{ text: '' }];
}); });
const isAdmin = computed(() => { const isExecutive = computed(() => {
const roles = userRoles.value; const roles = userRoles.value;
return roles.includes('executive');
return roles.includes('head_of_admin') || roles.includes('head_of_account');
}); });
const filteredTabs = computed(() => { const filteredTabs = computed(() => {
return pageTabs.filter((tab) => { return pageTabs.filter((tab) => {
if (isAdmin.value) { if (!isExecutive.value) {
return !(tab.by.length === 1 && tab.by.includes('user')); return !tab.by.includes('admin');
} else {
return !(tab.by.length === 1 && tab.by.includes('admin'));
} }
return true;
}); });
}); });
const pageState = reactive({ const pageState = reactive({
currentTab: isAdmin.value ? ViewMode.Product : ViewMode.Document, currentTab: isExecutive.value ? ViewMode.Product : ViewMode.Document,
}); });
async function fetchReportTab() { async function fetchReportTab() {
@ -152,7 +151,7 @@ watch([() => pageState.currentTab], async () => {
: 'app-text-muted' : 'app-text-muted'
" "
> >
{{ $t(`report.view${isAdmin ? '.admin' : ''}.${tab.label}`) }} {{ $t(`report.view.${tab.label}`) }}
</div> </div>
</q-tab> </q-tab>
</q-tabs> </q-tabs>

View file

@ -148,6 +148,6 @@ export const colReportBySale = [
export const pageTabs = [ export const pageTabs = [
{ label: 'Document', value: ViewMode.Document, by: ['user'] }, { label: 'Document', value: ViewMode.Document, by: ['user'] },
{ label: 'Invoice', value: ViewMode.Invoice, by: ['user'] }, { label: 'Invoice', value: ViewMode.Invoice, by: ['user'] },
{ label: 'Product', value: ViewMode.Product, by: ['user', 'admin'] }, { label: 'Product', value: ViewMode.Product, by: ['user'] },
{ label: 'Sale', value: ViewMode.Sale, by: ['admin'] }, { label: 'Sale', value: ViewMode.Sale, by: ['admin'] },
]; ];