Files
analiticaNucleo/nuxt4-app/app/components/SecosVendidos.vue
josedario87 5500c83f9f
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 48s
Feat: Agregar botones de copia a Panorama Facturador
Implementa botones "Copiar Texto" y "Copiar JSON" en todos los
componentes de datos del Panorama Facturador:

Componentes actualizados:
- SecosVendidos: Exporta inventario y proyecciones de café seco
- RechazosSubproductos: Exporta tabla de rechazos con totales
- Totales Financieros: Exporta vista general financiera (directo en página)

Además:
- Los componentes de Totales (IngresoCompra, Monetarios, Verde)
  ahora reciben contadores y metadata para incluir footer
- Todos los textos incluyen footer con:
  - Rango de fechas
  - Ingresos y rechazos filtrados vs totales
  - Fecha de generación

Nota: Panorama no tiene datos de clientes, solo ingresos y rechazos.
2025-10-30 17:13:21 -06:00

133 lines
4.7 KiB
Vue

<template>
<UCard class="brand-card border border-transparent">
<template #header>
<div class="flex items-center justify-between">
<h2 class="text-xl font-bold brand-section-title">Café Seco - Inventario y Proyecciones</h2>
<div class="flex items-center gap-2">
<UButton
size="xs"
color="gray"
variant="soft"
icon="i-lucide-copy"
@click="copiarTexto"
>
Copiar Texto
</UButton>
<UButton
size="xs"
color="gray"
variant="soft"
icon="i-lucide-braces"
@click="copiarJSON"
>
Copiar JSON
</UButton>
</div>
</div>
</template>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="rounded-lg border border-[#3a2a16] bg-[#1c140c] px-4 py-3">
<div class="text-xs text-[var(--brand-text-muted)] uppercase tracking-wide mb-1">QQ Seco por Vender</div>
<div class="text-2xl font-bold text-[var(--brand-text)]">
{{ formatNumber(data.total_qq_seco_por_vender) }} QQ
</div>
</div>
<div class="rounded-lg border border-[#3a2a16] bg-[#1c140c] px-4 py-3">
<div class="text-xs text-[var(--brand-text-muted)] uppercase tracking-wide mb-1">Precio Venta Promedio/QQ</div>
<div class="text-2xl font-bold text-green-400">
{{ formatCurrency(data.precio_venta_promedio_por_qq) }}
</div>
<div v-if="data.precio_venta_promedio_por_qq === 0" class="text-xs text-[var(--brand-text-muted)] mt-1">
Sin ventas registradas
</div>
</div>
<div class="rounded-lg border border-[#3a2a16] bg-[#1c140c] px-4 py-3">
<div class="text-xs text-[var(--brand-text-muted)] uppercase tracking-wide mb-1">Precio Compra Promedio/QQ</div>
<div class="text-2xl font-bold text-[var(--brand-text)]">
{{ formatCurrency(data.precio_compra_promedio_por_qq) }}
</div>
</div>
<div class="rounded-lg border border-[#3a2a16] bg-[#1c140c] px-4 py-3">
<div class="text-xs text-[var(--brand-text-muted)] uppercase tracking-wide mb-1">Margen de Ganancia/QQ</div>
<div class="text-2xl font-bold" :class="margenColor">
{{ formatCurrency(data.margen_ganancia_por_qq) }}
</div>
</div>
</div>
</UCard>
</template>
<script setup lang="ts">
const props = defineProps<{
data: {
total_qq_seco_por_vender: number
precio_venta_promedio_por_qq: number
precio_compra_promedio_por_qq: number
margen_ganancia_por_qq: number
}
conteos?: {
ingresos_total?: number
ingresos_filtrados?: number
rechazos_total?: number
rechazos_filtrados?: number
}
rangoLegible?: string
lastUpdated?: string
}>()
const margenColor = computed(() => {
if (props.data.margen_ganancia_por_qq > 0) return 'text-green-400'
if (props.data.margen_ganancia_por_qq < 0) return 'text-red-400'
return 'text-[var(--brand-text)]'
})
const formatNumber = (value: number) => {
return new Intl.NumberFormat('es-HN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
}).format(value)
}
const formatCurrency = (value: number) => {
if (!value) return 'L 0.00'
return new Intl.NumberFormat('es-HN', {
style: 'currency',
currency: 'HNL',
minimumFractionDigits: 2,
maximumFractionDigits: 2
}).format(value).replace('HNL', 'L')
}
async function copiarTexto() {
const footer = props.rangoLegible && props.lastUpdated ? `
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 RESUMEN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📅 Rango: ${props.rangoLegible}
📦 Ingresos: ${props.conteos?.ingresos_filtrados || 0} de ${props.conteos?.ingresos_total || 0} registros
📦 Rechazos: ${props.conteos?.rechazos_filtrados || 0} de ${props.conteos?.rechazos_total || 0} registros
🕐 Generado: ${props.lastUpdated}` : ''
const texto = `☕ CAFÉ SECO - INVENTARIO Y PROYECCIONES
📊 DATOS:
QQ Seco por Vender: ${formatNumber(props.data.total_qq_seco_por_vender)} QQ
Precio Venta Promedio/QQ: ${formatCurrency(props.data.precio_venta_promedio_por_qq)}
Precio Compra Promedio/QQ: ${formatCurrency(props.data.precio_compra_promedio_por_qq)}
Margen de Ganancia/QQ: ${formatCurrency(props.data.margen_ganancia_por_qq)}${footer}`
await navigator.clipboard.writeText(texto)
alert('✅ Café Seco - Inventario y Proyecciones copiado al portapapeles')
}
async function copiarJSON() {
const json = JSON.stringify(props.data, null, 2)
await navigator.clipboard.writeText(json)
alert('✅ JSON copiado al portapapeles')
}
</script>