refactor code (ยังไม่หมด)

This commit is contained in:
setthawutttty 2024-01-15 17:52:25 +07:00
parent ab4189e6ed
commit 32d4de7075
21 changed files with 309 additions and 109 deletions

View file

@ -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,