2024-03-07 13:46:12 +07:00
|
|
|
import { defineStore } from "pinia";
|
2025-03-17 16:01:02 +07:00
|
|
|
import { ref, reactive, computed } from "vue";
|
2025-03-18 15:25:08 +07:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2025-03-17 16:01:02 +07:00
|
|
|
import { useRoute } from "vue-router";
|
2024-03-07 13:46:12 +07:00
|
|
|
|
2024-08-01 12:12:28 +07:00
|
|
|
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
|
2024-03-07 13:46:12 +07:00
|
|
|
import type {
|
|
|
|
|
DataType,
|
|
|
|
|
DataLevel,
|
2024-08-01 12:12:28 +07:00
|
|
|
} from "@/modules/04_registryPerson/interface/response/Main";
|
2024-08-13 18:05:23 +07:00
|
|
|
import type { FormFilter } from "@/modules/04_registryPerson/interface/request/Main";
|
2024-03-07 13:46:12 +07:00
|
|
|
|
|
|
|
|
export const useRegistryNewDataStore = defineStore("registryNew", () => {
|
2025-03-17 16:01:02 +07:00
|
|
|
const route = useRoute();
|
2025-05-02 13:52:17 +07:00
|
|
|
const tab = ref<string>("1");
|
2025-03-17 16:01:02 +07:00
|
|
|
const routerName = ref<any>();
|
|
|
|
|
const searchTypeOption = computed<DataOption[]>(() => {
|
|
|
|
|
return [
|
|
|
|
|
{ id: "fullName", name: "ชื่อ-นามสกุล" },
|
|
|
|
|
{ id: "citizenId", name: "เลขประจำตัวประชาชน" },
|
|
|
|
|
{ id: "position", name: "ตำแหน่งในสายงาน" },
|
|
|
|
|
{
|
|
|
|
|
id: "posNo",
|
2025-06-13 17:42:22 +07:00
|
|
|
name:
|
|
|
|
|
route.name === "registryNew" ||
|
|
|
|
|
route.name === "registryRetireOfficer"
|
|
|
|
|
? "เลขที่ตำแหน่ง"
|
|
|
|
|
: "ตำแหน่งเลขที่",
|
2025-03-17 16:01:02 +07:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
});
|
2024-03-08 10:49:49 +07:00
|
|
|
const employeeClassOps = ref<DataOption[]>([
|
|
|
|
|
{ id: "officer", name: "ข้าราชการ กทม.สามัญ" },
|
|
|
|
|
{ id: "perm", name: "ลูกจ้างประจำ" },
|
2024-06-05 11:21:58 +07:00
|
|
|
// { id: "temp", name: "ลูกจ้างชั่วคราว" },
|
2024-03-08 10:49:49 +07:00
|
|
|
]);
|
2025-02-19 13:10:35 +07:00
|
|
|
const citizenId = ref<string>("");
|
2024-03-08 10:49:49 +07:00
|
|
|
const posTypeOps = ref<DataOption[]>([]);
|
|
|
|
|
const posTypeMain = ref<DataType[]>([]);
|
|
|
|
|
const posLevelOps = ref<DataOption[]>([]);
|
|
|
|
|
const yearOps = ref<DataOption[]>([]);
|
2024-06-24 17:54:53 +07:00
|
|
|
const mode = ref<string>("table");
|
2024-10-29 14:41:01 +07:00
|
|
|
const isLeave = ref<boolean>(false);
|
|
|
|
|
const tabs = ref<string>("Main");
|
|
|
|
|
const tabsManu = ref<DataOption[]>([
|
|
|
|
|
{ name: "ข้อมูลส่วนตัว", id: "Main" },
|
|
|
|
|
{ name: "ข้อมูลการพัฒนารายบุคคล (IDP)", id: "IDP" },
|
|
|
|
|
]);
|
2024-03-07 13:46:12 +07:00
|
|
|
function fetchType(data: DataType[]) {
|
2024-03-08 10:49:49 +07:00
|
|
|
posTypeMain.value = data;
|
2024-11-22 18:04:12 +07:00
|
|
|
|
2024-03-07 13:46:12 +07:00
|
|
|
const list: DataOption[] = data.map((e: DataType) => ({
|
|
|
|
|
id: e.id,
|
|
|
|
|
name: e.posTypeName,
|
|
|
|
|
}));
|
2024-03-08 10:49:49 +07:00
|
|
|
posTypeOps.value = list;
|
2024-03-07 13:46:12 +07:00
|
|
|
}
|
2024-11-22 18:04:12 +07:00
|
|
|
function fetchLevel(data: DataLevel[], shortName: string = "") {
|
2024-03-07 13:46:12 +07:00
|
|
|
const list: DataOption[] = data.map((e: DataLevel) => ({
|
|
|
|
|
id: e.id,
|
2024-11-29 10:11:38 +07:00
|
|
|
name: shortName ? `${shortName} ${e.posLevelName}` : e.posLevelName,
|
2024-03-07 13:46:12 +07:00
|
|
|
}));
|
2024-05-17 15:50:22 +07:00
|
|
|
const seen = new Set();
|
|
|
|
|
posLevelOps.value = list.filter((item: DataOption) => {
|
|
|
|
|
if (seen.has(item.name)) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
seen.add(item.name);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-03-07 13:46:12 +07:00
|
|
|
}
|
2024-08-13 18:05:23 +07:00
|
|
|
|
|
|
|
|
const formFilter = reactive<FormFilter>({
|
|
|
|
|
page: 1,
|
|
|
|
|
pageSize: 12,
|
|
|
|
|
keyword: "",
|
|
|
|
|
type: "officer",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
retireYear: "",
|
|
|
|
|
rangeYear: { min: 0, max: 60 },
|
|
|
|
|
isShowRetire: false,
|
|
|
|
|
isProbation: false,
|
2024-09-04 12:21:51 +07:00
|
|
|
isAll: true,
|
2024-09-04 14:37:39 +07:00
|
|
|
nodeId: null,
|
|
|
|
|
node: null,
|
2024-09-05 10:07:52 +07:00
|
|
|
searchType: "fullName",
|
2025-01-31 11:30:24 +07:00
|
|
|
retireType: null,
|
2025-02-19 13:10:35 +07:00
|
|
|
dateAppoint: "",
|
2024-08-13 18:05:23 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const labelOption = reactive({
|
|
|
|
|
type: "ข้าราชการ กทม.สามัญ",
|
|
|
|
|
posType: "ทั้งหมด",
|
|
|
|
|
posLevel: "ทั้งหมด",
|
|
|
|
|
retireYear: "",
|
2024-08-14 16:09:05 +07:00
|
|
|
node: "เลือกหน่วยงาน",
|
2025-01-31 11:30:24 +07:00
|
|
|
retireType: "ทั้งหมด",
|
2025-02-20 13:33:26 +07:00
|
|
|
sortName: "ลำดับการแสดงผล",
|
2024-08-13 18:05:23 +07:00
|
|
|
});
|
|
|
|
|
|
2025-01-30 17:07:04 +07:00
|
|
|
function convertTypeRetired(val: string) {
|
|
|
|
|
const newVal = val?.toLocaleUpperCase();
|
|
|
|
|
switch (newVal) {
|
|
|
|
|
case "RETIRE":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "เกษียณ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "RETIRE_RESIGN":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ลาออกจากราชการ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "RETIRE_DECEASED":
|
|
|
|
|
return "ถึงแก่กรรม ";
|
|
|
|
|
case "RETIRE_OUT":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ให้ออกจากราชการ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "DISCIPLINE_RESULT_REMOVE":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ปลดออกจากราชการ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "DISCIPLINE_RESULT_DISMISS":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ไล่ออกจากราชการ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "DISCIPLINE_SUSPEND":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ถูกพักจากราชการ";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "PROBATION_REPORT":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ผลการทดลองฯ ต่ำกว่ามาตรฐานที่กำหนด";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "PLACEMENT_TRANSFER":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "โอนออก";
|
2025-01-30 17:07:04 +07:00
|
|
|
case "RETIRE_RESIGN_EMP":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ลาออกจากราชการ";
|
2025-02-20 16:30:52 +07:00
|
|
|
case "RETIRE_OUT_EMP":
|
2025-02-20 17:31:15 +07:00
|
|
|
return "ให้ออกจากราชการ";
|
|
|
|
|
case "DISCIPLINE_TEMP_SUSPEND":
|
|
|
|
|
return "ให้ออกจากราชการไว้ก่อน";
|
2025-01-30 17:07:04 +07:00
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 11:30:24 +07:00
|
|
|
const retireTypeOps = ref<DataOption[]>([
|
|
|
|
|
{ id: "RETIRE", name: "เกษียณ" },
|
|
|
|
|
{ id: "RETIRE_DECEASED", name: "ถึงแก่กรรม" },
|
2025-02-20 17:31:15 +07:00
|
|
|
{ id: "RETIRE_RESIGN", name: "ลาออกจากราชการ" },
|
2025-01-31 11:30:24 +07:00
|
|
|
{ id: "RETIRE_OUT", name: "ให้ออกจากราชการ" },
|
|
|
|
|
{ id: "DISCIPLINE_RESULT_REMOVE", name: "ปลดออกจากราชการ" },
|
|
|
|
|
{ id: "DISCIPLINE_RESULT_DISMISS", name: "ไล่ออกจากราชการ" },
|
|
|
|
|
{ id: "DISCIPLINE_SUSPEND", name: "ถูกพักจากราชการ" },
|
2025-02-20 17:31:15 +07:00
|
|
|
{ id: "PROBATION_REPORT", name: "ผลการทดลองฯ ต่ำกว่ามาตรฐานที่กำหนด" },
|
|
|
|
|
{ id: "PLACEMENT_TRANSFER", name: "โอนออก" },
|
|
|
|
|
{ id: "DISCIPLINE_TEMP_SUSPEND", name: "ให้ออกจากราชการไว้ก่อน" },
|
2025-01-31 11:30:24 +07:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const retireTypeEmpOps = ref<DataOption[]>([
|
|
|
|
|
{ id: "RETIRE", name: "เกษียณ" },
|
|
|
|
|
{ id: "RETIRE_DECEASED", name: "ถึงแก่กรรม" },
|
2025-02-20 17:31:15 +07:00
|
|
|
{ id: "RETIRE_RESIGN_EMP", name: "ลาออกจากราชการ" },
|
2025-02-20 16:30:52 +07:00
|
|
|
{ id: "RETIRE_OUT_EMP", name: "ให้ออกจากราชการ" },
|
2025-01-31 11:30:24 +07:00
|
|
|
]);
|
|
|
|
|
|
2025-02-19 13:10:35 +07:00
|
|
|
const displayOrderOps = ref<DataOption[]>([
|
2025-02-19 17:39:45 +07:00
|
|
|
{ id: "DESC", name: "เรียงตามวันที่บรรจุแต่งตั้ง (ล่าสุด-เก่า)" },
|
|
|
|
|
{ id: "ASC", name: "เรียงตามวันที่บรรจุแต่งตั้ง (เก่า-ล่าสุด)" },
|
2025-02-19 13:10:35 +07:00
|
|
|
]);
|
|
|
|
|
|
2025-03-18 15:25:08 +07:00
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันสร้าง Path อัพโหลดไฟล์
|
|
|
|
|
* @param group กลุ่มไฟล์
|
|
|
|
|
* @param profileId id
|
|
|
|
|
* @param id subId
|
|
|
|
|
* @returns Path อัพโหลดไฟล์
|
|
|
|
|
*/
|
|
|
|
|
async function createPathUploadFlie(
|
|
|
|
|
group: string,
|
|
|
|
|
profileId: string,
|
|
|
|
|
id: string
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
const res = await http.post(
|
|
|
|
|
config.API.subFile("ทะเบียนประวัติ", group, profileId, id),
|
|
|
|
|
{
|
|
|
|
|
replace: true,
|
|
|
|
|
fileList: [
|
|
|
|
|
{
|
|
|
|
|
fileName: "เอกสารหลักฐาน",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return res.data["เอกสารหลักฐาน"].uploadUrl;
|
|
|
|
|
} catch (err) {
|
2025-06-05 15:11:23 +07:00
|
|
|
console.log(err);
|
2025-03-18 15:25:08 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันเรียก Path อัพโหลดไฟล์
|
|
|
|
|
* @param group กลุ่มไฟล์
|
|
|
|
|
* @param profileId id
|
|
|
|
|
* @param id subId
|
|
|
|
|
* @returns ข้อมูลไฟล์
|
|
|
|
|
*/
|
|
|
|
|
async function getPathUploadFlie(
|
|
|
|
|
group: string,
|
|
|
|
|
profileId: string,
|
|
|
|
|
id: string
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
const res = await http.get(
|
|
|
|
|
config.API.subFileByFileName(
|
|
|
|
|
"ทะเบียนประวัติ",
|
|
|
|
|
group,
|
|
|
|
|
profileId,
|
|
|
|
|
id,
|
|
|
|
|
"เอกสารหลักฐาน"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
return res.data;
|
|
|
|
|
} catch (err) {
|
2025-06-05 15:11:23 +07:00
|
|
|
console.log(err);
|
2025-03-18 15:25:08 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันอัพโหลดไฟล์
|
|
|
|
|
* @param uploadUrl Path อัพโหลดไฟล์
|
|
|
|
|
* @param file ไฟล์
|
|
|
|
|
*/
|
|
|
|
|
async function uploadFile(uploadUrl: string, file: any) {
|
|
|
|
|
try {
|
|
|
|
|
await axios.put(uploadUrl, file, {
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": file.type,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
2025-06-05 15:11:23 +07:00
|
|
|
console.log(err);
|
2025-03-18 15:25:08 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-07 13:46:12 +07:00
|
|
|
return {
|
|
|
|
|
fetchType,
|
|
|
|
|
fetchLevel,
|
2024-03-08 10:49:49 +07:00
|
|
|
posTypeMain,
|
|
|
|
|
searchTypeOption,
|
|
|
|
|
employeeClassOps,
|
|
|
|
|
posTypeOps,
|
|
|
|
|
posLevelOps,
|
|
|
|
|
yearOps,
|
|
|
|
|
mode,
|
2024-08-13 18:05:23 +07:00
|
|
|
formFilter,
|
|
|
|
|
labelOption,
|
2024-10-29 14:41:01 +07:00
|
|
|
isLeave,
|
|
|
|
|
tabs,
|
|
|
|
|
tabsManu,
|
2025-01-30 17:07:04 +07:00
|
|
|
convertTypeRetired,
|
2025-01-31 11:30:24 +07:00
|
|
|
retireTypeOps,
|
|
|
|
|
retireTypeEmpOps,
|
2025-02-19 13:10:35 +07:00
|
|
|
citizenId,
|
|
|
|
|
displayOrderOps,
|
2025-03-17 16:01:02 +07:00
|
|
|
routerName,
|
2025-03-18 15:25:08 +07:00
|
|
|
createPathUploadFlie,
|
|
|
|
|
getPathUploadFlie,
|
|
|
|
|
uploadFile,
|
2025-06-05 15:11:23 +07:00
|
|
|
tab,
|
2024-03-07 13:46:12 +07:00
|
|
|
};
|
|
|
|
|
});
|