fix: change status employee
This commit is contained in:
parent
a5791a1b54
commit
a59e0c5157
1 changed files with 26 additions and 5 deletions
|
|
@ -397,7 +397,11 @@ async function fetchListEmployee(opt?: {
|
||||||
employeeStats.value = await employeeStore.getStatsEmployee();
|
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) => {
|
return await new Promise((resolve, reject) => {
|
||||||
dialog({
|
dialog({
|
||||||
color: status !== 'INACTIVE' ? 'warning' : 'info',
|
color: status !== 'INACTIVE' ? 'warning' : 'info',
|
||||||
|
|
@ -412,7 +416,11 @@ async function triggerChangeStatus(id: string, status: string) {
|
||||||
: t('dialog.message.confirmChangeStatusOn'),
|
: t('dialog.message.confirmChangeStatusOn'),
|
||||||
action: async () => {
|
action: async () => {
|
||||||
if (currentTab.value === 'employee') {
|
if (currentTab.value === 'employee') {
|
||||||
await toggleStatusEmployee(id, status === 'INACTIVE' ? false : true)
|
await toggleStatusEmployee(
|
||||||
|
id,
|
||||||
|
status === 'INACTIVE' ? false : true,
|
||||||
|
employeeName,
|
||||||
|
)
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
} else {
|
} 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, {
|
const res = await employeeStore.editById(id, {
|
||||||
status: !status ? 'ACTIVE' : 'INACTIVE',
|
status: !status ? 'ACTIVE' : 'INACTIVE',
|
||||||
|
firstNameEN: employeeName,
|
||||||
});
|
});
|
||||||
if (res && employeeFormState.value.drawerModal)
|
if (res && employeeFormState.value.drawerModal)
|
||||||
currentFromDataEmployee.value.status = res.status;
|
currentFromDataEmployee.value.status = res.status;
|
||||||
|
|
@ -1831,7 +1844,11 @@ const emptyCreateDialog = ref(false);
|
||||||
"
|
"
|
||||||
@toggle-status="
|
@toggle-status="
|
||||||
async (item: any) => {
|
async (item: any) => {
|
||||||
triggerChangeStatus(item.id, item.status);
|
triggerChangeStatus(
|
||||||
|
item.id,
|
||||||
|
item.status,
|
||||||
|
item.firstNameEN,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
@ -4585,7 +4602,11 @@ const emptyCreateDialog = ref(false);
|
||||||
@update:toggle-status="
|
@update:toggle-status="
|
||||||
(v) => {
|
(v) => {
|
||||||
if (currentFromDataEmployee.id !== undefined)
|
if (currentFromDataEmployee.id !== undefined)
|
||||||
triggerChangeStatus(currentFromDataEmployee.id, v);
|
triggerChangeStatus(
|
||||||
|
currentFromDataEmployee.id,
|
||||||
|
v,
|
||||||
|
currentFromDataEmployee.firstNameEN,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:active="currentFromDataEmployee.status !== 'INACTIVE'"
|
:active="currentFromDataEmployee.status !== 'INACTIVE'"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue