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

@ -192,7 +192,7 @@ async function getData() {
}
/**
* นทกขอม
* นทกขอมเมอแกไข
* @param data อมลจากฟอร
*/
async function onSubmit(data: any) {

View file

@ -12,7 +12,10 @@ const { showLoader, messageError, hideLoader, dialogConfirm, success } = mixin;
const $q = useQuasar();
const router = useRouter();
/** บันทึกข้อมูลเเละ route กลับหน้าหลัก */
/**
* นทกขอม ทธรณ/องทกข
* @param data ดขอม
*/
async function onSubmit(data: any) {
console.log("add", data);
const formData = new FormData();
@ -33,6 +36,7 @@ async function onSubmit(data: any) {
.post(config.API.appealAdd() + "/admin", formData)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
//
router.push(`/discipline-appealcomplain/${res.data.result}`);
})
.catch((e) => {
@ -41,7 +45,6 @@ async function onSubmit(data: any) {
.finally(async () => {
hideLoader();
});
// router.push(`/discipline-appealcomplain`);
}
</script>

View file

@ -50,9 +50,12 @@ const data = reactive<EditDataList>({
historyStatus: [historyStatusOb],
disciplineComplaint_Appeal_Docs: [fileOb],
});
/** บันทึกข้อมูลเเละ route กลับหน้าหลัก */
/**
* นทกขอม ทธรณ/องทกข
* @param data ดขอม
*/
async function onSubmit(data: any) {
console.log(data)
const dataList = {
title: data.title,
description: data.description,
@ -69,17 +72,17 @@ async function onSubmit(data: any) {
.put(config.API.appealByID(id.value), dataList)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
getData();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
getData();
hideLoader();
});
// router.push(`/discipline-appealcomplain`);
}
/** ดึงข้อมูลจาก API หน้ารายการ */
function getData() {
showLoader();
http
@ -112,8 +115,8 @@ function getData() {
hideLoader();
});
}
onMounted(() => {
// fetchData();
getData();
});
</script>

View file

@ -184,8 +184,11 @@ async function addPerson(data: any) {
toggleModal();
}
/**
* เกบค list คคลไวใน row
* @param returnData ดขอม คคล
*/
function handleSave(returnData: any) {
console.log(returnData);
modalPerson.value = false;
dataStore.rowsAdd = returnData.map((item: any) => ({
profileId: item.personId,
@ -196,6 +199,10 @@ function handleSave(returnData: any) {
}));
}
/**
* งค css ออกไปตามเงอนไข
* @param val true/false
*/
function inputEdit(val: boolean) {
return {
"full-width cursor-pointer inputgreen ": val,
@ -203,6 +210,7 @@ function inputEdit(val: boolean) {
};
}
/** อัปโหลดเอกสาร */
function uploadFile() {
/** uploadFile */
const Data = new FormData();
@ -214,7 +222,6 @@ function uploadFile() {
console.log(res);
success($q, "อัปโหลดไฟล์สำเร็จ");
props.getData();
// router.push(`/discipline/complaints`);
})
.catch((e) => {
messageError($q, e);
@ -225,10 +232,18 @@ function uploadFile() {
});
}
/**
* เปดไฟลเอกสาร
* @param link link ของไฟล
*/
function downloadFile(link: string) {
window.open(link, "_blank");
}
/**
* ลบไฟลจาก id
* @param id id ของไฟล
*/
function deleteFile(id: string) {
dialogRemove($q, () => confirmDelete(id));
}
@ -284,14 +299,17 @@ watch(props.data, async () => {
}
});
/** ปิด popup */
function close() {
modalHistory.value = false;
}
/** เปิด pop up history */
function historyStatus() {
modalHistory.value = true;
}
/** save ข้อมูล */
function onSubmit() {
dialogConfirm(
$q,
@ -318,6 +336,7 @@ function onSubmit() {
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
onMounted(() => {
dataStore.columns = columns.value;
dataStore.visibleColumns = visibleColumns.value;

View file

@ -193,25 +193,21 @@ function redirectToPageadd() {
router.push(`/discipline-appealcomplain/add`);
}
/** เปิดหน้า แก้ไข */
function editPage(id: string) {
router.push(`/discipline-appealcomplain/${id}`);
}
/** ดึงข้อมูลเมื่อ กด enter */
function filterFn() {
console.log("enter", filterKeyword.value);
getData();
}
/** ปิด pop up */
function close() {
modalStatusEdit.value = false;
}
function editStatusReturn(data: any) {
dialogConfirm($q, () => {
console.log("saveStatus");
modalStatusEdit.value = false;
});
}
/** ดึงข้อมูลเริ่มต้น */
async function getData() {
showLoader();
@ -249,6 +245,7 @@ function yearAll() {
getData();
}
/** ฟังชั่น เคลียฟิลเตอร์ */
function resetFilter() {
filterKeyword.value = "";
getData();
@ -470,7 +467,6 @@ onMounted(async () => {
:modal="modalStatusEdit"
:data="dataRow"
:close="close"
@editStatusReturn="editStatusReturn"
/>
</template>

View file

@ -198,7 +198,26 @@ const OrderType = ref<string>("");
const OrderTypeFilter1 = ref<any>([]);
const OrderTypeOption = ref<DataOption1[]>([{ id: "", name: "ทั้งหมด" }]);
const OrderTypeFilter = async () => {
//
const OrderStatus = ref<string>("ทั้งหมด");
const OrderStatusOption = ref<DataOption1[]>([
{ id: "ทั้งหมด", name: "ทั้งหมด" },
]);
const OrderStatusFilter1 = ref<DataOption1[]>([
{ id: "ทั้งหมด", name: "ทั้งหมด" },
]);
const addedOrderStatusValues: string[] = [];
//
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
function resetFilter(){
filterKeyword.value = "";
filterRef.value.focus();
};
async function OrderTypeFilter(){
await http
.get(config.API.typeOrder())
.then((res) => {
@ -218,16 +237,12 @@ const OrderTypeFilter = async () => {
});
};
//
const OrderStatus = ref<string>("ทั้งหมด");
const OrderStatusOption = ref<DataOption1[]>([
{ id: "ทั้งหมด", name: "ทั้งหมด" },
]);
const OrderStatusFilter1 = ref<DataOption1[]>([
{ id: "ทั้งหมด", name: "ทั้งหมด" },
]);
const addedOrderStatusValues: string[] = [];
const OrderStatusFilter = async () => {
/** ฟังชั่นฟิลเตอร์ตามค่า ประเภท สถานะ ปี */
async function searchFilterTable(){
stroe.filterListOrder(OrderType.value, OrderStatus.value, fiscalyear.value);
};
async function OrderStatusFilter(){
for (let data of stroe.mainData) {
const OrderStatusValue = data.orderStatusName;
@ -248,19 +263,13 @@ const OrderStatusFilter = async () => {
}
};
//
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
const resetFilter = () => {
filterKeyword.value = "";
filterRef.value.focus();
};
const searchFilterTable = async () => {
stroe.filterListOrder(OrderType.value, OrderStatus.value, fiscalyear.value);
};
const filterSelector = (val: any, update: Function, refData: string) => {
/**
* ลเตอรอมลจาก input
* @param val าทอนให input
* @param update function จาก quasar
* @param refData type กำหนด ของ input นๆ
*/
function filterSelector(val: any, update: Function, refData: string){
switch (refData) {
case "fiscalyearOP":
update(() => {

View file

@ -185,7 +185,11 @@ const pagination = ref({
rowsPerPage: 10,
});
// redirect step
/**
* งช redirect
* @param id id ออกคำส
* @param status status
*/
const redirectToPage = (id?: string, status?: string) => {
let step = 1;
switch (status) {

View file

@ -141,6 +141,10 @@ async function directorSave() {
emit("returnDirector", selected.value);
}
/**
* งค input กลบไปหนาหล
* @param value าจาก input ลเตอร
*/
function updateInput(value: any) {
emit("update:filterKeyword2", value);
}
@ -150,6 +154,11 @@ function Reset() {
emit("update:filterKeyword2", "");
}
/**
* งเลขหน กลบไปหนาหล
* @param newPagination จำนวนขอมลทองการแสดง
* @param page เลขหนาปจจ
*/
function updateProp(newPagination: any, page: number) {
// event parent component props
emit("update:pagination", newPagination, page);

View file

@ -3,7 +3,6 @@ import { ref, useAttrs } from "vue";
const attrs = ref<any>(useAttrs());
const table = ref<any>(null);
const filterRef = ref<any>(null);
/** รับ props มาจากหน้าหลัก */
const props = defineProps({

View file

@ -7,9 +7,7 @@ import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const $q = useQuasar();
const { dialogConfirm, dialogMessageNotify } = mixin;
const props = defineProps({
title: {
type: String,
@ -50,18 +48,15 @@ const props = defineProps({
});
const emit = defineEmits(["returnPerson"]);
/** หัวตาราง */
const selected = ref<any>([]);
const inspectionResults = ref<string>("");
const filter = ref<string>("");
// const inputRef = ref<any>(null);
const initialPagination = ref<any>({
descending: false,
rowsPerPage: 25,
});
/** ฟังชั่นส่งคนไปออกคำสั่ง */
function onclickSend() {
if (selected.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 บุคคล");
@ -69,7 +64,6 @@ function onclickSend() {
dialogConfirm(
$q,
async () => {
// success($q, `${props.title}`);
await emit("returnPerson", selected.value);
props.fetchData();
props.close?.();
@ -80,6 +74,7 @@ function onclickSend() {
}
}
/** ปิด pop up */
function onClickClose() {
props.close?.();
}
@ -161,12 +156,6 @@ watch([() => props.modal], () => {
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width>
<!-- <q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/> -->
</q-th>
<q-th
v-for="col in props.cols"

View file

@ -90,10 +90,18 @@ async function uploadFile() {
});
}
/**
* pop up ลบไฟล
* @param id id ของไฟลจะลบ
*/
function popupRemove(id: string) {
dialogRemove($q, () => removeFile(id));
}
/**
* งชนลบไฟล
* @param id id ของไฟล
*/
async function removeFile(id: string) {
showLoader();
await http

View file

@ -15,17 +15,6 @@ export const useAppealComplainStore = defineStore(
const mixin = useCounterMixin()
const { date2Thai } = mixin
const typeConvert = (val: string) => {
switch (val) {
case "APPEAL":
return "อุทธรณ์";
case "COMPLAIN":
return "ร้องทุกข์";
default:
return "-";
}
};
const typeOptions = ref<DataOption[]>([
{ id: "APPEAL", name: "อุทธรณ์" },
{ id: "COMPLAIN", name: "ร้องทุกข์" },
@ -54,6 +43,26 @@ export const useAppealComplainStore = defineStore(
{ id: "DONE", name: "ปิดคำร้อง" },
]);
/**
* status
* @param val status
* @returns
*/
function typeConvert(val: string){
switch (val) {
case "APPEAL":
return "อุทธรณ์";
case "COMPLAIN":
return "ร้องทุกข์";
default:
return "-";
}
};
/**
*
* @param data API
*/
function fetchAppealComplain(data: MainList[]) {
let dataList: RowList[] = data.map((e: MainList) => ({
id: e.id,
@ -72,11 +81,22 @@ export const useAppealComplainStore = defineStore(
rows.value = dataList;
console.log(rows.value)
}
/**
*
* @param data list
*/
function getRow(data: RowAddList[]) {
if (data) {
rowsAdd.value = data
}
}
/**
* status Text
* @param val status
* @returns text
*/
function statusTothai(val: string) {
switch (val) {
case "NEW":
@ -98,8 +118,6 @@ export const useAppealComplainStore = defineStore(
}
};
return {
rows,
visibleColumns,

View file

@ -44,6 +44,11 @@ export const useDisciplineChannelDataStore = defineStore(
type.value = data
}
const rows = ref<ChannelRows[]>([]);
/**
* API rows
* @param data API
*/
function fetchData(data: ChannelRows[]) {
rows.value = data;
}

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,

View file

@ -89,7 +89,10 @@ export const useDisciplineDirectorDataStore = defineStore(
},
]);
// ข้อมูลในตาราง
/**
* API
* @param data API
*/
function fetchData(data: DirectorRows[]) {
const dataList: DirectorRowsResponse[] = data.map(
(item: DirectorRows) => ({

View file

@ -253,11 +253,20 @@ export const useInvestigateDisStore = defineStore(
}
]);
/**
* status id
* @param val id API find id
* @returns name
*/
function convertStatus(val: string) {
const result = statusOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";
}
/**
* API
* @param data API
*/
async function fetchList(data: investigateDisDataRowType[]) {
let datalist: any[] = data.map((e: any) => ({
id: e.id,
@ -274,6 +283,10 @@ export const useInvestigateDisStore = defineStore(
rows.value = datalist;
}
/**
* API
* @param data API
*/
async function fecthDirector(data: directorType[]) {
let datalistDirector: responseType[] = data.map((e: directorType) => ({
id: e.id,
@ -290,6 +303,11 @@ export const useInvestigateDisStore = defineStore(
// console.log(rows2.value);
}
/**
* status text
* @param val status
* @returns text
*/
function convertRespondentType(val: string) {
switch (val) {
case "PERSON":
@ -301,6 +319,11 @@ export const useInvestigateDisStore = defineStore(
}
}
/**
* status text
* @param val status
* @returns text
*/
function convertFault(val: string) {
switch (val) {
case "NOT_SPECIFIED":
@ -314,6 +337,12 @@ export const useInvestigateDisStore = defineStore(
}
}
/**
* input
* @param val input
* @param update function quasar
* @param type type input
*/
function filterFnOptionsType(
val: string | number,
update: any,

View file

@ -19,14 +19,7 @@ const mixin = useCounterMixin();
const { date2Thai } = mixin;
const organizationIdOp = ref<DataOption[]>([]);
const consideredAgencytoptions = ref<DataOption[]>([]);
function ocListFn(data: ocListType[]) {
let dataList: DataOption[] = data.map((item: ocListType) => ({
id: item.organizationId,
name: item.organizationName,
}));
consideredAgencytoptions.value = dataList;
organizationIdOp.value = dataList;
}
/*** store ของข้อมูลสืบสวนข้อเท็จจริง */
export const useInvestigateFactStore = defineStore(
@ -177,6 +170,25 @@ export const useInvestigateFactStore = defineStore(
},
]);
/**
* id/name
* @param data
*/
function ocListFn(data: ocListType[]) {
let dataList: DataOption[] = data.map((item: ocListType) => ({
id: item.organizationId,
name: item.organizationName,
}));
consideredAgencytoptions.value = dataList;
organizationIdOp.value = dataList;
}
/**
* input
* @param val input
* @param update function quasar
* @param type type input
*/
function filterFnOptionsType(
val: string | number,
update: any,
@ -199,7 +211,12 @@ export const useInvestigateFactStore = defineStore(
});
}
/**
* input
* @param val input
* @param update function quasar
* @param type type input
*/
function filterSelector(val: string, update: Function, type: string) {
console.log(val);
update(() => {
@ -213,6 +230,11 @@ export const useInvestigateFactStore = defineStore(
});
}
/**
* API
* @param data API
*/
async function fecthList(data: ListData[]) {
rows.value = await data.map((e: ListData) => {
return {
@ -227,15 +249,20 @@ export const useInvestigateFactStore = defineStore(
e.investigationDateEnd
)}`
: "-",
investigationStatusResult:e.investigationStatusResult ? mainStore.convertStatusResult(
investigationStatusResult: e.investigationStatusResult ? mainStore.convertStatusResult(
e.investigationStatusResult
):'-',
createdAt: e.createdAt ? date2Thai(e.createdAt as Date):'-',
status: e.status ? convertStatus(e.status):'-',
) : '-',
createdAt: e.createdAt ? date2Thai(e.createdAt as Date) : '-',
status: e.status ? convertStatus(e.status) : '-',
};
});
}
/**
* status text
* @param val status
* @returns text
*/
function convertInvestigationDetail(val: string) {
const result = investigationDetailOps.value.find(
(x: any) => x.id == val
@ -243,6 +270,11 @@ export const useInvestigateFactStore = defineStore(
return result ? result : "-";
}
/**
* status text
* @param val status
* @returns text
*/
function convertStatus(val: string) {
const result = faultOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";

View file

@ -31,6 +31,12 @@ export const useReportDataStore = defineStore("DisciplineReport11", () => {
{ id: "8", name: "รายงานจำนวนข้าราชการสามัญฯ ที่กระทำความผิดทางวินัยแต่ยุติเรื่อง แยกตามตำแหน่ง" },
]);
/**
* input
* @param val input
* @param update function quasar
* @param type type input
*/
function filterFnOptionsType(val: string, update: any, type: string) {
update(() => {
const needle = val.toLowerCase();

View file

@ -245,6 +245,12 @@ export const useDisciplineResultStore = defineStore(
},
]);
/**
* input
* @param val input
* @param update function quasar
* @param type type input
*/
function filterSelector(val: string, update: Function, type: string) {
update(() => {
const needle = val.toLowerCase();
@ -256,6 +262,10 @@ export const useDisciplineResultStore = defineStore(
});
}
/**
* API
* @param data API
*/
async function fetchList(data: DataResult[]) {
const datalist: DataResultList[] = data.map((e: DataResult) => ({
id: e.id,
@ -282,7 +292,11 @@ export const useDisciplineResultStore = defineStore(
rows.value = datalist;
}
/** function สถานะ*/
/**
* status text
* @param val status
* @returns text
*/
function convertStatus(val: string) {
switch (val) {
case "DONE":

View file

@ -20,6 +20,10 @@ export const useDisciplineSuspendStore = defineStore(
{ id: "DEADLY", name: "ร้ายแรง" },
]);
/**
* API
* @param data API
*/
function getData(data: listData[]) {
console.log(data)
const dataList: dataType[] = data.map((item: listData) => ({
@ -49,6 +53,11 @@ export const useDisciplineSuspendStore = defineStore(
rows.value = dataList
}
/**
* status text
* @param val status
* @returns text
*/
const statusTothai = (val: string) => {
switch (val) {
case "WAITTING":
@ -68,10 +77,6 @@ export const useDisciplineSuspendStore = defineStore(
return "-";
}
};
function convertOffenseDetails(val: string) {
const result = offenseDetailsOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";
}
return {
rows,

View file

@ -217,6 +217,11 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
"organization",
]);
/**
* option
* @param val API
* @returns name id
*/
function convertComplaintType(val: string) {
const result = complainantoptionsMain.value.find(
(x: any) => x.id == val
@ -224,7 +229,11 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
return result ? result : "-";
}
/** function ลักษณะความผิด*/
/**
* status text
* @param val status
* @returns text
*/
function convertFault(val: string) {
switch (val) {
case "NOT_SPECIFIED":
@ -238,7 +247,11 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
}
}
/** function สถานะ*/
/**
* status text
* @param val status
* @returns text
*/
function convertStatus(val: string) {
switch (val) {
case "NEW":
@ -252,12 +265,22 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
}
}
/**
* option
* @param val API
* @returns name id
*/
function convertOffenseDetailst(val: string) {
return (
offenseDetailstOptions.value.find((x: any) => x.id == val)?.name ?? "-"
);
}
/**
* option
* @param val API
* @returns name id
*/
function convertStatusResult(val: string) {
const result = statusResultOptions.value.find(
(x: any) => x.id == val
@ -265,7 +288,10 @@ export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
return result ? result : "-";
}
/**
* POPUP
* @param data
*/
function fetchData(data: ArrayPersonAdd[]) {
rowsAdd.value = data;
}