feat: buscar por itemFk y claimResponsibleFk
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-11-23 14:04:43 +01:00
parent c02be35e1c
commit 1c6a5164d4
3 changed files with 59 additions and 14 deletions

View File

@ -23,7 +23,7 @@ module.exports = Self => {
{ {
arg: 'search', arg: 'search',
type: 'string', type: 'string',
description: `If it's and integer searchs by id, otherwise it searchs by client name`, description: `If it's and number searchs by id, otherwise it searchs by client name`,
http: {source: 'query'} http: {source: 'query'}
}, },
{ {
@ -34,31 +34,31 @@ module.exports = Self => {
}, },
{ {
arg: 'id', arg: 'id',
type: 'integer', type: 'number',
description: 'The claim id', description: 'The claim id',
http: {source: 'query'} http: {source: 'query'}
}, },
{ {
arg: 'clientFk', arg: 'clientFk',
type: 'integer', type: 'number',
description: 'The client id', description: 'The client id',
http: {source: 'query'} http: {source: 'query'}
}, },
{ {
arg: 'claimStateFk', arg: 'claimStateFk',
type: 'integer', type: 'number',
description: 'The claim state id', description: 'The claim state id',
http: {source: 'query'} http: {source: 'query'}
}, },
{ {
arg: 'salesPersonFk', arg: 'salesPersonFk',
type: 'integer', type: 'number',
description: 'The salesPerson id', description: 'The salesPerson id',
http: {source: 'query'} http: {source: 'query'}
}, },
{ {
arg: 'attenderFk', arg: 'attenderFk',
type: 'integer', type: 'number',
description: 'The attender worker id', description: 'The attender worker id',
http: {source: 'query'} http: {source: 'query'}
}, },
@ -67,6 +67,18 @@ module.exports = Self => {
type: 'date', type: 'date',
description: 'The to date filter', description: 'The to date filter',
http: {source: 'query'} http: {source: 'query'}
},
{
arg: 'itemFk',
type: 'number',
description: 'The item id',
http: {source: 'query'}
},
{
arg: 'claimResponsibleFk',
type: 'number',
description: 'The claimResponsible id',
http: {source: 'query'}
} }
], ],
returns: { returns: {
@ -100,9 +112,10 @@ module.exports = Self => {
case 'clientName': case 'clientName':
return {'cl.clientName': {like: `%${value}%`}}; return {'cl.clientName': {like: `%${value}%`}};
case 'clientFk': case 'clientFk':
return {'cl.clientFk': value};
case 'id': case 'id':
case 'claimStateFk': case 'claimStateFk':
case 'itemFk':
case 'claimResponsibleFk':
case 'priority': case 'priority':
return {[`cl.${param}`]: value}; return {[`cl.${param}`]: value};
case 'salesPersonFk': case 'salesPersonFk':
@ -125,7 +138,7 @@ module.exports = Self => {
const stmt = new ParameterizedSQL( const stmt = new ParameterizedSQL(
`SELECT * `SELECT *
FROM ( FROM (
SELECT SELECT DISTINCT
cl.id, cl.id,
cl.clientFk, cl.clientFk,
c.name AS clientName, c.name AS clientName,
@ -135,12 +148,17 @@ module.exports = Self => {
cl.created, cl.created,
cs.priority, cs.priority,
cl.claimStateFk, cl.claimStateFk,
c.salesPersonFk c.salesPersonFk,
s.itemFk,
cd.claimResponsibleFk
FROM claim cl FROM claim cl
LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN client c ON c.id = cl.clientFk
LEFT JOIN worker w ON w.id = cl.workerFk LEFT JOIN worker w ON w.id = cl.workerFk
LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN claimState cs ON cs.id = cl.claimStateFk ) cl` LEFT JOIN claimState cs ON cs.id = cl.claimStateFk
LEFT JOIN claimBeginning cb ON cb.claimFk = cl.id
LEFT JOIN sale s ON s.id = cb.saleFk
LEFT JOIN claimDevelopment cd ON cd.claimFk = cl.id ) cl`
); );
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));

View File

@ -58,6 +58,26 @@
ng-model="filter.created"> ng-model="filter.created">
</vn-date-picker> </vn-date-picker>
</vn-horizontal> </vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one class="dense"
label="Item"
url="Items/withName"
ng-model="filter.itemFk"
show-field="name"
value-field="id"
search-function="$ctrl.itemSearchFunc($search)"
order="id DESC">
<tpl-item>{{::id}} - {{::name}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete
vn-one
ng-model="filter.claimResponsibleFk"
url="ClaimResponsibles"
show-field="description"
value-field="id"
label="Responsible">
</vn-autocomplete>
</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>
</vn-horizontal> </vn-horizontal>

View File

@ -1,7 +1,14 @@
import ngModule from '../module'; import ngModule from '../module';
import SearchPanel from 'core/components/searchbar/search-panel'; import SearchPanel from 'core/components/searchbar/search-panel';
class Controller extends SearchPanel {
itemSearchFunc($search) {
return /^\d+$/.test($search)
? {id: $search}
: {name: {like: '%' + $search + '%'}};
}
}
ngModule.vnComponent('vnClaimSearchPanel', { ngModule.vnComponent('vnClaimSearchPanel', {
template: require('./index.html'), template: require('./index.html'),
controller: SearchPanel controller: Controller
}); });