refactor: add Function edit Personal

This commit is contained in:
Net 2024-08-07 13:30:05 +07:00
parent 54e330a4cf
commit 287d73a1a5
2 changed files with 103 additions and 30 deletions

View file

@ -9,7 +9,7 @@ import { calculateAge, dateFormat } from 'src/utils/datetime';
import useCustomerStore from 'stores/customer';
import useEmployeeStore from 'stores/employee';
import useMyBranchStore from 'stores/my-branch';
import useUtilsStore, { dialog, notify } from 'stores/utils';
import useUtilsStore, { dialog } from 'stores/utils';
import useFlowStore from 'stores/flow';
import { Status } from 'stores/types';
import { CustomerStats, Customer, CustomerBranch } from 'stores/customer/types';
@ -408,6 +408,12 @@ async function editCustomerForm(id: string) {
customerFormState.value.editCustomerId = id;
}
async function editEmployeeFormPersonal(id: string) {
await employeeFormStore.assignFormDataEmployee(id);
employeeFormState.value.dialogType = 'edit';
employeeFormState.value.drawerModal = true;
}
function employeeConfirmUnsave(close = true) {
dialog({
color: 'warning',
@ -615,8 +621,8 @@ watch(
? customerStats.map((v) => ({
count:
v.name === 'CORP'
? (statsCustomerType?.CORP ?? 0)
: (statsCustomerType?.PERS ?? 0),
? statsCustomerType?.CORP ?? 0
: statsCustomerType?.PERS ?? 0,
label:
v.name === 'CORP'
? 'customerLegalEntity'
@ -1507,12 +1513,10 @@ watch(
class="row q-py-sm"
style="white-space: nowrap"
@click="
() => {
// openDialogInputForm(
// 'INFO',
// props.row.id,
// true,
// );
async () => {
await editEmployeeFormPersonal(
props.row.id,
);
}
"
>
@ -1614,7 +1618,7 @@ watch(
{
icon: 'mdi-clock-outline',
value: props.row.dateOfBirth
? (calculateAge(props.row.dateOfBirth) ?? '')
? calculateAge(props.row.dateOfBirth) ?? ''
: '',
},
],
@ -1920,10 +1924,19 @@ watch(
:title="$t('form.title.create', { name: 'Employee' })"
v-model:modal="employeeFormState.dialogModal"
:undo="() => employeeFormUndo(false)"
:submit="
async () => {
await employeeFormStore.submitPersonal();
await fetchListEmployee();
}
"
:close="
() => {
employeeFormStore.resetFormDataEmployee(true);
}
"
:before-close="
() => {
console.log('asd');
if (employeeFormStore.isFormDataDifferent()) {
employeeConfirmUnsave();
return true;
@ -1933,6 +1946,7 @@ watch(
"
>
<div class="q-mx-lg q-mt-lg">
{{ employeeFormState.statusSavePersonal }}
<ProfileBanner
active
useToggle
@ -1944,12 +1958,20 @@ watch(
v-model:toggle-status="currentFromDataEmployee.status"
fallbackCover="/images/employee-banner.png"
:img="employeeFormState.profileUrl || `/images/employee-avatar.png`"
:tabs-list="[
{ name: 'personalInfo', label: 'personalInfo' },
{ name: 'healthCheck', label: 'healthCheck' },
{ name: 'workHistory', label: 'workHistory' },
{ name: 'other', label: 'other' },
]"
:tabs-list="
[
{ name: 'personalInfo', label: 'personalInfo' },
{ name: 'healthCheck', label: 'healthCheck' },
{ name: 'workHistory', label: 'workHistory' },
{ name: 'other', label: 'other' },
].filter((v) => {
if (!employeeFormState.statusSavePersonal) {
return v.name === 'personalInfo';
}
return true;
})
"
:menu="formMenuIconEmployee"
:toggleTitle="$t('formDialogTitleUserStatus')"
:hideFade="
@ -2051,7 +2073,6 @@ watch(
v-model:nrc-no="currentFromDataEmployee.nrcNo"
v-model:code="currentFromDataEmployee.code"
@filter-owner-branch="employeeFormStore.employeeFilterOwnerBranch"
@save="() => employeeFormStore.submitPersonal()"
/>
<FormPerson
id="form-personal"
@ -2243,6 +2264,12 @@ watch(
? 'app-bg-female text-white'
: ''
"
:submit="
async () => {
await employeeFormStore.submitPersonal();
employeeFormState.isEmployeeEdit = false;
}
"
>
<div class="full-height full-width column">
<div class="q-mx-lg q-mt-lg">