ออกคำสั่ง - fix post or put
This commit is contained in:
parent
56ebfb89c7
commit
a8a51c05f2
1 changed files with 24 additions and 2 deletions
|
|
@ -351,7 +351,7 @@ onMounted(async () => {
|
|||
});
|
||||
const fetchdetailOrder = async () => {
|
||||
showLoader();
|
||||
console.log(orderId);
|
||||
// console.log(orderId);
|
||||
let orderIdString = orderId.toString();
|
||||
await http
|
||||
.get(config.API.detailOrder(orderIdString))
|
||||
|
|
@ -429,13 +429,18 @@ const submit = async () => {
|
|||
persistent: true,
|
||||
}).onOk(async () => {
|
||||
showLoader();
|
||||
if (!orderId) {
|
||||
createListOrder(formdata);
|
||||
} else {
|
||||
let orderIdString = orderId.toString();
|
||||
updateOrder(formdata, orderIdString);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
const createListOrder = async (formData: Object) => {
|
||||
console.log(formData);
|
||||
// console.log(formData);
|
||||
await http
|
||||
.post(config.API.createOrder(), formData)
|
||||
.then((res) => {
|
||||
|
|
@ -449,6 +454,23 @@ const createListOrder = async (formData: Object) => {
|
|||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const updateOrder = async (formData: Object, orderId: string) => {
|
||||
// console.log(formData);
|
||||
await http
|
||||
.put(config.API.detailOrder(orderId), formData)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
next();
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* class จัดรูปแบบแสดงระหว่างข้อมูลที่แก้ไขหรือแสดงเฉยๆ
|
||||
* @param val ข้อมูล input สำหรับแก้ไขหรือไม่
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue