ต่อ API

This commit is contained in:
setthawutttty 2024-10-31 17:11:53 +07:00
parent 8be5a28594
commit bf4143ece4
2 changed files with 31 additions and 30 deletions

View file

@ -22,6 +22,7 @@ export default {
probationsGetAssign: (assignId: string) =>
`${probation}/assign/probation-assign?assign_id=${assignId}`,
summarySurveyDetail: (id: string) => `${probation}/survey?assign_id=${id}`,
summaryDetail: () => `${probation}/survey`,
saveEditAssign: (personalId: string) =>
`${probation}/assign/probation-assign?id=${personalId}`,
saveFinish: (personalId: string) =>

View file

@ -38,9 +38,10 @@ const classBordered = ref<string>("");
async function getSurveyData() {
showLoader();
await http
.get(config.API.summarySurveyDetail(assignId.value))
.get(config.API.summaryDetail())
.then(async (res: any) => {
const data = await res.data.data;
const data = await res.data.data.data;
assignId.value = res.data.data.assignId;
if (data !== null) {
answer1.value = data.answer1;
answer2.value = data.answer2;
@ -56,33 +57,32 @@ async function getSurveyData() {
/** save ข้อมูล */
async function save() {
await myForm.value!.validate().then((result: boolean) => {
if (result && answer3.value !== 0) {
const data = {
answer1: answer1.value,
answer2: answer2.value,
answer3: answer3.value,
};
dialogConfirm($q, async () => {
showLoader();
await http
.post(config.API.summarySurveyDetail(assignId.value), data)
.then((res: any) => {
success($q, "บันทึกสำเร็จ");
getSurveyData();
})
.catch((e: any) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
} else if (answer3.value == 0) {
classBordered.value = "border_custom";
}
});
if (answer3.value !== 0) {
const data = {
answer1: answer1.value,
answer2: answer2.value,
answer3: answer3.value,
};
dialogConfirm($q, async () => {
showLoader();
await http
.post(config.API.summarySurveyDetail(assignId.value), data)
.then((res: any) => {
success($q, "บันทึกสำเร็จ");
getSurveyData();
})
.catch((e: any) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
} else if (answer3.value == 0) {
classBordered.value = "border_custom";
}
}
/** ถ้าเป็น 0 ใส่ class */
watch(answer3, () => {
if (answer3.value == 0) {
@ -229,9 +229,9 @@ onMounted(() => {
</div>
</div>
</q-card-section>
<q-separator />
<q-separator v-if="status" />
<q-card-actions align="right">
<q-card-actions align="right" v-if="status">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>