Merge branch 'feat/handle-role' into develop
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
puriphatt 2025-07-07 12:44:10 +07:00
commit f08c83c98b
44 changed files with 430 additions and 237 deletions

View file

@ -9,7 +9,7 @@ import { baseUrl } from 'src/stores/utils';
import useCustomerStore from 'stores/customer';
import useFlowStore from 'stores/flow';
import useOptionStore from 'stores/options';
import { dialog } from 'stores/utils';
import { dialog, canAccess } from 'stores/utils';
import { Status } from 'stores/types';
import { Employee } from 'stores/employee/types';
@ -285,7 +285,7 @@ watch(
<template>
<FloatingActionButton
style="z-index: 999"
v-if="$route.name !== 'CustomerManagement'"
v-if="$route.name !== 'CustomerManagement' && canAccess('customer', 'edit')"
@click="openEmployerBranchForm('create')"
hide-icon
></FloatingActionButton>
@ -615,7 +615,7 @@ watch(
<div class="text-center">
<TableEmpoloyee
:prefix-id="props.row.registerName || props.row.firstName"
add-button
:add-button="canAccess('customer', 'edit')"
in-table
:list-employee="listEmployee"
:columns-employee="columnsEmployee"
@ -759,7 +759,10 @@ watch(
/>
<DeleteButton
icon-only
v-if="customerBranchFormState.dialogType === 'info'"
v-if="
customerBranchFormState.dialogType === 'info' &&
canAccess('customer', 'edit')
"
@click="
() => {
deleteBranchById(customerBranchFormData.id || '');

View file

@ -6,7 +6,7 @@ import { useRoute, useRouter } from 'vue-router';
import { getUserId, getRole } from 'src/services/keycloak';
import { baseUrl, setPrefixName, waitAll } from 'src/stores/utils';
import { dateFormat } from 'src/utils/datetime';
import { dialogCheckData } from 'stores/utils';
import { dialogCheckData, canAccess } from 'stores/utils';
import useOcrStore from 'stores/ocr';
import useCustomerStore from 'stores/customer';
@ -397,7 +397,11 @@ async function fetchListEmployee(opt?: {
employeeStats.value = await employeeStore.getStatsEmployee();
}
async function triggerChangeStatus(id: string, status: string) {
async function triggerChangeStatus(
id: string,
status: string,
employeeName?: string,
) {
return await new Promise((resolve, reject) => {
dialog({
color: status !== 'INACTIVE' ? 'warning' : 'info',
@ -412,7 +416,11 @@ async function triggerChangeStatus(id: string, status: string) {
: t('dialog.message.confirmChangeStatusOn'),
action: async () => {
if (currentTab.value === 'employee') {
await toggleStatusEmployee(id, status === 'INACTIVE' ? false : true)
await toggleStatusEmployee(
id,
status === 'INACTIVE' ? false : true,
employeeName,
)
.then(resolve)
.catch(reject);
} else {
@ -426,9 +434,14 @@ async function triggerChangeStatus(id: string, status: string) {
});
}
async function toggleStatusEmployee(id: string, status: boolean) {
async function toggleStatusEmployee(
id: string,
status: boolean,
employeeName: string,
) {
const res = await employeeStore.editById(id, {
status: !status ? 'ACTIVE' : 'INACTIVE',
firstNameEN: employeeName,
});
if (res && employeeFormState.value.drawerModal)
currentFromDataEmployee.value.status = res.status;
@ -658,7 +671,7 @@ const emptyCreateDialog = ref(false);
<FloatingActionButton
style="z-index: 999"
:hide-icon="currentTab === 'employee'"
v-if="$route.name === 'CustomerManagement'"
v-if="$route.name === 'CustomerManagement' && canAccess('customer', 'edit')"
@click="
() => {
if (currentTab === 'employee') {
@ -1391,6 +1404,7 @@ const emptyCreateDialog = ref(false);
/>
<KebabAction
:hide-delete="!canAccess('customer', 'edit')"
:id-name="
props.row.branch[0].customerName ||
props.row.branch[0].firstName
@ -1638,7 +1652,17 @@ const emptyCreateDialog = ref(false);
</div>
</template>
<template v-slot:action>
<q-btn
icon="mdi-eye-outline"
:id="`btn-eye-${props.row.branch[0].customerName || props.row.branch[0].firstName}`"
size="sm"
dense
round
flat
@click.stop="editCustomerForm(props.row.id)"
/>
<KebabAction
:hide-delete="!canAccess('customer', 'edit')"
:status="props.row.status"
:id-name="props.row.name"
@view="
@ -1772,6 +1796,7 @@ const emptyCreateDialog = ref(false);
"
>
<TableEmpoloyee
:hide-delete="!canAccess('customer', 'edit')"
v-model:page-size="pageSize"
v-model:current-page="currentPageEmployee"
:grid-view="gridView"
@ -1819,7 +1844,11 @@ const emptyCreateDialog = ref(false);
"
@toggle-status="
async (item: any) => {
triggerChangeStatus(item.id, item.status);
triggerChangeStatus(
item.id,
item.status,
item.firstNameEN,
);
}
"
/>
@ -1889,6 +1918,7 @@ const emptyCreateDialog = ref(false);
"
>
<TooltipComponent
v-if="canAccess('customer', 'edit')"
class="self-end q-ma-md"
:title="'general.noData'"
:caption="'general.clickToCreate'"
@ -1900,6 +1930,7 @@ const emptyCreateDialog = ref(false);
style="flex-grow: 1"
>
<EmptyAddButton
v-if="canAccess('customer', 'edit')"
:label="'general.add'"
:i18n-args="{
text: $t(`customer.${currentTab}`),
@ -1914,6 +1945,7 @@ const emptyCreateDialog = ref(false);
}
"
/>
<NoData v-else />
</div>
</template>
</div>
@ -4423,6 +4455,7 @@ const emptyCreateDialog = ref(false);
(customerFormState.branchIndex !== -1 &&
customerFormState.branchIndex !== idx)
"
:hide-delete="!canAccess('customer', 'edit')"
:readonly="customerFormState.branchIndex !== idx"
@edit="() => (customerFormState.branchIndex = idx)"
@cancel="() => customerFormUndo(false)"
@ -4463,11 +4496,18 @@ const emptyCreateDialog = ref(false);
}
"
:title="
employeeFormState.currentEmployee
? $i18n.locale === 'eng'
? `${employeeFormState.currentEmployee.firstNameEN} ${employeeFormState.currentEmployee.lastNameEN}`
: `${employeeFormState.currentEmployee.firstName} ${employeeFormState.currentEmployee.lastName}`
: '-'
setPrefixName(
{
namePrefix: employeeFormState.currentEmployee.namePrefix,
firstName:
employeeFormState.currentEmployee.firstName ||
employeeFormState.currentEmployee.firstNameEN,
lastName: employeeFormState.currentEmployee.lastName,
firstNameEN: employeeFormState.currentEmployee.firstNameEN,
lastNameEN: employeeFormState.currentEmployee.lastNameEN,
},
{ locale },
)
"
:badge-class="
currentFromDataEmployee.gender === 'male'
@ -4562,7 +4602,11 @@ const emptyCreateDialog = ref(false);
@update:toggle-status="
(v) => {
if (currentFromDataEmployee.id !== undefined)
triggerChangeStatus(currentFromDataEmployee.id, v);
triggerChangeStatus(
currentFromDataEmployee.id,
v,
currentFromDataEmployee.firstNameEN,
);
}
"
:active="currentFromDataEmployee.status !== 'INACTIVE'"
@ -4582,7 +4626,9 @@ const emptyCreateDialog = ref(false);
? setPrefixName(
{
namePrefix: employeeFormState.currentEmployee.namePrefix,
firstName: employeeFormState.currentEmployee.firstName,
firstName:
employeeFormState.currentEmployee.firstName ||
employeeFormState.currentEmployee.firstNameEN,
lastName: employeeFormState.currentEmployee.lastName,
firstNameEN: employeeFormState.currentEmployee.firstNameEN,
lastNameEN: employeeFormState.currentEmployee.lastNameEN,
@ -4878,7 +4924,10 @@ const emptyCreateDialog = ref(false);
type="button"
/>
<DeleteButton
v-if="!employeeFormState.isEmployeeEdit"
v-if="
!employeeFormState.isEmployeeEdit &&
canAccess('customer', 'edit')
"
id="btn-info-basic-delete"
icon-only
@click="

View file

@ -102,7 +102,13 @@ const telephoneNo = defineModel<string>('telephoneNo', { default: '' });
class="col-md-6"
:readonly
:disabled="
!isRoleInclude(['admin', 'system', 'head_of_admin']) && !readonly
!isRoleInclude([
'admin',
'system',
'head_of_admin',
'executive',
'accountant',
]) && !readonly
"
:label="$t('customer.form.registeredBranch')"
select-first-value

View file

@ -51,6 +51,7 @@ withDefaults(
actionDisabled?: boolean;
customerType?: 'CORP' | 'PERS';
hideAction?: boolean;
hideDelete?: boolean;
}>(),
{
hideAction: false,
@ -81,7 +82,7 @@ withDefaults(
/>
<DeleteButton
icon-only
v-if="readonly"
v-if="readonly && !hideDelete"
@click="$emit('delete')"
type="button"
:disabled="actionDisabled"