Refactoring code module 04_registryPerson

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-18 17:24:21 +07:00
parent 1164d79122
commit eeb92dfb5d
46 changed files with 1935 additions and 2230 deletions

View file

@ -1,15 +1,19 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import {
checkPermission,
checkPermissionCreate,
checkPermissionList,
} from "@/utils/permissions";
import { useRoute, useRouter } from "vue-router";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import axios from "axios";
import avatar from "@/assets/avatar_user.jpg";
/**
* importType
*/
@ -22,16 +26,10 @@ import type { ResponseObject } from "@/modules/04_registryPerson/interface/respo
/**
* importComponents
*/
import CardNotPermission from "@/components/CardNotPermission.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import TabMain from "@/modules/04_registryPerson/components/detail/TabMain.vue";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
import avatar from "@/assets/avatar_user.jpg";
import CardNotPermission from "@/components/CardNotPermission.vue";
/**
* use
*/
@ -51,23 +49,22 @@ const {
pathRegistryEmp,
} = useCounterMixin();
const isPermission = ref<boolean | null>(null);
const notPermissionMsg = ref<string>("");
const isPermission = ref<boolean | null>(null); //
const notPermissionMsg = ref<string>(""); //
const profileId = ref<string>(route.params.id.toString()); //id profile
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? "")); //
/** ถึงเเก่กรรม */
const dialogPassaway = ref<boolean>(false);
const placeDeathCertificate = ref("");
const deathCertificateNo = ref("");
const dateDeath = ref<Date>(new Date());
const filePassaway = ref<any>(null);
const reasonDeath = ref("");
const dialogPassaway = ref<boolean>(false); //
const filePassaway = ref<any>(null); //
const deathCertificateNo = ref(""); //
const dateDeath = ref<Date>(new Date()); //
const placeDeathCertificate = ref(""); //
const reasonDeath = ref(""); //
const dialogImage = ref<boolean>(false);
const profileId = ref<string>(route.params.id.toString());
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const formDetail = ref<ResponseObject>();
const dialogImage = ref<boolean>(false); //
const formDetail = ref<ResponseObject>(); //
//
const itemsMenu = ref<DataOptionSys[]>([
{
id: "1",
@ -100,7 +97,7 @@ const itemsMenu = ref<DataOptionSys[]>([
system: "SYS_PLACEMENT_OTHER",
},
]);
//
const itemsMenuEmployee = ref<DataOptionSys[]>([
{
id: "1",
@ -114,15 +111,14 @@ const itemsMenuEmployee = ref<DataOptionSys[]>([
},
]);
const uploadUrl = ref<string>("");
const fileName = ref<string>("");
const profilePicture = ref<string>("");
const profileFile = ref();
const uploadUrl = ref<string>(""); //URL
const fileName = ref<string>(""); //
const profilePicture = ref<string>(""); //
const profileFile = ref(); //
const input = document.createElement("input");
const activeImage = ref<any | null>(null);
const images = ref<any[]>([]);
const imagesAlldata = ref<any[]>([]);
input.type = "file";
input.accept = ".jpg,.png,.tif,.pic";
@ -140,6 +136,9 @@ function imageActive(n: any) {
activeImage.value = n;
}
/**
* งกนอปโหลด
*/
function uploadImg() {
http
.post(config.API.orgProfileAvatarbyType(empType.value), {
@ -156,6 +155,10 @@ function uploadImg() {
.finally(() => {});
}
/**
* งกนสราง path ปโหลไฟล
* @param path
*/
function uploadProfile(path: string) {
http
.post(config.API.fileByPath(path), {
@ -179,6 +182,11 @@ function uploadProfile(path: string) {
});
}
/**
* งกนอปโหลด
* @param uploadUrl path ปโหลไฟล
* @param file ไฟล
*/
function uploadFileURL(uploadUrl: string, file: any) {
showLoader();
axios
@ -199,8 +207,11 @@ function uploadFileURL(uploadUrl: string, file: any) {
});
}
/**
* งกนดงขอมลรปโปรไฟล
* @param id โปรไฟล
*/
function fetchProfile(id: string) {
// showLoader();
http
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value))
.then(async (res) => {
@ -209,9 +220,6 @@ function fetchProfile(id: string) {
.catch(() => {
profilePicture.value = avatar;
});
// .finally(() => {
// hideLoader();
// });
}
const reasonStatus = ref<boolean>(false);
@ -251,6 +259,9 @@ const reasonOptions = ref<DataOption[]>([
},
]);
/**
* งกนดงขอมลสวนต
*/
async function fetchDataPersonal() {
showLoader();
await http
@ -298,6 +309,9 @@ async function fetchDataPersonal() {
});
}
/**
* งกนดาวนโหลดไฟล "..7/..1 หร ประวแบบย
*/
function onClickDownloadKp7(type: string) {
showLoader();
const url =
@ -333,7 +347,7 @@ function onClickDownloadKp7(type: string) {
}
/**
* วยราชการ
* งกนออกคำสวยราชการ
*/
function helpPost() {
const formData = new FormData();
@ -356,7 +370,7 @@ function helpPost() {
}
/**
* งตวกล
* งกนออกคำสงตวกล
*/
function repatriationPost() {
const formData = new FormData();
@ -379,7 +393,7 @@ function repatriationPost() {
}
/**
* แตงตงเลอน
* งกนออกคำสแตงตงเลอน
*/
function appointPost() {
const formData = new FormData();
@ -402,14 +416,14 @@ function appointPost() {
}
/**
* งเเกกรรม
* งกนออกคำสงเเกกรรม
*/
function clickPassaway() {
dialogPassaway.value = true;
}
/**
* ใหออกจากราชการ
* งกนออกคำสใหออกจากราชการ
*/
function outPost() {
const formData = new FormData();
@ -432,7 +446,7 @@ function outPost() {
}
/**
* นๆ
* งกนออกคำสนๆ
*/
function otherPost() {
const formData = new FormData();
@ -454,6 +468,9 @@ function otherPost() {
});
}
/**
* งกนออกคำสงปรบระดบชนงาน - าย
*/
function appointEmployeePost() {
const formData = new FormData();
formData.append("id", profileId.value);
@ -474,12 +491,8 @@ function appointEmployeePost() {
});
}
function closePassaway() {
dialogPassaway.value = false;
}
/**
* function นยนบนทกขอมลถงแกกรรม
* งกนยนยนบนทกขอมลถงแกกรรม
*/
function clickSaveDeceased() {
dialogConfirm($q, async () => {
@ -507,7 +520,14 @@ function clickSaveDeceased() {
}
/**
* function เป popup เลอกรปภาพ
* งกนป popup งแกกรรม
*/
function closePassaway() {
dialogPassaway.value = false;
}
/**
* งกนเป popup เลอกรปภาพ
*/
function openDialogImg() {
dialogImage.value = true;
@ -515,7 +535,7 @@ function openDialogImg() {
}
/**
* function เรยกขอมลร
* งกเรยกขอมลร
*/
function getImage() {
showLoader();
@ -538,7 +558,7 @@ function getImage() {
}
/**
* function เรยกขอมลร
* งกเรยกขอมลร
* @param dataList
*/
function getImg(dataList: any) {
@ -559,7 +579,7 @@ function getImg(dataList: any) {
}
/**
* funciton Popup เลอกรปภาพ
* งก Popup เลอกรปภาพ
*/
function closeImage() {
dialogImage.value = false;
@ -568,7 +588,7 @@ function closeImage() {
}
/**
* funciotn นยนการลบร
* งกนยนการลบร
* @param id ปภาพ
*/
function deletePhoto(id: string) {
@ -595,7 +615,7 @@ function deletePhoto(id: string) {
}
/**
* function นยนการเลอกร
* งกนยนการเลอกร
*/
function selectAvatarHistory() {
if (activeImage.value == null) {