diff --git a/src/components/02_personnel-management/FormByType.vue b/src/components/02_personnel-management/FormByType.vue new file mode 100644 index 00000000..6f345419 --- /dev/null +++ b/src/components/02_personnel-management/FormByType.vue @@ -0,0 +1,307 @@ + + diff --git a/src/components/02_personnel-management/FormName.vue b/src/components/02_personnel-management/FormName.vue new file mode 100644 index 00000000..e719f524 --- /dev/null +++ b/src/components/02_personnel-management/FormName.vue @@ -0,0 +1,56 @@ + + diff --git a/src/components/02_personnel-management/FormTop.vue b/src/components/02_personnel-management/FormTop.vue new file mode 100644 index 00000000..da50bd8b --- /dev/null +++ b/src/components/02_personnel-management/FormTop.vue @@ -0,0 +1,124 @@ + + diff --git a/src/components/FormDialog.vue b/src/components/FormDialog.vue index d3d3ca38..85ae9fdc 100644 --- a/src/components/FormDialog.vue +++ b/src/components/FormDialog.vue @@ -1,5 +1,5 @@ @@ -512,7 +499,7 @@ watch(() => currentUser.value?.districtId, getSubDistrict); background-size: cover; } -.btn-edt { +.btn-edit { color: white; background-color: hsl(var(--info-bg)); border-radius: var(--radius-2); diff --git a/src/stores/user/index.ts b/src/stores/user/index.ts index f47e3f1c..2338671e 100644 --- a/src/stores/user/index.ts +++ b/src/stores/user/index.ts @@ -12,8 +12,11 @@ import { UserOption, } from './types'; import axios from 'axios'; +import useBranchStore from '../branch'; import { Branch } from '../branch/types'; +const branchStore = useBranchStore() + const useUserStore = defineStore('api-user', () => { const userOption = ref({ hqOpts: [], @@ -56,8 +59,50 @@ const useUserStore = defineStore('api-user', () => { { label: 'สถานที่อบรมแรงงานกัมพูชา-บ้านแหลม จ.จันทบุร' }, ], }); + const data = ref>(); + function calculateAge(birthDate: Date | null): string { + if (!birthDate) return ''; + const birthDateTimeStamp = new Date(birthDate).getTime(); + const now = new Date(); + const diff = now.getTime() - birthDateTimeStamp; + + const ageDate = new Date(diff); + const years = ageDate.getUTCFullYear() - 1970; + const result = `${years} ปี` + return result; + } + + async function fetchHqOption() { + if (userOption.value.hqOpts.length === 0) { + const res = await branchStore.fetchList({ pageSize: 999, filter: 'head' }); + if (res) { + res.result.map((item) => { + userOption.value.hqOpts.push({ + label: item.code, + value: item.id, + }); + }); + } + } + } + + + async function fetchBrOption(id: string) { + const res = await branchStore.fetchById(id, { + includeSubBranch: true, + }); + if (res && res?.branch) { + res.branch.map((item) => { + userOption.value.brOpts.push({ + label: item.code, + value: item.id, + }); + }); + } + } + async function fetchRoleOption() { const res = await api.get('/keycloak/role'); res.data.map((item) => { @@ -429,6 +474,10 @@ const useUserStore = defineStore('api-user', () => { return { data, userOption, + calculateAge, + + fetchHqOption, + fetchBrOption, fetchRoleOption, fetchList, diff --git a/src/stores/user/types.ts b/src/stores/user/types.ts index c0a8bb5d..19f3381a 100644 --- a/src/stores/user/types.ts +++ b/src/stores/user/types.ts @@ -14,15 +14,15 @@ export type User = { trainingPlace: string | null; importNationality: string | null; sourceNationality: string | null; - licenseExpireDate: string | null; - licenseIssueDate: string | null; + licenseExpireDate: Date | null; + licenseIssueDate: Date | null; licenseNo: string | null; discountCondition: string | null; gender: string; userRole: string; userType: string; - retireDate: string | null; - startDate: string | null; + retireDate: Date | null; + startDate: Date | null; registrationNo: string | null; telephoneNo: string; email: string;