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

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