refactor code (ยังไม่หมด)
This commit is contained in:
parent
ab4189e6ed
commit
32d4de7075
21 changed files with 309 additions and 109 deletions
|
|
@ -43,20 +43,6 @@ export const useComplainstDataStore = defineStore(
|
|||
);
|
||||
const consideredAgencytoptions = ref<DataOption[]>([]);
|
||||
const organizationIdOp = ref<DataOption[]>([]);
|
||||
|
||||
const statusTothai = (val: string) => {
|
||||
switch (val) {
|
||||
case "NEW":
|
||||
return "ใหม่";
|
||||
case "STOP":
|
||||
return "ยุติเรื่อง";
|
||||
case "SEND_INVESTIGATE":
|
||||
return "มีมูลส่งไปสืบสวนแล้ว";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
const levelConsiderationtOptions = ref<DataOption[]>([
|
||||
{ id: "NORMAL", name: "ปกติ" },
|
||||
{ id: "URGENT", name: "ด่วน" },
|
||||
|
|
@ -74,6 +60,29 @@ export const useComplainstDataStore = defineStore(
|
|||
{ id: "SEND_INVESTIGATE", name: "มีมูลส่งไปสืบสวนแล้ว" },
|
||||
]);
|
||||
|
||||
/**
|
||||
* แปลง status เป็น Text
|
||||
* @param val status
|
||||
* @returns text
|
||||
*/
|
||||
function statusTothai(val: string) {
|
||||
switch (val) {
|
||||
case "NEW":
|
||||
return "ใหม่";
|
||||
case "STOP":
|
||||
return "ยุติเรื่อง";
|
||||
case "SEND_INVESTIGATE":
|
||||
return "มีมูลส่งไปสืบสวนแล้ว";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* แปลง option ที่รับมาเป็น ไทย
|
||||
* @param val ค่าที่ได้จาก API
|
||||
* @returns ส่ง name ที่ id ตรงกันออกไป
|
||||
*/
|
||||
function levelConsiderationTran(val: string) {
|
||||
return (
|
||||
levelConsiderationtOptions.value.find((v: any) => v.id === val)?.name ??
|
||||
|
|
@ -81,11 +90,21 @@ export const useComplainstDataStore = defineStore(
|
|||
);
|
||||
}
|
||||
|
||||
function selectComplainantTpye(list: any) {
|
||||
/**
|
||||
* ฟังชั่น เก็บค่า options โดยแบ่งเก็บไว้ ตัวหลัก กับตัวรอง
|
||||
* @param list ชุดข้อมูล options
|
||||
*/
|
||||
function selectComplainantType(list: any) {
|
||||
optionListNameMain.value = list;
|
||||
optionListName.value = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟิลเตอร์ตาม text ใน input
|
||||
* @param val text
|
||||
* @param update ฟังชั่น qursar
|
||||
* @param type ค่า type ที่กำหนดไว้เอาไว้ แยกประเภท
|
||||
*/
|
||||
function filterSelector(val: string, update: Function, type: string) {
|
||||
update(() => {
|
||||
const needle = val.toLowerCase();
|
||||
|
|
@ -105,6 +124,10 @@ export const useComplainstDataStore = defineStore(
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ดึงข้อมูล เฉพาะ สังกัด โดย เก็บ id/name
|
||||
* @param data ชุดข้อมูลรวม
|
||||
*/
|
||||
function ocListFn(data: ocListType[]) {
|
||||
let dataList: DataOption[] = data.map((item: ocListType) => ({
|
||||
id: item.organizationId,
|
||||
|
|
@ -118,7 +141,7 @@ export const useComplainstDataStore = defineStore(
|
|||
visibleColumns,
|
||||
columns,
|
||||
fetchComplainst,
|
||||
selectComplainantTpye,
|
||||
selectComplainantType,
|
||||
filterSelector,
|
||||
complainantoptions,
|
||||
consideredAgencytoptions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue