fix: change status dialog

This commit is contained in:
puriphatt 2024-07-25 10:49:43 +00:00
parent 305d1f2e2b
commit f9eeb7f529
4 changed files with 152 additions and 84 deletions

View file

@ -755,6 +755,7 @@ function clearFormEmployee() {
infoDrawerEmployeeEdit.value = false;
formDataEmployeeSameAddr.value = true;
currentEmployeeCode.value = '';
formDataEmployeeTab.value = 'personalInfo';
currentEmployee.value = undefined;
formDataEmployeeOwner.value = undefined;
@ -990,6 +991,35 @@ async function fetchListEmployee() {
}
}
async function triggerChangeStatus(id: string, status: string) {
console.log('asd');
return await new Promise((resolve, reject) => {
dialog({
color: status !== 'INACTIVE' ? 'warning' : 'info',
icon: status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-comment-alert',
title: t('confirmChangeStatusTitle'),
actionText:
status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'),
message:
status !== 'INACTIVE'
? t('confirmChangeStatusOffMessage')
: t('confirmChangeStatusOnMessage'),
action: async () => {
if (currentTab.value === 'employee') {
await toggleStatusEmployee(id, status === 'ACTIVE' ? true : false)
.then(resolve)
.catch(reject);
} else {
await toggleStatusCustomer(id, status === 'ACTIVE' ? true : false)
.then(resolve)
.catch(reject);
}
},
cancel: () => {},
});
});
}
async function toggleStatusEmployee(id: string, status: boolean) {
await employeeStore.editById(id, { status: !status ? 'ACTIVE' : 'INACTIVE' });
@ -2219,11 +2249,9 @@ watch(isMainPage, () => {
"
@click="
async () => {
toggleStatusCustomer(
triggerChangeStatus(
props.row.id,
props.row.status === 'ACTIVE'
? true
: false,
props.row.status,
);
}
"
@ -2313,10 +2341,7 @@ watch(isMainPage, () => {
"
@delete-card="deleteCustomerById(props.row.id)"
@toggle-status="
toggleStatusCustomer(
props.row.id,
props.row.status === 'ACTIVE' ? true : false,
)
triggerChangeStatus(props.row.id, props.row.status)
"
/>
</div>
@ -2685,11 +2710,9 @@ watch(isMainPage, () => {
"
@click="
async () => {
toggleStatusEmployee(
triggerChangeStatus(
props.row.id,
props.row.status === 'ACTIVE'
? true
: false,
props.row.status,
);
}
"
@ -2754,10 +2777,7 @@ watch(isMainPage, () => {
"
@delete-card="onDelete(props.row.id)"
@toggle-status="
toggleStatusEmployee(
props.row.id,
props.row.status === 'ACTIVE' ? true : false,
)
triggerChangeStatus(props.row.id, props.row.status)
"
/>
</div>
@ -4019,30 +4039,28 @@ watch(isMainPage, () => {
employee
>
<template #person-card>
<div class="q-ma-md">
<AppBox class="surface-1" style="padding: 0">
<PersonCard
:can-edit-profile="infoDrawerEmployeeEdit"
no-hover
no-action
no-detail
:data="{
name:
formDataEmployee.firstName + ' ' + formDataEmployee.lastName,
code: formDataEmployee.code,
male: formDataEmployee.gender === 'male',
female: formDataEmployee.gender === 'female',
img: profileUrl || undefined,
}"
:list="infoEmployeePersonCard ? infoEmployeePersonCard : []"
:gridColumns="1"
@edit-profile="
() => {
inputFile.click();
}
"
/>
</AppBox>
<div class="q-pa-md full-height" style="overflow: hidden">
<PersonCard
:can-edit-profile="infoDrawerEmployeeEdit"
no-hover
no-action
no-detail
:data="{
name:
formDataEmployee.firstName + ' ' + formDataEmployee.lastName,
code: formDataEmployee.code,
male: formDataEmployee.gender === 'male',
female: formDataEmployee.gender === 'female',
img: profileUrl || undefined,
}"
:list="infoEmployeePersonCard ? infoEmployeePersonCard : []"
:gridColumns="1"
@edit-profile="
() => {
inputFile.click();
}
"
/>
</div>
</template>
<template #information>