diff --git a/src/modules/catalog/components/ComercialClassification.vue b/src/modules/catalog/components/ComercialClassification.vue index b81a08a..1785b0b 100644 --- a/src/modules/catalog/components/ComercialClassification.vue +++ b/src/modules/catalog/components/ComercialClassification.vue @@ -11,6 +11,7 @@ import Dialog from 'primevue/dialog'; import Dropdown from 'primevue/dropdown'; import InputText from 'primevue/inputtext'; import Textarea from 'primevue/textarea'; +import InputSwitch from 'primevue/inputswitch'; import ProgressSpinner from 'primevue/progressspinner'; import Toast from 'primevue/toast'; import { useComercialClassificationStore } from '../stores/comercialClassificationStore'; @@ -26,6 +27,7 @@ interface Category { name: string; description: string; parent_id: number | null; + is_active: number; created_at: string; subcategories: Category[]; } @@ -45,7 +47,16 @@ const formData = ref({ code: '', name: '', description: '', - parent_id: null as number | null + parent_id: null as number | null, + is_active: 1 as number +}); + +// Computed para el switch (convierte number a boolean y viceversa) +const isActiveSwitch = computed({ + get: () => formData.value.is_active === 1, + set: (value: boolean) => { + formData.value.is_active = value ? 1 : 0; + } }); // Transform API data to component structure @@ -56,6 +67,7 @@ const transformClassifications = (classifications: ComercialClassification[]): C name: cls.name, description: cls.description || '', parent_id: cls.parent_id, + is_active: cls.is_active, created_at: cls.created_at, subcategories: cls.children ? cls.children.map(child => ({ id: child.id, @@ -63,6 +75,7 @@ const transformClassifications = (classifications: ComercialClassification[]): C name: child.name, description: child.description || '', parent_id: child.parent_id, + is_active: child.is_active, created_at: child.created_at, subcategories: [] })) : [] @@ -100,7 +113,8 @@ const addNewCategory = () => { code: '', name: '', description: '', - parent_id: null + parent_id: null, + is_active: 1 }; showCreateModal.value = true; }; @@ -161,7 +175,8 @@ const createClassification = async () => { code: '', name: '', description: '', - parent_id: null + parent_id: null, + is_active: 1 }; } catch (error) { console.error('Error saving classification:', error); @@ -186,7 +201,8 @@ const addSubcategory = () => { code: '', name: '', description: '', - parent_id: selectedCategory.value.id + parent_id: selectedCategory.value.id, + is_active: 1 }; showCreateModal.value = true; } @@ -201,7 +217,8 @@ const editCategory = () => { code: selectedCategory.value.code, name: selectedCategory.value.name, description: selectedCategory.value.description, - parent_id: selectedCategory.value.parent_id + parent_id: selectedCategory.value.parent_id, + is_active: selectedCategory.value.is_active }; showCreateModal.value = true; }; @@ -256,7 +273,8 @@ const editSubcategory = (subcategory: Category) => { code: subcategory.code, name: subcategory.name, description: subcategory.description, - parent_id: subcategory.parent_id + parent_id: subcategory.parent_id, + is_active: subcategory.is_active }; showCreateModal.value = true; }; @@ -600,6 +618,24 @@ onMounted(() => { Deja vacío para crear una clasificación raíz + + +
+
+
+ + + Activa o desactiva esta clasificación comercial + +
+ +
+