feat: แก้ไข และ ลบ ของ Product
This commit is contained in:
parent
e55935ce3a
commit
b6e7eb68cd
3 changed files with 91 additions and 15 deletions
|
|
@ -326,14 +326,23 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
|||
}
|
||||
}
|
||||
|
||||
async function editProduct(productId: string, data: ProductUpdate) {
|
||||
const { ...payload } = data;
|
||||
async function editProduct(productId: string, data: ProductCreate) {
|
||||
const { image, code, ...payload } = data;
|
||||
|
||||
const res = await api.put<ProductGroupUpdate>(`/product/${productId}`, {
|
||||
...payload,
|
||||
});
|
||||
const res = await api.put<ProductCreate & { imageUploadUrl: string }>(
|
||||
`/product/${productId}`,
|
||||
{
|
||||
...payload,
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
image &&
|
||||
(await axios
|
||||
.put(res.data.imageUploadUrl, image, {
|
||||
headers: { 'Content-Type': image.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
})
|
||||
.catch((e) => console.error(e)));
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export interface ProductCreate {
|
|||
}
|
||||
|
||||
export interface ProductUpdate {
|
||||
productTypeId: string;
|
||||
remark: string;
|
||||
serviceCharge: number;
|
||||
agentPrice: number;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue