'use strict'; const fs = require('fs'); const moment = require('moment'); //业绩报表相关 async function getReceivedDetail(ctx) { try { const { models } = ctx.fs.dc; const { keywordTarget, keyword, limit, page } = ctx.query let where = {} if (keywordTarget == 'contract' && keyword) { where.contractNo = { $like: `%${keyword}%` } } let res = await models.ReceivableDetail.findAndCountAll({ where: where, offset: Number(page) * Number(limit), limit: Number(limit), order: [['id', 'DESC']] }) ctx.status = 200 ctx.body = { count: res.count, rows: res.rows }; } catch (error) { ctx.fs.logger.error(`path:${ctx.path},error:${error}`) ctx.status = 400; ctx.body = { name: 'FindAllError', message: '获取失败' } } } async function getAchievementDetail(ctx) { try { const { models } = ctx.fs.dc; const { keywordTarget, keyword, limit, page } = ctx.query let where = {} if (keywordTarget == 'saler' && keyword) { where.sale = { $like: `%${keyword}%` } } if (keywordTarget == 'line' && keyword) { where.serviceLine = { $like: `%${keyword}%` } } if (keywordTarget == 'dep' && keyword) { where.department = { $like: `%${keyword}%` } } let res = await models.PerformanceDetail.findAndCountAll({ where: where, offset: Number(page) * Number(limit), limit: Number(limit), order: [['id', 'DESC']] }) ctx.status = 200 ctx.body = { count: res.count, rows: res.rows }; } catch (error) { ctx.fs.logger.error(`path:${ctx.path},error:${error}`) ctx.status = 400; ctx.body = { name: 'FindAllError', message: '获取失败' } } } module.exports = { getReceivedDetail,//回款 getAchievementDetail,//业绩 }