(
@@ -53,7 +53,7 @@ onMounted(async () => {
• {{ $t(`formDialogTitlePassport`) }}
{
class="col-3"
:options="addrOptions.provinceOps"
lazy-rules
+ :rules="[
+ (val: string) =>
+ !!val || $t('selectValidate') + $t('formDialogInputPassportType'),
+ ]"
/>
{
class="col-3"
:label="$t('formDialogInputPassportNo')"
v-model="passportNumber"
+ :rules="[
+ (val: string) =>
+ !!val || $t('inputValidate') + $t('formDialogInputPassportNo'),
+ ]"
/>
{
class="col-6"
:label="$t('formDialogInputPassportRef')"
v-model="previousPassportReference"
+ :rules="[
+ (val: string) =>
+ !!val || $t('inputValidate') + $t('formDialogInputPassportRef'),
+ ]"
/>
{
class="col-3"
:options="addrOptions.provinceOps"
lazy-rules
+ :rules="[
+ (val: string) =>
+ !!val || $t('selectValidate') + $t('formDialogInputPassportCountry'),
+ ]"
/>
{
{
color="positive"
/>
-
-
-
{
{
:model-value="
passportExpiryDate ? dateFormat(passportExpiryDate) : ''
"
+ :rules="[
+ (val: string) =>
+ !!val ||
+ $t('selectValidate') + $t('formDialogInputPassportExpire'),
+ ]"
>
{
color="positive"
/>
-
-
-
@@ -215,8 +229,8 @@ onMounted(async () => {
diff --git a/src/components/03_customer-management/FormEmployeeVisa.vue b/src/components/03_customer-management/FormEmployeeVisa.vue
index 3bb7fb90..7e6418fd 100644
--- a/src/components/03_customer-management/FormEmployeeVisa.vue
+++ b/src/components/03_customer-management/FormEmployeeVisa.vue
@@ -21,12 +21,12 @@ const addrOptions = reactive<{
const visaType = defineModel('visaType');
const visaNumber = defineModel('visaNumber');
-const visaIssueDate = defineModel('visaIssueDate');
-const visaExpiryDate = defineModel('visaExpiryDate');
+const visaIssueDate = defineModel('visaIssueDate');
+const visaExpiryDate = defineModel('visaExpiryDate');
const visaIssuingPlace = defineModel('visaIssuingPlace');
-const visaStayUntilDate = defineModel('visaStayUntilDate');
+const visaStayUntilDate = defineModel('visaStayUntilDate');
const tm6Number = defineModel('tm6Number');
-const entryDate = defineModel('entryDate');
+const entryDate = defineModel('entryDate');
defineProps<{
title?: string;
@@ -52,7 +52,7 @@ onMounted(async () => {
• {{ $t(`formDialogTitleVisa`) }}
{
class="col-3"
:options="addrOptions.provinceOps"
lazy-rules
+ :rules="[
+ (val: string) =>
+ !!val || $t('selectValidate') + $t('formDialogInputVisaType'),
+ ]"
/>
{
class="col-3"
:label="$t('formDialogInputVisaNo')"
v-model="visaNumber"
+ :rules="[
+ (val: string) =>
+ !!val || $t('inputValidate') + $t('formDialogInputVisaNo'),
+ ]"
/>
{
{
color="positive"
/>
-
-
-
{
{
color="positive"
/>
-
-
-
{
class="col-6"
:label="$t('formDialogInputVisaPlace')"
v-model="visaIssuingPlace"
+ :rules="[
+ (val: string) =>
+ !!val || $t('selectValidate') + $t('formDialogInputVisaPlace'),
+ ]"
/>
{
{
{
class="col-6"
:label="$t('formDialogInputVisaTM6')"
v-model="tm6Number"
+ :rules="[
+ (val: string) =>
+ !!val || $t('inputValidate') + $t('formDialogInputVisaTM6'),
+ ]"
/>
{
:readonly="readonly"
:borderless="readonly"
:model-value="entryDate ? dateFormat(entryDate) : ''"
+ :rules="[
+ (val: string) =>
+ !!val || $t('selectValidate') + $t('formDialogInputVisaEnter'),
+ ]"
>
{
color="positive"
/>
-
-
-
diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue
index 69f75831..74026b7c 100644
--- a/src/pages/03_customer-management/MainPage.vue
+++ b/src/pages/03_customer-management/MainPage.vue
@@ -108,10 +108,10 @@ const fieldSelectedCustomer = ref<{ label: string; value: string }>({
const formDataEmployeeSameAddr = ref(false);
const formDataEmployeeTab = ref('personalInfo');
const formDataEmployee = ref({
- 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({
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 () => {
{
},
) {
const { image, ...payload } = data;
-
const res = await api.post<
- Employee & { imageUrl: string; imageUploadUrl: string }
+ Employee & { profileImageUrl: string; profileImageUploadUrl: string }
>('/employee', payload, {
headers: {
'X-Session-Id': flow?.sessionId,
@@ -67,12 +66,13 @@ const useEmployeeStore = defineStore('api-employee', () => {
},
});
- await axios
- .put(res.data.imageUploadUrl, image, {
- headers: { 'Content-Type': image.type },
- onUploadProgress: (e) => console.log(e),
- })
- .catch((e) => console.error(e));
+ image &&
+ (await axios
+ .put(res.data.profileImageUploadUrl, image, {
+ headers: { 'Content-Type': image?.type },
+ onUploadProgress: (e) => console.log(e),
+ })
+ .catch((e) => console.error(e)));
if (!res) return false;
diff --git a/src/stores/employee/types.ts b/src/stores/employee/types.ts
index 974648ba..c1907069 100644
--- a/src/stores/employee/types.ts
+++ b/src/stores/employee/types.ts
@@ -46,14 +46,14 @@ export type Employee = {
};
export type EmployeeCreate = {
- image: File;
+ image: File | null;
customerBranchId: string;
status?: Status;
nrcNo: string;
- dateOfBirth: Date;
+ dateOfBirth: Date | null;
gender: string;
nationality: string;
@@ -68,20 +68,20 @@ export type EmployeeCreate = {
passportType: string;
passportNumber: string;
- passportIssueDate: Date;
- passportExpiryDate: Date;
+ passportIssueDate: Date | null;
+ passportExpiryDate: Date | null;
passportIssuingCountry: string;
passportIssuingPlace: string;
previousPassportReference?: string;
visaType: string;
visaNumber: string;
- visaIssueDate: Date;
- visaExpiryDate: Date;
+ visaIssueDate: Date | null;
+ visaExpiryDate: Date | null;
visaIssuingPlace: string;
- visaStayUntilDate: Date;
+ visaStayUntilDate: Date | null;
tm6Number: string;
- entryDate: Date;
+ entryDate: Date | null;
workerStatus: string;
subDistrictId?: string | null;
@@ -145,8 +145,8 @@ export type EmployeeCheckup = {
};
export type EmployeeCheckupCreate = {
- coverageExpireDate?: Date;
- coverageStartDate?: Date;
+ coverageExpireDate?: Date | null;
+ coverageStartDate?: Date | null;
insuranceCompany?: string;
medicalBenefitScheme?: string;
remark?: string;
@@ -175,9 +175,9 @@ export type EmployeeWork = {
};
export type EmployeeWorkCreate = {
- workEndDate?: Date;
- workPermitExpireDate?: Date;
- workPermitIssuDate?: Date;
+ workEndDate?: Date | null;
+ workPermitExpireDate?: Date | null;
+ workPermitIssuDate?: Date | null;
workPermitNo?: string;
workplace?: string;
jobType?: string;