Updated filter
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
36ad778a59
commit
7987603d7b
|
@ -82,13 +82,13 @@ module.exports = Self => {
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
let teamIds = [];
|
let teamIds = [];
|
||||||
|
|
||||||
if (worker.collegues().length && ctx.args.myTeam) {
|
if (worker.collegues().length && args.myTeam) {
|
||||||
worker.collegues().forEach(collegue => {
|
worker.collegues().forEach(collegue => {
|
||||||
teamIds.push(collegue.collegueFk);
|
teamIds.push(collegue.collegueFk);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worker.collegues().length === 0 && ctx.args.myTeam) {
|
if (worker.collegues().length === 0 && args.myTeam) {
|
||||||
worker = await Self.app.models.Worker.findOne({
|
worker = await Self.app.models.Worker.findOne({
|
||||||
fields: ['id'],
|
fields: ['id'],
|
||||||
where: {userFk: ctx.req.accessToken.userId}
|
where: {userFk: ctx.req.accessToken.userId}
|
||||||
|
@ -96,9 +96,9 @@ module.exports = Self => {
|
||||||
teamIds = [worker && worker.id];
|
teamIds = [worker && worker.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.args && ctx.args.myTeam)
|
if (args && args.myTeam)
|
||||||
ctx.args.teamIds = teamIds;
|
args.teamIds = teamIds;
|
||||||
let where = buildFilter(ctx.args, (param, value) => {
|
let where = buildFilter(args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
return /^\d+$/.test(value)
|
return /^\d+$/.test(value)
|
||||||
|
@ -106,7 +106,6 @@ module.exports = Self => {
|
||||||
: {or: [
|
: {or: [
|
||||||
{'c.name': {like: `%${value}%`}}
|
{'c.name': {like: `%${value}%`}}
|
||||||
]};
|
]};
|
||||||
// return {'o.id': value};
|
|
||||||
case 'from':
|
case 'from':
|
||||||
return {'o.date_send': {gte: value}};
|
return {'o.date_send': {gte: value}};
|
||||||
case 'to':
|
case 'to':
|
||||||
|
@ -125,6 +124,8 @@ module.exports = Self => {
|
||||||
return {'o.confirmed': value ? 1 : 0};
|
return {'o.confirmed': value ? 1 : 0};
|
||||||
case 'myTeam':
|
case 'myTeam':
|
||||||
return {'c.salesPersonFk': {inq: teamIds}};
|
return {'c.salesPersonFk': {inq: teamIds}};
|
||||||
|
case 'showEmpty':
|
||||||
|
return {'o.total': {neq: value}};
|
||||||
case 'id':
|
case 'id':
|
||||||
param = `o.${param}`;
|
param = `o.${param}`;
|
||||||
return {[param]: value};
|
return {[param]: value};
|
||||||
|
@ -164,7 +165,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN account.user u ON u.id = wk.userFk
|
LEFT JOIN account.user u ON u.id = wk.userFk
|
||||||
LEFT JOIN company co ON co.id = o.company_id`);
|
LEFT JOIN company co ON co.id = o.company_id`);
|
||||||
|
|
||||||
if (ctx.args && ctx.args.ticketFk) {
|
if (args && args.ticketFk) {
|
||||||
stmt.merge({
|
stmt.merge({
|
||||||
sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id`
|
sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id`
|
||||||
});
|
});
|
||||||
|
@ -186,13 +187,6 @@ module.exports = Self => {
|
||||||
`SELECT f.*, ot.*
|
`SELECT f.*, ot.*
|
||||||
FROM tmp.filter f
|
FROM tmp.filter f
|
||||||
LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`);
|
LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`);
|
||||||
const filterWhere = {};
|
|
||||||
|
|
||||||
if (args && args.showEmpty === false)
|
|
||||||
filterWhere.total = {neq: 0};
|
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filterWhere));
|
|
||||||
|
|
||||||
const orderIndex = stmts.push(stmt) - 1;
|
const orderIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
stmts.push(`
|
stmts.push(`
|
||||||
|
|
|
@ -3,7 +3,7 @@ import ModuleMain from 'salix/components/module-main';
|
||||||
|
|
||||||
export default class Order extends ModuleMain {
|
export default class Order extends ModuleMain {
|
||||||
$postLink() {
|
$postLink() {
|
||||||
// this.filter = {showEmpty: false};
|
this.filter = {showEmpty: false};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,11 @@
|
||||||
triple-state="true"
|
triple-state="true"
|
||||||
ng-model="filter.isConfirmed">
|
ng-model="filter.isConfirmed">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<!-- <vn-check
|
<vn-check
|
||||||
vn-one
|
vn-one
|
||||||
label="Show empty"
|
label="Show empty"
|
||||||
ng-model="filter.showEmpty">
|
ng-model="filter.showEmpty">
|
||||||
</vn-check> -->
|
</vn-check>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="vn-mt-lg">
|
<vn-horizontal class="vn-mt-lg">
|
||||||
<vn-submit label="Search"></vn-submit>
|
<vn-submit label="Search"></vn-submit>
|
||||||
|
|
Loading…
Reference in New Issue