From ee66e825bbb80f8a54996beea6831db4ff13c3b3 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 11 Apr 2024 22:17:24 +0700 Subject: [PATCH 1/5] refactor: edit form use FormComponent (name, top, byType) instead --- .../02_personnel-management/FormByType.vue | 307 ++++++++++ .../02_personnel-management/FormName.vue | 56 ++ .../02_personnel-management/FormTop.vue | 124 ++++ src/components/FormDialog.vue | 10 +- .../02_personnel-management/MainPage.vue | 535 +++--------------- 5 files changed, 565 insertions(+), 467 deletions(-) create mode 100644 src/components/02_personnel-management/FormByType.vue create mode 100644 src/components/02_personnel-management/FormName.vue create mode 100644 src/components/02_personnel-management/FormTop.vue 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); From 477c1354875cdb24c6eb797213a6ad51bd355ffb Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 11 Apr 2024 22:19:14 +0700 Subject: [PATCH 3/5] fix: personnel status --- src/components/home/PersonCard.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/home/PersonCard.vue b/src/components/home/PersonCard.vue index d590e29e..80261e3b 100644 --- a/src/components/home/PersonCard.vue +++ b/src/components/home/PersonCard.vue @@ -109,12 +109,14 @@ const status = ref(false); dense color="primary" size="xs" - v-model="status" + :model-value="!v.disabled" val="xs" padding="none" /> - ปิดสถานะ + + {{ v.disabled ? 'เปิดสถานะ' : 'ปิดสถานะ' }} + From 8b0c0a33ac8ff0d04ff732b32831e27ad50ee160 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 11 Apr 2024 22:20:04 +0700 Subject: [PATCH 4/5] fix: userType i18n & colorformat --- src/css/app.scss | 8 +++++--- src/i18n/en-US/personnel-main-page.ts | 8 ++++---- src/i18n/th-th/personnel-main-page.ts | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/css/app.scss b/src/css/app.scss index 18c9a709..126a7c4d 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -28,7 +28,8 @@ html { --shadow-color: 220 3% 15%; --shadow-strength: 5%; - --inner-shadow-highlight: inset 0 -.5px 0 0 #fff, inset 0 .5px 0 0 rgba(0, 0, 0, .067); + --inner-shadow-highlight: inset 0 -0.5px 0 0 #fff, + inset 0 0.5px 0 0 rgba(0, 0, 0, 0.067); color: var(--foreground); background-color: var(--background); @@ -49,7 +50,8 @@ html { --shadow-color: 220 0% 100%; --shadow-strength: 25%; - --inner-shadow-highlight: inset 0 -.5px 0 0 hsla(0, 0%, 100%, .067), inset 0 .5px 0 0 rgba(0, 0, 0, .467); + --inner-shadow-highlight: inset 0 -0.5px 0 0 hsla(0, 0%, 100%, 0.067), + inset 0 0.5px 0 0 rgba(0, 0, 0, 0.467); } ::-webkit-scrollbar { @@ -111,7 +113,7 @@ html { } .app-text-muted { - color: hsl(var(--text-mute)) + color: hsl(var(--text-mute)); } .app-text-info { diff --git a/src/i18n/en-US/personnel-main-page.ts b/src/i18n/en-US/personnel-main-page.ts index 449c5947..c329c60d 100644 --- a/src/i18n/en-US/personnel-main-page.ts +++ b/src/i18n/en-US/personnel-main-page.ts @@ -4,10 +4,10 @@ export default { personnelTooltipCaption: 'Click + to add a personnel', personnelAdd: 'Add personnel', - personnelSelector1: 'Employee', - personnelSelector2: 'Courier', - personnelSelector3: 'Agent', - personnelSelector4: 'Agency', + USER: 'Employee', + MESSENGER: 'Courier', + DELEGATE: 'Delegate', + AGENCY: 'Agency', personnelStatTitle: 'Summary data of ' }; diff --git a/src/i18n/th-th/personnel-main-page.ts b/src/i18n/th-th/personnel-main-page.ts index 246be1ea..8bf9fe41 100644 --- a/src/i18n/th-th/personnel-main-page.ts +++ b/src/i18n/th-th/personnel-main-page.ts @@ -4,10 +4,10 @@ export default { personnelTooltipCaption: 'คลิก + เพื่อเพิ่มบุคลากร', personnelAdd: 'เพิ่มข้อมูลบุคลากร', - personnelSelector1: 'พนักงาน', - personnelSelector2: 'พนักงานส่งเอกสาร', - personnelSelector3: 'ตัวแทน', - personnelSelector4: 'เอเจนซี่', + USER: 'พนักงาน', + MESSENGER: 'พนักงานส่งเอกสาร', + DELEGATE: 'ตัวแทน', + AGENCY: 'เอเจนซี่', personnelStatTitle: 'สรุปจำนวนข้อมูล', }; From cf215ba717a8f6282f9f2cd5679c896cbd8f981a Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 11 Apr 2024 22:20:28 +0700 Subject: [PATCH 5/5] fix: user type and store --- src/stores/user/index.ts | 49 ++++++++++++++++++++++++++++++++++++++++ src/stores/user/types.ts | 8 +++---- 2 files changed, 53 insertions(+), 4 deletions(-) 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;