clear code + comment
This commit is contained in:
parent
a9609d2d7f
commit
ac70090e22
19 changed files with 231 additions and 166 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue