refactor ออกคำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-22 10:47:31 +07:00
parent 8dfa5ca02e
commit 3802d5d5a2
8 changed files with 526 additions and 916 deletions

View file

@ -109,7 +109,7 @@ const conditionData = async () => {
await fetchOrder(id);
}
};
//
const getData = async (id: string) => {
showLoader();
await http
@ -141,6 +141,7 @@ const getData = async (id: string) => {
hideLoader();
});
};
//
const fetchOrder = async (id: string) => {
await http
.get(config.API.detailOrder(id))
@ -152,6 +153,7 @@ const fetchOrder = async (id: string) => {
messageError($q, err);
});
};
//
const statuscode = computed(() => {
if (
orderTypeCode.value === "c-pm-01" ||
@ -170,10 +172,11 @@ const statuscode = computed(() => {
}
return true;
});
//
const dialogDeleteData = async (id: string) => {
dialogRemove($q, () => deleteData(id));
};
// API
const deleteData = async (id: string) => {
await http
.delete(config.API.personsOrder(id))
@ -188,9 +191,8 @@ const deleteData = async (id: string) => {
await conditionData();
});
};
//
const swapUp = async (id: string) => {
// id = personalId
await http
.put(config.API.swapUpOrder(id))
.catch((e) => {
@ -201,9 +203,8 @@ const swapUp = async (id: string) => {
hideLoader();
});
};
//
const swapDown = async (id: string) => {
// id = personalId
await http
.put(config.API.swapDownOrder(id))
.catch((e) => {
@ -216,14 +217,13 @@ const swapDown = async (id: string) => {
};
const upDown = async (value: any, up: boolean = true) => {
const indexCurrent = value.rowIndex;
if (up) {
await swapUp(value.row.personalId);
} else {
await swapDown(value.row.personalId);
}
};
//
const saveModal = () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
@ -234,12 +234,13 @@ const saveModal = () => {
}
};
const personalId = ref<string>("");
// popup
const selectModal = (e: any) => {
titleName.value = e.name;
personalId.value = e.personalId;
modalOpenClose(e.personalId);
};
// popup
const modalOpenClose = async (personalId: string) => {
modal.value = !modal.value;
if (modal.value) {
@ -249,6 +250,7 @@ const modalOpenClose = async (personalId: string) => {
}
myForm.value?.reset();
};
// personalId
const fetchSalary = async (personalId: string) => {
showLoader();
await http
@ -283,7 +285,7 @@ const fetchSalary = async (personalId: string) => {
hideLoader();
});
};
//
const putSalary = async (salary: any) => {
dialogConfirm($q, async () => {
showLoader();
@ -298,7 +300,7 @@ const putSalary = async (salary: any) => {
}
await http
.put(config.API.salaryOrder(personalId.value), modalData.value)
.then((res: any) => {
.then((any) => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
@ -311,7 +313,7 @@ const putSalary = async (salary: any) => {
});
});
};
// popup
const modalAddChange = async () => {
modalAdd.value = !modalAdd.value;
if (modalAdd.value == true) {
@ -325,7 +327,7 @@ const modalAddChange = async () => {
}
} else await conditionData();
};
//
const fetchaddlist = async (id: string) => {
showLoader();
await http
@ -344,7 +346,6 @@ const fetchaddlist = async (id: string) => {
}));
rows2.value = list;
selected.value = rows.value;
// rows2.value = list.filter((e: any) => e.selectStatus === false);
})
.catch((e) => {
messageError($q, e);
@ -353,7 +354,7 @@ const fetchaddlist = async (id: string) => {
hideLoader();
});
};
//
const saveModalAdd = () => {
if (myFormAdd.value !== null) {
myFormAdd.value.validate().then(async (result: boolean) => {
@ -372,7 +373,7 @@ const saveModalAdd = () => {
});
}
};
// API
const addlist = async (data: Object) => {
const id = route.params.orderid
? route.params.orderid.toString()
@ -393,7 +394,7 @@ const addlist = async (data: Object) => {
});
}
};
// step 2
const save = async () => {
const check = rows.value.find((x: any) => x.salaryAmount == 0);
if (
@ -725,8 +726,7 @@ const pagination = ref({
color="public"
@click="saveModalAdd"
class="q-px-md"
><!-- icon="mdi-content-save-outline"
<q-tooltip>นท</q-tooltip> -->
>
</q-btn>
</q-card-actions>
</q-form>