refactor: update role checks and access control in MainPage and QuotationFormProductSelect components
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
puriphatt 2025-07-03 15:19:41 +07:00
parent 2269038e11
commit e9d995fa3e
2 changed files with 20 additions and 22 deletions

View file

@ -41,7 +41,7 @@ import PaginationPageSize from 'src/components/PaginationPageSize.vue';
import useFlowStore from 'stores/flow'; import useFlowStore from 'stores/flow';
import { dateFormat } from 'src/utils/datetime'; import { dateFormat } from 'src/utils/datetime';
import { formatNumberDecimal, isRoleInclude, notify } from 'stores/utils'; import { formatNumberDecimal, isRoleInclude, canAccess } from 'stores/utils';
const { getWorkflowTemplate } = useWorkflowTemplate(); const { getWorkflowTemplate } = useWorkflowTemplate();
import { Status } from 'stores/types'; import { Status } from 'stores/types';
@ -143,27 +143,25 @@ const { t } = useI18n();
const baseUrl = ref<string>(import.meta.env.VITE_API_BASE_URL); const baseUrl = ref<string>(import.meta.env.VITE_API_BASE_URL);
const priceDisplay = computed(() => ({ const priceDisplay = computed(() => ({
price: !isRoleInclude(['sale_agent']), // price: !isRoleInclude(['sale_agent']),
price: true,
agentPrice: isRoleInclude([ agentPrice: isRoleInclude([
'admin',
'head_of_admin',
'head_of_sale',
'system', 'system',
'owner', 'head_of_admin',
'admin',
'executive',
'accountant', 'accountant',
'sale_agent', 'head_of_sale',
]), ]),
serviceCharge: isRoleInclude([ serviceCharge: isRoleInclude([
'admin',
'head_of_admin',
'system', 'system',
'owner', 'head_of_admin',
'admin',
'executive',
'accountant', 'accountant',
]), ]),
})); }));
const actionDisplay = computed(() => const actionDisplay = computed(() => canAccess('product', 'edit'));
isRoleInclude(['admin', 'head_of_admin', 'system', 'owner', 'accountant']),
);
const splitterModel = computed(() => const splitterModel = computed(() =>
$q.screen.lt.md ? (productMode.value !== 'group' ? 0 : 100) : 25, $q.screen.lt.md ? (productMode.value !== 'group' ? 0 : 100) : 25,
); );

View file

@ -66,21 +66,21 @@ const serviceList = defineModel<Partial<Record<ProductGroupId, Service[]>>>(
); );
const priceDisplay = computed(() => ({ const priceDisplay = computed(() => ({
price: !isRoleInclude(['sale_agent']), // price: !isRoleInclude(['sale_agent']),
price: true,
agentPrice: isRoleInclude([ agentPrice: isRoleInclude([
'admin',
'head_of_admin',
'head_of_sale',
'system', 'system',
'owner', 'head_of_admin',
'admin',
'executive',
'accountant', 'accountant',
'sale_agent', 'head_of_sale',
]), ]),
serviceCharge: isRoleInclude([ serviceCharge: isRoleInclude([
'admin',
'head_of_admin',
'system', 'system',
'owner', 'head_of_admin',
'admin',
'executive',
'accountant', 'accountant',
]), ]),
})); }));