diff --git a/src/components/shared/select/select.ts b/src/components/shared/select/select.ts index 08fd88b2..cf1555cb 100644 --- a/src/components/shared/select/select.ts +++ b/src/components/shared/select/select.ts @@ -35,7 +35,13 @@ export const createSelect = >( let previousSearch = ''; watch(value, (v) => { - if (!v || (cache && cache.find((opt) => opt[valueField] === v))) return; + if (!v) return; + + if (cache && cache.find((opt) => opt[valueField] === v)) { + valueOption.value = cache.find((opt) => opt[valueField] === v); + return; + } + getSelectedOption(); }); @@ -63,7 +69,15 @@ export const createSelect = >( const currentValue = value.value; if (!currentValue) return; - if (selectOptions.value.find((v) => v[valueField] === currentValue)) return; + + const option = selectOptions.value.find( + (v) => v[valueField] === currentValue, + ); + + if (option) { + valueOption.value = option; + return; + } if (valueOption.value && valueOption.value[valueField] === currentValue) { return selectOptions.value.unshift(valueOption.value); } diff --git a/src/pages/05_quotation/QuotationFormProductSelect.vue b/src/pages/05_quotation/QuotationFormProductSelect.vue index 39be19e7..b2e92761 100644 --- a/src/pages/05_quotation/QuotationFormProductSelect.vue +++ b/src/pages/05_quotation/QuotationFormProductSelect.vue @@ -51,6 +51,8 @@ const emit = defineEmits<{ const selectedProductGroup = defineModel('selectedProductGroup', { default: '', }); + +const selectedProductGroupOption = ref(); const model = defineModel(); const inputSearch = defineModel('inputSearch'); const productGroup = defineModel('productGroup', { @@ -569,14 +571,18 @@ watch( {{ productGroup.find( (g) => g.id === selectedProductGroup, - )?.name || '-' + )?.name || + selectedProductGroupOption?.name || + '-' }} {{ productGroup.find( (g) => g.id === selectedProductGroup, - )?.code || '-' + )?.code || + selectedProductGroupOption?.code || + '-' }} @@ -862,13 +868,13 @@ watch( {{ $t('productService.group.title') }} -