diff --git a/src/modules/catalog/components/risk-factors/RiskFactorModal.vue b/src/modules/catalog/components/risk-factors/RiskFactorModal.vue
index 8aa507c..72956d1 100644
--- a/src/modules/catalog/components/risk-factors/RiskFactorModal.vue
+++ b/src/modules/catalog/components/risk-factors/RiskFactorModal.vue
@@ -44,7 +44,7 @@
{{ errors.evaluation_context[0] }}
-
+
+
+
+
+
+
+
+ Determina si este factor estará disponible en nuevas evaluaciones
+
+
+
@@ -92,6 +102,16 @@
+
+
+
+
+
+
+
+
+
@@ -100,7 +120,8 @@
severity="danger"
text
rounded
- @click="removeOption(index)" />
+ @click="removeOption(index)"
+ title="Eliminar" />
@@ -129,6 +150,7 @@ import Column from 'primevue/column';
import Button from 'primevue/button';
import InputNumber from 'primevue/inputnumber';
import Tag from 'primevue/tag';
+import InputSwitch from 'primevue/inputswitch';
import { riskFactorServices } from '../../services/risk-factors.services';
import type { RiskFactor, RiskOption, RiskFactorFormErrors } from '../../types/risk-factors.interfaces';
@@ -150,7 +172,7 @@ const errors = ref({});
const contextOptions = [
{ label: 'Ruta', value: 1 },
- { label: 'Programa', value: 2 }
+ { label: 'Viaje', value: 2 }
];
const form = reactive({
@@ -158,6 +180,7 @@ const form = reactive({
name: '',
description: '',
evaluation_context: 1,
+ is_active: true,
options: []
});
@@ -172,7 +195,8 @@ onMounted(() => {
const addOption = () => {
const newOption: ExtendedRiskOption = {
name: '',
- value: 1, // Valor por defecto solicitado
+ value: 1,
+ is_active: true,
tempId: Date.now() + Math.random()
};
form.options.push(newOption);
@@ -219,6 +243,12 @@ const handleSave = async () => {
loading.value = true;
try {
const payload = JSON.parse(JSON.stringify(form));
+ payload.options = payload.options.map((option: any) => ({
+ id: option.id,
+ name: option.name,
+ value: option.value,
+ is_active: option.is_active !== false,
+ }));
let response;
if (form.id && !isDuplicating.value) {
@@ -233,7 +263,9 @@ const handleSave = async () => {
if (error.response?.data?.errors) {
errors.value = error.response.data.errors;
}
- toast.add({ severity: 'error', summary: 'Error', detail: 'No se pudo guardar el factor de riesgo', life: 3000 });
+
+ const detail = error.response?.data?.error || error.response?.data?.message || 'No se pudo guardar el factor de riesgo';
+ toast.add({ severity: 'error', summary: 'Error', detail, life: 5000 });
} finally {
loading.value = false;
}
diff --git a/src/modules/catalog/components/risk-factors/RiskFactors.vue b/src/modules/catalog/components/risk-factors/RiskFactors.vue
index 59c7b4d..adaeee3 100644
--- a/src/modules/catalog/components/risk-factors/RiskFactors.vue
+++ b/src/modules/catalog/components/risk-factors/RiskFactors.vue
@@ -29,10 +29,17 @@
+
+
+
+
+
+
-
+
@@ -50,7 +57,7 @@
-
+
+ v-if="hasPermission('risk-factors.update')"
+ title="Editar" />
+ v-if="hasPermission('risk-factors.destroy')"
+ title="Eliminar" />
@@ -193,8 +202,9 @@ const confirmDelete = (factor: RiskFactor) => {
await riskFactorServices.deleteRiskFactor(factor.id!);
toast.add({ severity: 'success', summary: 'Eliminado', detail: 'Factor eliminado correctamente', life: 3000 });
fetchFactors();
- } catch (error) {
- toast.add({ severity: 'error', summary: 'Error', detail: 'No se pudo eliminar el factor', life: 3000 });
+ } catch (error: any) {
+ const detail = error.response?.data?.error || error.response?.data?.message || 'No se pudo eliminar el factor';
+ toast.add({ severity: 'error', summary: 'Error de Eliminación', detail, life: 5000 });
}
}
});
diff --git a/src/modules/catalog/types/risk-factors.interfaces.ts b/src/modules/catalog/types/risk-factors.interfaces.ts
index 56209c7..f12c290 100644
--- a/src/modules/catalog/types/risk-factors.interfaces.ts
+++ b/src/modules/catalog/types/risk-factors.interfaces.ts
@@ -7,6 +7,7 @@ export interface RiskOption {
risk_factor_id?: number;
name: string;
value: number;
+ is_active?: boolean;
}
export interface RiskFactor {
@@ -15,6 +16,7 @@ export interface RiskFactor {
description: string | null;
evaluation_context: number;
tenant_id?: number;
+ is_active?: boolean;
options?: RiskOption[];
created_at?: string;
updated_at?: string;