Merge branch 'develop'
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
Thanaphon Frappet 2025-03-24 10:41:12 +07:00
commit 1101fa68d8
4 changed files with 118 additions and 29 deletions

View file

@ -7,6 +7,7 @@ import useMyBranch from 'stores/my-branch';
import { getUserId, getRole } from 'src/services/keycloak';
import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n';
import { isRoleInclude } from 'src/stores/utils';
type Menu = {
label: string;
@ -70,44 +71,82 @@ function initMenu() {
{
label: 'branch',
route: '/branch-management',
hidden: !(
role.value.includes('admin') ||
role.value.includes('branch_manager') ||
role.value.includes('head_of_admin') ||
role.value.includes('system') ||
role.value.includes('owner') ||
role.value.includes('head_of_account')
),
hidden: !isRoleInclude([
'system',
'head_of_admin',
'admin',
'branch_manager',
'head_of_accountant',
]),
},
{
label: 'personnel',
route: '/personnel-management',
hidden: !(
role.value.includes('admin') ||
role.value.includes('head_of_admin') ||
role.value.includes('system') ||
role.value.includes('owner') ||
role.value.includes('branch_manager')
),
hidden: !isRoleInclude([
'owner',
'system',
'head_of_admin',
'admin',
'branch_manager',
]),
},
{
label: 'workflow',
route: '/workflow',
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
},
{ label: 'workflow', route: '/workflow' },
{
label: 'property',
route: '/property',
hidden: !(
role.value.includes('admin') ||
role.value.includes('head_of_admin') ||
role.value.includes('system')
),
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
},
{
label: 'productService',
route: '/product-service',
hidden: !isRoleInclude([
'system',
'head_of_admin',
'admin',
'branch_manager',
'head_of_accountant',
'head_of_sale',
'sale',
]),
},
{
label: 'customer',
route: '/customer-management',
hidden: !isRoleInclude([
'system',
'head_of_admin',
'admin',
'branch_manager',
'head_of_accountant',
'accountant',
'head_of_sale',
'sale',
]),
},
{
label: 'agencies',
route: '/agencies-management',
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin']),
},
{ label: 'productService', route: '/product-service' },
{ label: 'customer', route: '/customer-management' },
{ label: 'agencies', route: '/agencies-management' },
],
},
{
label: 'menu.sales',
icon: 'mdi-store-settings-outline',
hidden: !isRoleInclude([
'system',
'head_of_admin',
'admin',
'branch_manager',
'head_of_accountant',
'accountant',
'head_of_sale',
'sale',
]),
children: [
{ label: 'quotation', route: '/quotation' },
{ label: 'invoice', route: '/invoice' },
@ -130,6 +169,16 @@ function initMenu() {
label: 'menu.account',
icon: 'mdi-bank-outline',
disabled: false,
hidden: !isRoleInclude([
'system',
'head_of_admin',
'admin',
'branch_manager',
'head_of_accountant',
'accountant',
'head_of_sale',
'sale',
]),
children: [
{ label: 'receipt', route: '/receipt' },
{ label: 'creditNote', route: '/credit-note' },
@ -151,6 +200,7 @@ function initMenu() {
{
label: 'menu.overall',
icon: 'mdi-monitor-dashboard',
hidden: !isRoleInclude(['system', 'head_of_admin', 'admin', 'executive']),
children: [
{ label: 'report', route: '/report' },
{ label: 'dashboard', route: '/dash-board' },
@ -163,7 +213,7 @@ function initMenu() {
children: [
{
label: 'usage',
route: `/manual`,
route: '/manual',
},
],
},
@ -250,7 +300,13 @@ onMounted(async () => {
</header>
<div id="drawer-menu" class="q-pl-md q-mr-xs q-gutter-y-sm">
<template v-for="(menu, i) in menuData" :key="i">
<template
v-for="(menu, i) in menuData.filter(
(v) =>
!(v.children?.length === 0 || v.children?.every((i) => i.hidden)),
)"
:key="i"
>
<q-expansion-item
v-if="!menu.hidden"
:id="menu.label"
@ -444,8 +500,9 @@ onMounted(async () => {
</span>
</div>
<!-- v-if="!mini" -->
<q-btn
v-if="!mini"
v-if="false"
dense
flat
rounded

View file

@ -23,6 +23,7 @@ import { useRequestList } from 'src/stores/request-list';
import { RequestData, RequestDataStatus } from 'src/stores/request-list/types';
import { dialogWarningClose } from 'src/stores/utils';
import { CancelButton, SaveButton } from 'src/components/button';
import { getRole } from 'src/services/keycloak';
const $q = useQuasar();
const navigatorStore = useNavigator();
@ -92,6 +93,19 @@ function triggerCancel(id: string) {
});
}
const hideAction = computed(() => {
const role = getRole();
const allowedRoles = [
'head_of_admin',
'head_of_sale',
'admin',
'sale',
'system',
];
return !role || !role.some((r) => allowedRoles.includes(r));
});
function triggerView(opts: { requestData: RequestData }) {
const url = new URL(
`/request-list/${opts.requestData.id}`,
@ -379,6 +393,7 @@ watch([() => pageState.inputSearch, () => pageState.statusFilter], () => {
:rows="data"
:grid="pageState.gridView"
:visible-columns="pageState.fieldSelected"
:hide-action
@view="(data) => triggerView({ requestData: data })"
@delete="(data) => triggerCancel(data.id)"
@reject-cancel="

View file

@ -4,6 +4,8 @@ import { baseUrl } from 'src/stores/utils';
import { ProductRelation, PayCondition } from 'src/stores/quotations/types';
import { Step, RequestWorkStatus } from 'src/stores/request-list/types';
import BadgeComponent from 'src/components/BadgeComponent.vue';
import { computed } from 'vue';
import { getRole } from 'src/services/keycloak';
defineEmits<{
(
@ -34,6 +36,19 @@ const props = defineProps<{
orderAble?: boolean;
}>();
const canCanceled = computed(() => {
const role = getRole();
const allowedRoles = [
'head_of_admin',
'head_of_sale',
'admin',
'sale',
'system',
];
return !role || role.some((r) => allowedRoles.includes(r));
});
function changeableStatus(currentStatus?: RequestWorkStatus) {
switch (currentStatus) {
case RequestWorkStatus.Ready:
@ -53,7 +68,7 @@ function changeableStatus(currentStatus?: RequestWorkStatus) {
RequestWorkStatus.Ready,
RequestWorkStatus.Ended,
RequestWorkStatus.Canceled,
];
].filter((v) => canCanceled.value || v !== RequestWorkStatus.Canceled);
if (props.orderAble) {
return props.requestCancel && !props.rejectRequestCancel
? [...statuses, RequestWorkStatus.RejectCancel]

View file

@ -20,6 +20,7 @@ const props = withDefaults(
columns: QTableProps['columns'];
grid?: boolean;
visibleColumns?: string[];
hideAction?: boolean;
}>(),
{
row: () => [],
@ -224,6 +225,7 @@ function getEmployeeName(
/>
<KebabAction
v-if="!hideAction"
:id-name="`btn-kebab-${props.row.code}`"
hide-edit
hide-toggle
@ -255,7 +257,7 @@ function getEmployeeName(
hide-kebab-view
hide-kebab-edit
hide-kebab-delete
use-cancel
:use-cancel="!hideAction"
class="full-height"
:use-reject-cancel="
props.row.customerRequestCancel && !props.row.rejectRequestCancel