up
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
:class="d.urgencia==='rojo' ? 'bg-red-100 text-red-700' : d.urgencia==='amarillo' ? 'bg-yellow-100 text-yellow-700' : 'bg-green-100 text-green-700'"
|
||||
x-text="d.dias_restantes <= 0 ? 'Vencido' : d.dias_restantes+' días'"></span>
|
||||
</td>
|
||||
<td class="py-2 px-3" x-text="Number(d.precio_acordado).toFixed(2)"></td>
|
||||
<td class="py-2 px-3" x-text="fmtPrecio(d.precio_acordado, d.moneda)"></td>
|
||||
<td class="py-2 px-3">
|
||||
<span class="px-2 py-0.5 rounded text-xs font-medium"
|
||||
:class="{
|
||||
@@ -161,9 +161,18 @@
|
||||
<label class="text-xs font-medium text-gray-600">Precio acordado</label>
|
||||
<input x-model="form.precio_acordado" type="number" step="0.01" class="mt-1 w-full border rounded px-3 py-2 text-sm" />
|
||||
<p class="text-xs text-gray-400 mt-0.5" x-show="precioSugerido > 0">
|
||||
Sugerido: <span class="font-medium text-gray-600" x-text="precioSugerido.toFixed(2)"></span>
|
||||
Sugerido: <span class="font-medium text-gray-600" x-text="fmtPrecio(precioSugerido, form.moneda)"></span>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs font-medium text-gray-600">Moneda</label>
|
||||
<select x-model="form.moneda" class="mt-1 w-full border rounded px-3 py-2 text-sm">
|
||||
<option value="COP">COP — Pesos colombianos</option>
|
||||
<option value="USD">USD — Dólares</option>
|
||||
<option value="MXN">MXN — Pesos mexicanos</option>
|
||||
<option value="EUR">EUR — Euros</option>
|
||||
</select>
|
||||
</div>
|
||||
<div x-show="editModal">
|
||||
<label class="text-xs font-medium text-gray-600">Estado</label>
|
||||
<select x-model="form.estado" class="mt-1 w-full border rounded px-3 py-2 text-sm">
|
||||
@@ -342,7 +351,7 @@ document.addEventListener('alpine:init', () => {
|
||||
clientes: [], servicios: [], reglas: [], reglasBienvenida: [],
|
||||
selectedId: null,
|
||||
verificandoID: null,
|
||||
form: { cliente_id:'', servicio_ids:[], fecha_inicio:'', fecha_vencimiento:'', precio_acordado:0, estado:'activo', auto_renovar:false, notas:'' },
|
||||
form: { cliente_id:'', servicio_ids:[], fecha_inicio:'', fecha_vencimiento:'', precio_acordado:0, moneda:'COP', estado:'activo', auto_renovar:false, notas:'' },
|
||||
toast: { show: false, msg: '', type: 'ok' },
|
||||
|
||||
async init() {
|
||||
@@ -398,6 +407,7 @@ document.addEventListener('alpine:init', () => {
|
||||
fecha_inicio: d.fecha_inicio ? d.fecha_inicio.substring(0,10) : '',
|
||||
fecha_vencimiento: d.fecha_vencimiento ? d.fecha_vencimiento.substring(0,10) : '',
|
||||
precio_acordado: d.precio_acordado,
|
||||
moneda: d.moneda || 'COP',
|
||||
estado: d.estado,
|
||||
auto_renovar: d.auto_renovar,
|
||||
notas: d.notas
|
||||
@@ -409,7 +419,7 @@ document.addEventListener('alpine:init', () => {
|
||||
closeModals() {
|
||||
this.addModal = this.editModal = this.deleteModal = false;
|
||||
this.selectedId = null;
|
||||
this.form = { cliente_id:'', servicio_ids:[], fecha_inicio:'', fecha_vencimiento:'', precio_acordado:0, estado:'activo', auto_renovar:false, notas:'' };
|
||||
this.form = { cliente_id:'', servicio_ids:[], fecha_inicio:'', fecha_vencimiento:'', precio_acordado:0, moneda:'COP', estado:'activo', auto_renovar:false, notas:'' };
|
||||
},
|
||||
|
||||
async save() {
|
||||
@@ -532,6 +542,18 @@ document.addEventListener('alpine:init', () => {
|
||||
if (!raw) return '—';
|
||||
return new Date(raw).toLocaleDateString('es-ES', { day:'2-digit', month:'2-digit', year:'numeric' });
|
||||
},
|
||||
|
||||
fmtPrecio(valor, moneda) {
|
||||
const v = parseFloat(valor) || 0;
|
||||
const cur = moneda || 'COP';
|
||||
// COP y MXN: sin decimales, separador de miles
|
||||
const sinDecimales = ['COP', 'MXN'];
|
||||
const opts = sinDecimales.includes(cur)
|
||||
? { minimumFractionDigits: 0, maximumFractionDigits: 0 }
|
||||
: { minimumFractionDigits: 2, maximumFractionDigits: 2 };
|
||||
const num = v.toLocaleString('es-CO', opts);
|
||||
return cur + ' ' + num;
|
||||
},
|
||||
prevPage() { if(this.page>1){ this.page--; this.loadData(); } },
|
||||
nextPage() { if(this.page<this.totalPages){ this.page++; this.loadData(); } },
|
||||
showToast(msg, type='ok') {
|
||||
|
||||
Reference in New Issue
Block a user