From 831df21930b854b349948534fef512aa4935f2f1 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 19 Sep 2024 11:21:13 +0700 Subject: [PATCH] fix: work name management --- .../WorkManagementComponent.vue | 15 ++++++++++++++- src/pages/04_product-service/MainPage.vue | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/04_product-service/WorkManagementComponent.vue b/src/components/04_product-service/WorkManagementComponent.vue index c76cd1cb..6a4544c7 100644 --- a/src/components/04_product-service/WorkManagementComponent.vue +++ b/src/components/04_product-service/WorkManagementComponent.vue @@ -6,7 +6,7 @@ import useProductServiceStore from 'stores/product-service'; import useOptionStore from 'stores/options'; import { Attributes, ProductList } from 'stores/product-service/types'; import { storeToRefs } from 'pinia'; -import { ref } from 'vue'; +import { ref, watch } from 'vue'; const baseUrl = ref(import.meta.env.VITE_API_BASE_URL); const productServiceStore = useProductServiceStore(); @@ -58,6 +58,19 @@ defineEmits<{ (e: 'manageWorkName'): void; (e: 'workProperties'): void; }>(); + +watch( + () => workNameItems.value, + (c, o) => { + const list = c.map((v: { name: string }) => v.name); + const oldList = o.map((v: { name: string }) => v.name); + const index = oldList.indexOf(workName.value); + + if (list[index] !== oldList[index]) { + workName.value = list[index]; + } + }, +);