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 | 41 | } |
| 42 | 42 | async analysis() { |
| 43 | 43 | const ctx = this.ctx; |
| 44 | + const param = qs.parse(this.ctx.query); | |
| 45 | + const date = param.date; | |
| 44 | 46 | try { |
| 45 | - const result = await ctx.service.project.analysis(); | |
| 47 | + const result = await ctx.service.project.analysis(date); | |
| 46 | 48 | this.ctx.body = { |
| 47 | 49 | result, |
| 48 | 50 | success: true, | ... | ... |
app/service/project.js
| ... | ... | @@ -5,7 +5,7 @@ const objExclude = require('../util/common').objExclude; |
| 5 | 5 | const moment = require('moment'); |
| 6 | 6 | |
| 7 | 7 | class ProjectService extends Service { |
| 8 | - async analysis() { | |
| 8 | + async analysis(date) { | |
| 9 | 9 | // const sql = ` |
| 10 | 10 | // select |
| 11 | 11 | // project.number, |
| ... | ... | @@ -23,16 +23,17 @@ class ProjectService extends Service { |
| 23 | 23 | select a.*,b.p_value, b.p_other_expenses,b.p_invoice from |
| 24 | 24 | ( |
| 25 | 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 | 27 | from project, contract where project.sale_contract_id = contract.id |
| 28 | 28 | ) a |
| 29 | 29 | left join |
| 30 | 30 | ( |
| 31 | 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 | 33 | from project, contract where project.purchase_contract_id = contract.id |
| 34 | 34 | ) b |
| 35 | 35 | on a.number = b.number |
| 36 | + ${date !== undefined && date !== null ? ` where a.create_time like '%${date}%'` : ''} | |
| 36 | 37 | `; |
| 37 | 38 | const result = await this.app.mysql.query(sql); |
| 38 | 39 | return result; | ... | ... |