Commit cd1375474cf58333fcd7f896f06fa37b2310cc85
1 parent
3fd67619
Exists in
master
报表增加日期查询
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
app/controller/project.js
| @@ -41,8 +41,10 @@ class ProjectController extends Controller { | @@ -41,8 +41,10 @@ class ProjectController extends Controller { | ||
| 41 | } | 41 | } |
| 42 | async analysis() { | 42 | async analysis() { |
| 43 | const ctx = this.ctx; | 43 | const ctx = this.ctx; |
| 44 | + const param = qs.parse(this.ctx.query); | ||
| 45 | + const date = param.date; | ||
| 44 | try { | 46 | try { |
| 45 | - const result = await ctx.service.project.analysis(); | 47 | + const result = await ctx.service.project.analysis(date); |
| 46 | this.ctx.body = { | 48 | this.ctx.body = { |
| 47 | result, | 49 | result, |
| 48 | success: true, | 50 | success: true, |
app/service/project.js
| @@ -5,7 +5,7 @@ const objExclude = require('../util/common').objExclude; | @@ -5,7 +5,7 @@ const objExclude = require('../util/common').objExclude; | ||
| 5 | const moment = require('moment'); | 5 | const moment = require('moment'); |
| 6 | 6 | ||
| 7 | class ProjectService extends Service { | 7 | class ProjectService extends Service { |
| 8 | - async analysis() { | 8 | + async analysis(date) { |
| 9 | // const sql = ` | 9 | // const sql = ` |
| 10 | // select | 10 | // select |
| 11 | // project.number, | 11 | // project.number, |
| @@ -23,16 +23,17 @@ class ProjectService extends Service { | @@ -23,16 +23,17 @@ class ProjectService extends Service { | ||
| 23 | select a.*,b.p_value, b.p_other_expenses,b.p_invoice from | 23 | select a.*,b.p_value, b.p_other_expenses,b.p_invoice from |
| 24 | ( | 24 | ( |
| 25 | select | 25 | select |
| 26 | - project.number, project.name, contract.value as s_value, contract.other_expenses as s_other_expenses, contract.invoice as s_invoice | 26 | + project.number, project.name, project.create_time, contract.value as s_value, contract.other_expenses as s_other_expenses, contract.invoice as s_invoice |
| 27 | from project, contract where project.sale_contract_id = contract.id | 27 | from project, contract where project.sale_contract_id = contract.id |
| 28 | ) a | 28 | ) a |
| 29 | left join | 29 | left join |
| 30 | ( | 30 | ( |
| 31 | select | 31 | select |
| 32 | - project.number, project.name, contract.value as p_value, contract.other_expenses as p_other_expenses, contract.invoice as p_invoice | 32 | + project.number, project.name, project.create_time, contract.value as p_value, contract.other_expenses as p_other_expenses, contract.invoice as p_invoice |
| 33 | from project, contract where project.purchase_contract_id = contract.id | 33 | from project, contract where project.purchase_contract_id = contract.id |
| 34 | ) b | 34 | ) b |
| 35 | on a.number = b.number | 35 | on a.number = b.number |
| 36 | + ${date !== undefined && date !== null ? ` where a.create_time like '%${date}%'` : ''} | ||
| 36 | `; | 37 | `; |
| 37 | const result = await this.app.mysql.query(sql); | 38 | const result = await this.app.mysql.query(sql); |
| 38 | return result; | 39 | return result; |