refactor code (ยังไม่หมด)
This commit is contained in:
parent
ab4189e6ed
commit
32d4de7075
21 changed files with 309 additions and 109 deletions
|
|
@ -192,7 +192,7 @@ async function getData() {
|
|||
}
|
||||
|
||||
/**
|
||||
* บันทึกข้อมูล
|
||||
* บันทึกข้อมูลเมื่อแก้ไข
|
||||
* @param data ข้อมูลจากฟอร์ม
|
||||
*/
|
||||
async function onSubmit(data: any) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue