UNPKG

prg-class

Version:

Clases genéricas utilizadas por microservicios Programamos SPA.

116 lines (115 loc) 4.65 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuerySPAll = void 0; const F = require("prg-function"); const exec_sp_1 = require("./exec-sp"); const U = require("prg-constant"); class QuerySPAll extends exec_sp_1.ExecSP { constructor() { super(); this.mbCustomXls = false; this.mbCustomRet = false; this.msCustomErrMsg = ''; this.miSS = 50; this.miSM = 100; this.miSL = 200; this.miSX0 = 350; this.miSX1 = 550; this.miSX2 = 1100; this.miX3 = 1500; this.msFN0 = '###,###,###,##0'; this.msFN2 = '###,###,###,##0.00'; this.msFM0 = '$###,###,###,###,##0'; this.msFM2 = '$###,###,###,###,##0.00'; this.msFP0 = '##0%'; this.msFP2 = '##0.00%'; this.moParam = null; this.mbReturnAll = false; this.mbAudit = false; this.useExcelWidth = true; this.msTitle = ''; // Asignación de título de informe. this.msSPName = ''; // Asignación de nombre de nombre de procedimiento almacenado. } fnQueryAll(aoParams, aoUPRM) { return __awaiter(this, void 0, void 0, function* () { this.moParam = aoParams; const loRet = yield this.fnSpExecute(aoParams, aoUPRM, this.mbAudit); if (loRet.error) { return loRet; } if (!loRet.json || loRet.json.length < 1) { const lsErr = this.msCustomErrMsg ? this.msCustomErrMsg : 'No se encontraron coincidencias.'; return F.fnRetErrBP(lsErr); } const loData = {}; for (let i = 0; i < loRet.json.length; i++) { let lsCero = ''; if (i > 10 && i < 99) { lsCero = '0'; } if (i < 10) { lsCero = '00'; } loData['D' + lsCero + F.trim(i)] = loRet.json[i]; } if (F.intval(aoParams.xls) === 1 || F.intval(aoParams.Xls) === 1) { const loDataXls = loData && loData.D000 ? loData.D000 : []; const loRetB64 = yield this.exportXls(loDataXls); return loRetB64; } if (this.mbCustomRet === true) { return this.customRet(loData); } return F.fnRetOk(loData); }); } customRet(aoData) { return __awaiter(this, void 0, void 0, function* () { return F.fnRetOk(aoData); }); } exportXls(aoData) { return __awaiter(this, void 0, void 0, function* () { const loCol = this.xlsDef(); const lsUsr = this.moUPRM ? this.moUPRM.P_USR : '0'; const loNull = null; const loPrm = { l: loCol, d: aoData, ps: 10000, cp: 1, u: lsUsr, strip: true, wb: loNull, }; // Parámetros para exportar a Excel. const lsTag = ''; const lsSbj = ''; this.fnMakeXlsParams(loPrm, this.msTitle, lsTag, lsSbj); const loRet = yield this.fnExportDataToExcel(loPrm); return loRet; }); } xlsDef() { const loCol = []; const loExt = this.xlsDefExtraField(); loExt.forEach((c) => { loCol.push(c); }); return loCol; } xlsDefExtraField() { const loCol = [ this.fnRowXls('c ', 'Código ', 100, '', 'L', U.jDTT.xText), this.fnRowXls('d ', 'Descripcion ', 350, '', 'L', U.jDTT.xText), this.fnRowXls('o ', 'Observaciones ', 600, '', 'L', U.jDTT.xText), ]; return loCol; } getSPParams(aoParam) { return [ { n: 'i', v: F.trim(aoParam.i), t: 'T', p: 0 }, { n: 'c', v: F.trim(aoParam.c), t: 'T', p: 0 }, { n: 'd', v: F.trim(aoParam.d), t: 'T', p: 0 }, ]; } } exports.QuerySPAll = QuerySPAll;