feat: refs #8283 vue cmp by AI
This commit is contained in:
parent
4fc9ad3f76
commit
75a746e0bc
|
@ -0,0 +1,87 @@
|
||||||
|
<template>
|
||||||
|
<q-card class="q-pa-md">
|
||||||
|
<q-card-section>
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
v-model.number="credito"
|
||||||
|
label="Crédito Asignado (€)"
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
<q-input filled v-model.number="riesgo" label="Riesgo (€)" type="number" />
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
v-model.number="sumatorioPedidos"
|
||||||
|
label="Sumatorio Pedidos del Día (€)"
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
<q-toggle
|
||||||
|
v-model="esClienteFrances"
|
||||||
|
label="¿Cliente Francés?"
|
||||||
|
color="primary"
|
||||||
|
class="q-mt-md"
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section>
|
||||||
|
<q-badge :color="resultado.color" align="center" class="text-bold q-pa-md">
|
||||||
|
{{ resultado.mensaje }}
|
||||||
|
</q-badge>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
|
// Variables reactivas
|
||||||
|
const credito = ref(0);
|
||||||
|
const riesgo = ref(0);
|
||||||
|
const sumatorioPedidos = ref(0);
|
||||||
|
const esClienteFrances = ref(false);
|
||||||
|
|
||||||
|
// Cálculo del margen
|
||||||
|
const margen = computed(() => {
|
||||||
|
if (credito.value === 0) return esClienteFrances.value ? 500 : 200;
|
||||||
|
if (esClienteFrances.value) {
|
||||||
|
return credito.value > 5000 ? credito.value * 0.1 : 500;
|
||||||
|
}
|
||||||
|
return credito.value > 2000 ? credito.value * 0.1 : 200;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Evaluación del riesgo
|
||||||
|
const resultado = computed(() => {
|
||||||
|
const margenActual = margen.value;
|
||||||
|
|
||||||
|
// Riesgo Naranja
|
||||||
|
if (
|
||||||
|
riesgo.value > 0 &&
|
||||||
|
riesgo.value < margenActual &&
|
||||||
|
riesgo.value < sumatorioPedidos.value
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
mensaje: 'Riesgo Naranja: Evaluación en Proceso',
|
||||||
|
color: 'orange',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Riesgo Rojo
|
||||||
|
if (riesgo.value >= margenActual || riesgo.value >= sumatorioPedidos.value) {
|
||||||
|
return {
|
||||||
|
mensaje: 'Riesgo Rojo: No Preparar Pedido',
|
||||||
|
color: 'red',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default
|
||||||
|
return {
|
||||||
|
mensaje: 'Condiciones No Cumplen para Evaluación',
|
||||||
|
color: 'grey',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.q-card {
|
||||||
|
max-width: 400px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue