fix: work name management

This commit is contained in:
puriphatt 2024-09-19 11:21:13 +07:00
parent 48bf222f4e
commit 831df21930
2 changed files with 21 additions and 1 deletions

View file

@ -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<string>(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];
}
},
);
</script>
<template>
<div class="bordered rounded">

View file

@ -1172,6 +1172,13 @@ function triggerConfirmCloseWork() {
dialogWarningClose(t, {
action: () => {
manageWorkNameDialog.value = false;
if(workNameItems.value[workNameItems.value.length - 1].name ===''){
confirmDeleteWork(
workNameItems.value[workNameItems.value.length - 1].id,
true,
);
}
},
cancel: () => {},
});