feat: employee image and type

This commit is contained in:
puriphatt 2024-06-11 05:01:58 +00:00
parent 93697fd8cc
commit 26402c0de4
5 changed files with 53 additions and 46 deletions

View file

@ -108,10 +108,10 @@ const fieldSelectedCustomer = ref<{ label: string; value: string }>({
const formDataEmployeeSameAddr = ref(false);
const formDataEmployeeTab = ref('personalInfo');
const formDataEmployee = ref<EmployeeCreate>({
image: new File([''], 'dummy.jpg'),
customerBranchId: '0b16ee4a-2ff3-40b8-b09d-c7589422d03d',
image: null,
customerBranchId: '',
nrcNo: '',
dateOfBirth: new Date(),
dateOfBirth: null,
gender: '',
nationality: '',
@ -126,20 +126,20 @@ const formDataEmployee = ref<EmployeeCreate>({
passportType: '',
passportNumber: '',
passportIssueDate: new Date(),
passportExpiryDate: new Date(),
passportIssueDate: null,
passportExpiryDate: null,
passportIssuingCountry: '',
passportIssuingPlace: '',
previousPassportReference: '',
visaType: '',
visaNumber: '',
visaIssueDate: new Date(),
visaExpiryDate: new Date(),
visaIssueDate: null,
visaExpiryDate: null,
visaIssuingPlace: '',
visaStayUntilDate: new Date(),
visaStayUntilDate: null,
tm6Number: '',
entryDate: new Date(),
entryDate: null,
workerStatus: '',
subDistrictId: '',
@ -424,18 +424,24 @@ function deleteBranchId(id: string) {
}
async function onSubmit() {
await create({
...formData.value,
customerType: customerType.value === 'CORP' ? 'CORP' : 'PERS',
image: profileSubmit.value ? profileFile.value ?? null : null,
});
clearForm();
const resultList = await fetchList({ includeBranch: true });
if (selectorLabel.value === 'EMPLOYER') {
await create({
...formData.value,
customerType: customerType.value === 'CORP' ? 'CORP' : 'PERS',
image: profileSubmit.value ? profileFile.value ?? null : null,
});
clearForm();
const resultList = await fetchList({ includeBranch: true });
if (resultList) listCustomer.value = resultList.result;
if (resultList) listCustomer.value = resultList.result;
}
if (selectorLabel.value === 'EMPLOYEE') {
await employeeStore.create(formDataEmployee.value);
console.log(profileFile.value);
await employeeStore.create({
...formDataEmployee.value,
image: profileSubmit.value ? profileFile.value ?? null : null,
});
const resultList = await employeeStore.fetchList();
if (resultList) listEmployee.value = resultList.result;
}
@ -891,6 +897,7 @@ watch(fieldSelectedCustomer, async () => {
<PersonCard
:list="
listEmployee.map((v: Employee) => ({
img: v.profileImageUrl,
id: v.id,
name:
$i18n.locale === 'en-US'
@ -1157,9 +1164,9 @@ watch(fieldSelectedCustomer, async () => {
employee
addressSeparator
:noAddress="formDataEmployeeTab !== 'personalInfo'"
v-model:modal="dialogEmployee"
v-model:tabs-list="employeeTab"
v-model:employee-tab="formDataEmployeeTab"
v-model:modal="dialogEmployee"
v-model:same-with-employer="formDataEmployeeSameAddr"
v-model:address="formDataEmployee.address"
v-model:addressEN="formDataEmployee.addressEN"