- Cataloghi: parte finale... prima bozza 9 dic
This commit is contained in:
@@ -20,7 +20,7 @@ import { ICatalogo, IMyScheda, IProduct } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CContainerCatalogoCard',
|
||||
emits: ['selauthor'],
|
||||
emits: ['selauthor', 'update:modelValue'],
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
@@ -47,24 +47,15 @@ export default defineComponent({
|
||||
required: false,
|
||||
default: () => { }
|
||||
},
|
||||
optcatalogo: {
|
||||
modelValue: {
|
||||
type: Object as PropType<ICatalogo>,
|
||||
required: false,
|
||||
default: () => ({
|
||||
//++AddCATALOGO_FIELDS
|
||||
productTypes: [0],
|
||||
excludeproductTypes: [],
|
||||
formato: [],
|
||||
Categoria: [],
|
||||
Editore: [],
|
||||
pdf: false,
|
||||
}),
|
||||
required: true,
|
||||
},
|
||||
scheda: {
|
||||
type: Object as PropType<IMyScheda>,
|
||||
required: false,
|
||||
default: () => ({
|
||||
|
||||
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -77,6 +68,25 @@ export default defineComponent({
|
||||
|
||||
const opendetailbool = ref(false)
|
||||
|
||||
// Crea una copia locale reattiva di modelValue
|
||||
const optcatalogo = ref<ICatalogo>({ ...props.modelValue });
|
||||
|
||||
// Watcher per sincronizzare le modifiche di modelValue
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
optcatalogo.value = { ...newVal };
|
||||
// updateCatalogoPadre()
|
||||
}, { deep: true });
|
||||
|
||||
function updateCatalogoPadre() {
|
||||
emit('update:modelValue', optcatalogo.value);
|
||||
}
|
||||
|
||||
// Metodo per aggiornare il valore del catalogo
|
||||
const updateCatalogo = (updatedCatalogo: ICatalogo) => {
|
||||
optcatalogo.value = updatedCatalogo; // Aggiorna la copia locale
|
||||
updateCatalogoPadre()
|
||||
};
|
||||
|
||||
function selauthor(id: any, autore: any) {
|
||||
emit('selauthor', id, autore)
|
||||
}
|
||||
@@ -102,6 +112,8 @@ export default defineComponent({
|
||||
selauthor,
|
||||
opendetail,
|
||||
opendetailbool,
|
||||
optcatalogo,
|
||||
updateCatalogo,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user