PageSourceSearch

https://rosgan.app/assets/rosgan-auditor-excel.js

js rosgan.app collected 2026-10-09 23:24:36 UTC 4,451 bytes, 31 lines download raw bytes

1(function(root,factory){if(typeof module==='object'&&module.exports)module.exports=factory();else root.RosganAuditorExcel=factory();})(typeof window==='undefined'?this:window,function(){
2  'use strict';
3  function select(lots, checked) { return checked.size ? lots.filter(lot=>checked.has(String(lot.lotCert))) : lots.slice(); }
4  async function build(ExcelJS, lots, meta={}) {
5    const book=new ExcelJS.Workbook(); book.creator='Rosgan'; book.created=new Date();
6    const sheet=book.addWorksheet('Lotes',{views:[{state:'frozen',ySplit:4,xSplit:1}]});
7    const columns=[['Certificado','lotCert',16],['Orden de venta','saleOrder',16],['Estado','status',16],['Consignataria','consignatariaName',32],['Categoría','displayCategoryName',28],['Comitente','comitenteName',34],['Establecimiento','establishmentName',30],['Localidad','locality',25],['Provincia','province',15],['Cabezas','totalQuantity',14],['Machos','maleQuantity',12],['Hembras','femaleQuantity',12],['Madres','motherQuantity',12],['Crías','calfQuantity',12],['Peso promedio (kg)','averageWeight',21],['Razas','breedNames',30],['Plazo de pago','paymentTerm',32],['Edad','ageValue',12],['Unidad de edad','ageUnit',18],['Dentición','dentition',22],['Sanidad','health',25],['Nutrición','nutrition',25],['Estado corporal','bodyCondition',23],['Clase','animalClass',20],['Observaciones','observations',60],['Cargado por','loadedByName',28],['Video final','hasFinalVideo',16],['Videos crudos','rawVideoCount',16],['Fecha de carga','createdAt',25],['Última actualización','updatedAt',25]];
8    sheet.columns=columns.map(([,key,width])=>({key,width}));
9    sheet.mergeCells(1,1,1,columns.length);sheet.getCell(1,1).value='ROSGAN | '+(meta.title||'Lotes del remate');sheet.getRow(1).height=30;sheet.getCell(1,1).font={name:'Calibri',bold:true,size:18,color:{argb:'FFFFFFFF'}};sheet.getCell(1,1).fill={type:'pattern',pattern:'solid',fgColor:{argb:'FF10345B'}};
10    sheet.mergeCells(2,1,2,columns.length);sheet.getCell(2,1).value=`${lots.length} lotes · ${meta.selected?'Selección de certificados':'Todos los lotes disponibles para el usuario'} · ${new Date().toLocaleString('es-AR')}`;
11    sheet.getCell(2,1).font={name:'Calibri',size:11,color:{argb:'FF62768B'}};
12    sheet.getRow(4).values=columns.map(([title])=>title);sheet.getRow(4).height=28;
13    sheet.getRow(4).eachCell(cell=>{cell.font={bold:true,color:{argb:'FFFFFFFF'}};cell.fill={type:'pattern',pattern:'solid',fgColor:{argb:'FF0A5CA8'}};cell.alignment={vertical:'middle',wrapText:true};});
14    const states={cargado:'Cargado',controlado:'Controlado',publicado:'Publicado',anulado:'Anulado',cerrado:'Cerrado'};
15    for(const [i,lot] of lots.entries()) {
16      const data={...lot,lotCert:String(lot.lotCert||''),status:states[lot.status]||lot.status,displayCategoryName:lot.displayCategoryName||lot.categoryName,totalQuantity:lot.totalQuantity??lot.quantity??null,hasFinalVideo:lot.hasFinalVideo==null?'Sin verificar':lot.hasFinalVideo?'Sí':'No'};
17      const row=sheet.addRow(columns.map(([,key])=>{const value=data[key];return Array.isArray(value)?value.join(' · '):value??'';}));
18      row.eachCell({includeEmpty:true},cell=>{cell.font={name:'Calibri',size:11,color:{argb:'FF17344E'}};cell.alignment={vertical:'top',wrapText:true};if(i%2===0)cell.fill={type:'pattern',pattern:'solid',fgColor:{argb:'FFF0F5FA'}};});
19    }
20    sheet.autoFilter={from:{row:4,column:1},to:{row:4+lots.length,column:columns.length}};
21    sheet.pageSetup={orientation:'landscape',paperSize:9,fitToPage:true,fitToWidth:1,fitToHeight:0,printTitlesRow:'1:4'};
22    return book.xlsx.writeBuffer();
23  }
24  async function download(lots,meta) {
25    if(!window.ExcelJS)await new Promise((resolve,reject)=>{const script=document.createElement('script');script.src='/vendor/exceljs.min.js';script.onload=resolve;script.onerror=()=>{script.remove();reject(Error('No se pudo cargar el generador Excel.'));};document.head.append(script);});
26    const buffer=await build(window.ExcelJS,lots,meta);
27    const url=URL.createObjectURL(new Blob([buffer],{type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}));
28    const a=document.createElement('a');a.href=url;a.download='remate-'+String(meta.remateId).replace(/[^\w-]/g,'')+'-lotes'+(meta.selected?'-seleccionados':'')+'.xlsx';document.body.append(a);a.click();a.remove();setTimeout(()=>URL.revokeObjectURL(url),60000);
29  }
30  return {select,build,download};
31});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.