From c40d7c6ebf82b9b64fd589b4b93d43fcf4014ae5 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 11 Apr 2024 22:18:41 +0700 Subject: [PATCH] feat: Personnel info form and btn --- .../person-info/MainPage.vue | 697 +++++++++--------- 1 file changed, 342 insertions(+), 355 deletions(-) diff --git a/src/pages/02_personnel-management/person-info/MainPage.vue b/src/pages/02_personnel-management/person-info/MainPage.vue index c59aedb2..8b777282 100644 --- a/src/pages/02_personnel-management/person-info/MainPage.vue +++ b/src/pages/02_personnel-management/person-info/MainPage.vue @@ -8,10 +8,14 @@ import useUserStore from 'stores/user'; import useBranchStore from 'stores/branch'; import { User } from 'stores/user/types'; -import { Branch, BranchWithChildren } from 'stores/branch/types'; +import { Branch } from 'stores/branch/types'; +import { dialog } from 'src/stores/utils'; import PersonCard from 'components/home/PersonCard.vue'; import AppBox from 'components/app/AppBox.vue'; +import FormTop from 'src/components/02_personnel-management/FormTop.vue'; +import FormName from 'src/components/02_personnel-management/FormName.vue'; +import FormByType from 'src/components/02_personnel-management/FormByType.vue'; import useAddressStore, { District, Province, @@ -32,9 +36,8 @@ const currentUser = ref(); const currentUserBranch = ref([]); const currentHQ = ref(); const currentBR = ref(); - -const hq = ref([]); -const br = ref([]); +const isEdit = ref(false); +const formRef = ref(); async function getCurrentUser() { if (typeof route.params.id !== 'string') return; @@ -67,23 +70,6 @@ async function getUserBranch() { } } -async function getHQ() { - const res = await branchStore.fetchList({ - filter: 'head', - pageSize: 9999, - }); - if (res) hq.value = res.result; -} - -async function getBR() { - if (!currentHQ.value) return; - - const res = await branchStore.fetchById(currentHQ.value, { - includeSubBranch: true, - }); - if (res) br.value = res.branch; -} - const opts = reactive<{ province: Province[]; district: District[]; @@ -113,18 +99,55 @@ async function getSubDistrict() { if (result) opts.subDistrict = result; } +function triggerEdit(id?: string) { + if (!id) return; + isEdit.value = true; + console.log('Edit!'); +} + +function onSubmit() { + dialog({ + color: 'primary', + icon: 'mdi-pencil-outline', + title: 'ยืนยันการแก้ไขข้อมูล', + actionText: 'ตกลง', + persistent: true, + message: 'คุณต้องการแก้ไขข้อมูล ใช่หรือไม่', + action: async () => { + console.log('Submit!'); + }, + }); +} + +function onDelete(id?: string) { + if (!id) return; + dialog({ + color: 'negative', + icon: 'mdi-trash-can-outline', + title: 'ยืนยันการลบข้อมูล', + actionText: 'ตกลง', + persistent: true, + message: 'คุณต้องการลบข้อมูล ใช่หรือไม่', + action: async () => { + console.log('Delete!'); + }, + }); +} + onMounted(async () => { - getCurrentUser(); - getHQ(); - getProvince(); + await getCurrentUser(); + await getUserBranch(); + await userStore.fetchHqOption(); + if (!currentHQ.value) return; + await userStore.fetchBrOption(currentHQ.value); + await getProvince(); + if (userStore.userOption.roleOpts.length === 0) { userStore.fetchRoleOption(); } }); watch(() => route.params.id, getCurrentUser); -watch(currentUser, getUserBranch); -watch(currentHQ, getBR); watch(() => currentUser.value?.provinceId, getDistrict); watch(() => currentUser.value?.districtId, getSubDistrict); @@ -149,339 +172,303 @@ watch(() => currentUser.value?.districtId, getSubDistrict); class="q-pa-md info-bg" :style="`background-image: url(/personnel-info-bg-${$q.dark.isActive ? 'dark' : 'light'}.png)`" > -
-
- -
-
- - - แก้ไขข้อมูล - -
-
- - - ลบข้อมูล - -
-
-
- - -
- - - - - - - - - - - + +
+
+ + + แก้ไขข้อมูล + + +
-
{{ $t('address') }}
- - - - - - - -
{{ $t('address') }} EN
- - - - - - +
+ + + ลบข้อมูล + + +
+
-
-
+ + +
+ + +
{{ $t('address') }}
+ + + + + + + +
{{ $t('address') }} EN
+ + + + + + + +
+
+ + @@ -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);