clear code + comment

This commit is contained in:
STW_TTTY\stwtt 2024-04-30 14:31:55 +07:00
parent a9609d2d7f
commit ac70090e22
19 changed files with 231 additions and 166 deletions

View file

@ -46,7 +46,13 @@ const nodes = ref<any[]>([]);
const filter = ref<string>("");
const expanded = ref<Array<string>>([]);
const nodeId = ref<string>("");
const modalDialog = ref<boolean>(false);
const isStatusEdit = ref<boolean>(false);
const strategicName = ref<string>("");
const levelnode = ref<number>(0);
const titleDialog = ref<string>("");
/** ดึงข้อมูล ในรูปแบบ tree */
function fetchDataTree() {
showLoader();
http
@ -63,6 +69,11 @@ function fetchDataTree() {
});
}
/**
* เพ ลบ แกไข
* @param type ประเภท node
* @param data อม
*/
function onClickAction(type: string, data: DataStrategic | null = null) {
switch (type) {
case "ADD":
@ -79,11 +90,11 @@ function onClickAction(type: string, data: DataStrategic | null = null) {
}
}
const modalDialog = ref<boolean>(false);
const isStatusEdit = ref<boolean>(false);
const strategicName = ref<string>("");
const levelnode = ref<number>(0);
const titleDialog = ref<string>("");
/**
* เป dialog
* @param status true/false
* @param data อมลยทธศาสตร
*/
function onClickOpenDialog(
status: boolean = false,
data: DataStrategic | null = null
@ -125,11 +136,13 @@ function onClickOpenDialog(
modalDialog.value = true;
}
/** ปิด dialog */
function closeDialog() {
modalDialog.value = false;
strategicName.value = "";
}
/** บันทึกข้อมูล */
function onSubmit() {
dialogConfirm($q, async () => {
const formData = {
@ -138,9 +151,6 @@ function onSubmit() {
name: strategicName.value,
};
try {
// const url = isStatusEdit.value
// ? config.API.devStrategy;
// : config.API.devStrategy;
const method = isStatusEdit.value ? "patch" : "post";
await http[method](config.API.devStrategy, formData);
fetchDataTree();
@ -154,6 +164,7 @@ function onSubmit() {
});
}
/** ลบข้อมูลตาม id */
function onDelete(data: DataStrategic) {
dialogRemove($q, () => {
showLoader();
@ -176,6 +187,7 @@ function onDelete(data: DataStrategic) {
});
}
/** ดึงข้อมูลเมื่ออยู่ในหน้า */
onMounted(() => {
fetchDataTree();
});