fix: โค้คหาย

This commit is contained in:
Net 2024-06-26 17:44:13 +07:00
parent 14eb498133
commit 45d912e20a

View file

@ -636,11 +636,14 @@ const prevService = ref<ServiceCreate>({
productTypeId: '', productTypeId: '',
}); });
const currentService = ref<ServiceById>();
async function assignFormDataProductService(id: string) { async function assignFormDataProductService(id: string) {
const res = await fetchListServiceById(id); const res = await fetchListServiceById(id);
if (res) { if (res) {
statusToggle.value = res.status === 'INACTIVE' ? false : true; statusToggle.value = res.status === 'INACTIVE' ? false : true;
currentService.value = JSON.parse(JSON.stringify(res));
prevService.value = { prevService.value = {
code: res.code, code: res.code,
@ -674,7 +677,7 @@ async function assignFormDataProductService(id: string) {
product: item.productOnWork.map((productOnWorkItem) => { product: item.productOnWork.map((productOnWorkItem) => {
return { return {
...productOnWorkItem.product, ...productOnWorkItem.product,
nameEn: '', nameEn: productOnWorkItem.product.name,
}; };
}), }),
}; };
@ -945,6 +948,28 @@ async function fetchSearch() {
} }
} }
function cloneData() {
if (!currentService.value) return;
formDataProductService.value = {
...prevService.value,
attributes: JSON.parse(JSON.stringify(currentService.value.attributes)),
};
workItems.value = currentService.value.work.map((item) => {
return {
id: item.id,
name: item.name,
attributes: JSON.parse(JSON.stringify(item.attributes)),
product: item.productOnWork.map((productOnWorkItem) => {
return {
...productOnWorkItem.product,
nameEn: productOnWorkItem.product.name,
};
}),
};
});
}
onMounted(async () => { onMounted(async () => {
calculateStats(); calculateStats();
await fetchListGroups(); await fetchListGroups();
@ -2160,7 +2185,7 @@ watch(currentPageService, async () => {
:undo=" :undo="
() => { () => {
infoServiceEdit = false; infoServiceEdit = false;
formDataProductService = { ...prevService }; cloneData();
statusToggle = prevService.status === 'INACTIVE' ? false : true; statusToggle = prevService.status === 'INACTIVE' ? false : true;
flowStore.rotate(); flowStore.rotate();
} }