Browse Source

(*)报表查询接口 修改排序

master
wuqun 2 years ago
parent
commit
603d93af63
  1. 12
      api/app/lib/controllers/report/achievement.js
  2. 2
      api/app/lib/controllers/report/index.js

12
api/app/lib/controllers/report/achievement.js

@ -12,7 +12,7 @@ async function getReceivedDetail(ctx) {
} }
let findOption = { let findOption = {
where: where, where: where,
order: [['id', 'DESC']] order: [['id', 'ASC']]
} }
if (!toExport) {//非导出时考虑分页 if (!toExport) {//非导出时考虑分页
if (limit) { if (limit) {
@ -132,7 +132,7 @@ async function getAchievementDetail(ctx) {
} }
let findOption = { let findOption = {
where: where, where: where,
order: [['id', 'DESC']] order: [['id', 'ASC']]
} }
if (!toExport) {//非导出时考虑分页 if (!toExport) {//非导出时考虑分页
if (limit) { if (limit) {
@ -349,7 +349,7 @@ async function getContractDetail(ctx) {
where: where, where: where,
offset: Number(page) * Number(limit), offset: Number(page) * Number(limit),
limit: Number(limit), limit: Number(limit),
order: [['id', 'DESC']] order: [['id', 'ASC']]
}); });
ctx.status = 200 ctx.status = 200
ctx.body = contractDetail; ctx.body = contractDetail;
@ -376,7 +376,7 @@ async function getInvoicingDetail(ctx) {
where: where, where: where,
offset: Number(page) * Number(limit), offset: Number(page) * Number(limit),
limit: Number(limit), limit: Number(limit),
order: [['id', 'DESC']] order: [['id', 'ASC']]
}); });
ctx.status = 200 ctx.status = 200
ctx.body = invoiceDetail; ctx.body = invoiceDetail;
@ -394,7 +394,7 @@ async function exportContractDetail(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
let exportData = await models.ContractDetail.findAll({ let exportData = await models.ContractDetail.findAll({
order: [['id', 'DESC']] order: [['id', 'ASC']]
}); });
const { utils: { simpleExcelDown, contractDetailsColumnKeys } } = ctx.app.fs; const { utils: { simpleExcelDown, contractDetailsColumnKeys } } = ctx.app.fs;
let header = []; let header = [];
@ -423,7 +423,7 @@ async function exportInvoicingDetail(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
let exportData = await models.InvoiceDetail.findAll({ let exportData = await models.InvoiceDetail.findAll({
order: [['id', 'DESC']] order: [['id', 'ASC']]
}); });
const { utils: { simpleExcelDown, invoicingDetailsColumnKeys } } = ctx.app.fs; const { utils: { simpleExcelDown, invoicingDetailsColumnKeys } } = ctx.app.fs;
let header = []; let header = [];

2
api/app/lib/controllers/report/index.js

@ -58,7 +58,7 @@ async function getSalersReport(ctx) {
const salersRes = await clickHouse.hr.query(` const salersRes = await clickHouse.hr.query(`
SELECT * from sales_distribution as sales SELECT * from sales_distribution as sales
${innerSelectQuery} ${innerSelectQuery}
order by id desc order by id asc
${!toExport && limit ? `LIMIT ${limit}` : ''} ${!toExport && limit ? `LIMIT ${limit}` : ''}
${!toExport && limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} ${!toExport && limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''}
`).toPromise() `).toPromise()

Loading…
Cancel
Save