Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 4x 25x 4x 4x 25x 4x 13x 13x 13x 13x 13x 13x 13x 13x 3x 10x 3x 7x 3x 4x 3x 13x 13x 70x 70x 70x 18x 13x | import moment from 'moment-timezone'; import UserDao from '../../database/dao/user'; import I18n from '../../helpers/i18n'; import { models } from '../../../config/database'; import { mountWhereBasedFilter } from '../../helpers/reports/sequelize'; // Funcao criada para popular o array headers e rows enviados por parametro export default async function generateData( columns, filters, headers = [], rows = [], opts = {}, appLanguage = 'ptBr' ) { const where = mountWhereBasedFilter(filters); const headersValue = columns.map((it) => it.value); const dados = await UserDao.findUsers(where, { attributes: headersValue, include: [ { required: true, model: models.User, as: 'userCreated', attributes: ['login'], }, { required: true, model: models.User, as: 'userUpdated', attributes: ['login'], }, { required: false, model: models.Department, as: 'departmentUser', attributes: ['name'], }, { required: false, model: models.UserFunction, as: 'functionUser', attributes: ['name'], }, { required: false, model: models.WorkShift, as: 'workShiftUser', attributes: ['name'], }, { required: false, model: models.AccessProfile, as: 'accessProfileUser', attributes: ['name'], }, ], ...opts, }); columns.forEach((it) => { headers.push(it.label); }); dados.forEach((it) => { it.createdUser = it.userCreated.dataValues.login; it.updatedUser = it.userUpdated.dataValues.login; it.status ? (it.status = I18n.t('BEE499' /* Ativo */, undefined, appLanguage)) : (it.status = I18n.t('BEE207' /* Bloqueado */, undefined, appLanguage)); it.department ? (it.department = it.departmentUser.name) : ''; it.userFunction ? (it.userFunction = it.functionUser.name) : ''; it.workShift ? (it.workShift = it.workShiftUser.name) : ''; it.accessProfile ? (it.accessProfile = it.accessProfileUser.name) : ''; if (it.type === 1) { it.type = I18n.t('BEE510' /* Master */, undefined, appLanguage); } else if (it.type === 2) { it.type = I18n.t('BEE511' /* Administrador */, undefined, appLanguage); } else if (it.type === 3) { it.type = I18n.t('BEE512' /* Operacional */, undefined, appLanguage); } else if (it.type === 4) { it.type = I18n.t('BEE513' /* Integração */, undefined, appLanguage); } const row = []; for (let index = 0; index < headersValue.length; index++) { const column = headersValue[index]; row.push(it[column]); if (column === 'createdAt' || column === 'updatedAt') { row[index] = moment(row[index]).format('l LTS'); } } rows.push(row); }); } |