feat: เปลี่ยน สถานะของ สินค้าและบริการ
This commit is contained in:
parent
fe2fa5e4bc
commit
247549e176
2 changed files with 31 additions and 3 deletions
|
|
@ -335,6 +335,21 @@ const itemCard = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
async function toggleStatusProduct(id: string, status: Status) {
|
||||||
|
await editProduct(id, {
|
||||||
|
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
||||||
|
});
|
||||||
|
|
||||||
|
await fetchListOfProduct(currentIdType.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleStatusService(id: string, status: Status) {
|
||||||
|
await editService(id, {
|
||||||
|
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
||||||
|
});
|
||||||
|
|
||||||
|
await fetchListOfService();
|
||||||
|
}
|
||||||
async function toggleStatusType(id: string, status: Status) {
|
async function toggleStatusType(id: string, status: Status) {
|
||||||
await editProductServiceType(id, {
|
await editProductServiceType(id, {
|
||||||
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
||||||
|
|
@ -1202,6 +1217,11 @@ watch(currentStatus, async () => {
|
||||||
typeProduct="product"
|
typeProduct="product"
|
||||||
:title="i.name"
|
:title="i.name"
|
||||||
:isDisabled="i.status === 'INACTIVE' ? true : false"
|
:isDisabled="i.status === 'INACTIVE' ? true : false"
|
||||||
|
@toggleStatus="
|
||||||
|
() => {
|
||||||
|
toggleStatusProduct(i.id, i.status);
|
||||||
|
}
|
||||||
|
"
|
||||||
@menuViewDetail="
|
@menuViewDetail="
|
||||||
() => {
|
() => {
|
||||||
currentIdProduct = i.id;
|
currentIdProduct = i.id;
|
||||||
|
|
@ -1255,6 +1275,11 @@ watch(currentStatus, async () => {
|
||||||
:title="i.name"
|
:title="i.name"
|
||||||
:isDisabled="i.status === 'INACTIVE' ? true : false"
|
:isDisabled="i.status === 'INACTIVE' ? true : false"
|
||||||
:created-at="i.createdAt"
|
:created-at="i.createdAt"
|
||||||
|
@toggleStatus="
|
||||||
|
() => {
|
||||||
|
toggleStatusService(i.id, i.status);
|
||||||
|
}
|
||||||
|
"
|
||||||
@menuViewDetail="
|
@menuViewDetail="
|
||||||
() => {
|
() => {
|
||||||
currentIdService = i.id;
|
currentIdService = i.id;
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createProduct(data: ProductCreate) {
|
async function createProduct(data: ProductCreate) {
|
||||||
const { image, ...payload } = data;
|
const { image, status, ...payload } = data;
|
||||||
|
|
||||||
const res = await api.post<ProductCreate & { imageUploadUrl: string }>(
|
const res = await api.post<ProductCreate & { imageUploadUrl: string }>(
|
||||||
'/product',
|
'/product',
|
||||||
|
|
@ -340,7 +340,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
|
|
||||||
async function editProduct(
|
async function editProduct(
|
||||||
productId: string,
|
productId: string,
|
||||||
data: ProductCreate & { status: string },
|
data: Partial<ProductCreate & { status: string }>,
|
||||||
) {
|
) {
|
||||||
const { image, code, ...payload } = data;
|
const { image, code, ...payload } = data;
|
||||||
|
|
||||||
|
|
@ -502,7 +502,10 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editService(serviceId: string, data: ServiceCreate) {
|
async function editService(
|
||||||
|
serviceId: string,
|
||||||
|
data: Partial<ServiceCreate & { status: string }>,
|
||||||
|
) {
|
||||||
const { image, code, ...payload } = data;
|
const { image, code, ...payload } = data;
|
||||||
|
|
||||||
const res = await api.put<ServiceCreate & { imageUploadUrl: string }>(
|
const res = await api.put<ServiceCreate & { imageUploadUrl: string }>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue