diff --git a/src/modules/01_metadata/components/calendar/calendarMain.vue b/src/modules/01_metadata/components/calendar/calendarMain.vue index b144fc5c..177dfc7b 100644 --- a/src/modules/01_metadata/components/calendar/calendarMain.vue +++ b/src/modules/01_metadata/components/calendar/calendarMain.vue @@ -99,7 +99,13 @@ const updateYear = async (e: number) => { * ฟังก์ชันปุ่มเพิ่มวันหยุดแบบเลือกวันได้ */ const addCalendar = () => { - dateAdd.value = [new Date(), new Date()]; + const today = new Date(); + const { year } = dateMonth.value; + + dateAdd.value = [ + new Date(year, today.getMonth(), today.getDate()), + new Date(year, today.getMonth(), today.getDate()), + ]; name.value = ""; category.value = "all"; isSpecial.value = true; diff --git a/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue b/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue index 7077acc7..28740568 100644 --- a/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue +++ b/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue @@ -15,12 +15,10 @@ import type { Avatar } from "@/components/information/interface/response/avatar" import { useCounterMixin } from "@/stores/mixin"; /** use*/ -const route = useRoute(); + const mixin = useCounterMixin(); -const router = useRouter(); const $q = useQuasar(); -const retireDate = ref(); -const { showLoader, hideLoader, messageError, date2Thai } = mixin; +const { messageError, date2Thai } = mixin; const isEmployee = defineModel("isEmployee", { type: String }); const empType = ref("officer"); @@ -42,6 +40,9 @@ const emit = defineEmits(["update:modal"]); /** ตัวแปร*/ const modal = ref(false); +const isloadInformation = ref(true); +const isloadGoverment = ref(true); +const retireDate = ref(); const avatar = reactive({ avatar: "", fullname: "", @@ -94,7 +95,7 @@ function calculateAge(birthDate: Date | null) { * @param id profileID */ async function fetchInformation(id: string) { - showLoader(); + isloadInformation.value = true; await http .get( config.API.orgProfileAdminById( @@ -111,9 +112,7 @@ async function fetchInformation(id: string) { imformation.birthDate = data.birthDate ? date2Thai(data.birthDate) : "-"; imformation.age = data.birthDate ? calculateAge(data.birthDate) : "-"; imformation.gender = data.gender ?? "-"; - avatar.fullname = `${data.prefix}${data.firstName} ${data.lastName}`; - avatar.position = data.position ? data.position : "-"; if (data.avatarName) { await fetchProfile(data.id as string, data.avatarName); @@ -125,7 +124,7 @@ async function fetchInformation(id: string) { messageError($q, err); }) .finally(() => { - hideLoader(); + isloadInformation.value = false; }); } @@ -134,7 +133,7 @@ async function fetchInformation(id: string) { * @param id profileID */ async function fetchProfileGov(id: string) { - showLoader(); + isloadGoverment.value = true; await http .get( config.API.profileNewGovernmentCard( @@ -158,19 +157,21 @@ async function fetchProfileGov(id: string) { goverment.positionExecutiveSide = data.positionExecutiveField !== "" ? data.positionExecutiveField : "-"; }) - .catch((err) => { messageError($q, err); }) .finally(() => { - hideLoader(); + isloadGoverment.value = false; }); } -// function redirecToRegistry() { -// router.push(`/registry-${empType.value}/${props.id}`); -// modal.value = false; -// } +async function fetchProfile(id: string, avatarName: string) { + await http + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) + .then(async (res) => { + avatar.avatar = await res.data.downloadUrl; + }); +} watch( () => props.modal, @@ -178,12 +179,6 @@ watch( modal.value = props.modal ? props.modal : false; if (modal.value) { if (props.id) { - // empType.value = - // route.name === "appoint-employee-detail" || - // isEmployee.value == "EMPLOYEE" - // ? "employee" - // : "officer"; - await Promise.all([ fetchInformation(props.id), fetchProfileGov(props.id), @@ -198,14 +193,6 @@ watch(modal, (newValue) => { emit("update:modal", false); } }); - -async function fetchProfile(id: string, avatarName: string) { - await http - .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) - .then(async (res) => { - avatar.avatar = await res.data.downloadUrl; - }); -}