MOD: mejorar la gestión del formulario en ConceptSection
This commit is contained in:
parent
4ac8799f88
commit
8d513d215c
@ -26,6 +26,23 @@ const form = useForm({
|
|||||||
charge_type: null,
|
charge_type: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
form.direction_id = null;
|
||||||
|
form.unit_id = null;
|
||||||
|
form.short_name = "";
|
||||||
|
form.name = "";
|
||||||
|
form.legal_instrument = "";
|
||||||
|
form.article = "";
|
||||||
|
form.content = "";
|
||||||
|
form.min_amount_uma = "";
|
||||||
|
form.max_amount_uma = "";
|
||||||
|
form.min_amount_peso = "";
|
||||||
|
form.max_amount_peso = "";
|
||||||
|
form.unit_cost_uma = "";
|
||||||
|
form.unit_cost_peso = "";
|
||||||
|
form.charge_type = null;
|
||||||
|
};
|
||||||
|
|
||||||
const addresses = ref([]);
|
const addresses = ref([]);
|
||||||
const units = ref([]);
|
const units = ref([]);
|
||||||
|
|
||||||
@ -36,8 +53,8 @@ const chargeTypeId = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const chargeTypesOptions = ref([
|
const chargeTypesOptions = ref([
|
||||||
{ id: 'uma_range', name: 'UMA Range' },
|
{ id: 'uma_range', name: 'Rango en UMA' },
|
||||||
{ id: 'peso_range', name: 'Peso Range' },
|
{ id: 'peso_range', name: 'Rango en Peso' },
|
||||||
{ id: 'uma_fixed', name: 'UMA unitario' },
|
{ id: 'uma_fixed', name: 'UMA unitario' },
|
||||||
{ id: 'peso_fixed', name: 'Peso unitario' },
|
{ id: 'peso_fixed', name: 'Peso unitario' },
|
||||||
]);
|
]);
|
||||||
@ -76,8 +93,8 @@ onMounted(async () => {
|
|||||||
/** Métodos */
|
/** Métodos */
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const baseData = {
|
const baseData = {
|
||||||
direction_id: typeof form.direction === 'object' ? form.direction.id : Number(form.direction_id),
|
direction_id: typeof form.direction_id === 'object' ? form.direction_id.id : Number(form.direction_id),
|
||||||
unit_id: form.unit ? (typeof form.unit === 'object' ? form.unit.id : Number(form.unit)) : null,
|
unit_id: typeof form.unit_id === 'object' ? form.unit_id.id : Number(form.unit_id),
|
||||||
short_name: form.short_name,
|
short_name: form.short_name,
|
||||||
name: form.name,
|
name: form.name,
|
||||||
legal_instrument: form.legal_instrument,
|
legal_instrument: form.legal_instrument,
|
||||||
@ -106,6 +123,7 @@ const handleSubmit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit('concept-created', baseData);
|
emit('concept-created', baseData);
|
||||||
|
resetForm();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -118,7 +136,7 @@ const handleSubmit = () => {
|
|||||||
<form @submit.prevent="handleSubmit">
|
<form @submit.prevent="handleSubmit">
|
||||||
<div class="mb-5 grid grid-cols-2 gap-4">
|
<div class="mb-5 grid grid-cols-2 gap-4">
|
||||||
<Selectable
|
<Selectable
|
||||||
v-model="form.direction"
|
v-model="form.direction_id"
|
||||||
label="name"
|
label="name"
|
||||||
value="id"
|
value="id"
|
||||||
:title="$t('concept.direction')"
|
:title="$t('concept.direction')"
|
||||||
@ -211,7 +229,7 @@ const handleSubmit = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Selectable
|
<Selectable
|
||||||
v-model="form.unit"
|
v-model="form.unit_id"
|
||||||
label="name"
|
label="name"
|
||||||
value="id"
|
value="id"
|
||||||
:title="$t('concept.sizeUnit')"
|
:title="$t('concept.sizeUnit')"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user