项企-报表中心
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
2.0 KiB

'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,//业绩
}