diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index e86830200..730fa9ec0 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -23,7 +23,7 @@ module.exports = Self => { { arg: 'search', 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'} }, { @@ -34,31 +34,31 @@ module.exports = Self => { }, { arg: 'id', - type: 'integer', + type: 'number', description: 'The claim id', http: {source: 'query'} }, { arg: 'clientFk', - type: 'integer', + type: 'number', description: 'The client id', http: {source: 'query'} }, { arg: 'claimStateFk', - type: 'integer', + type: 'number', description: 'The claim state id', http: {source: 'query'} }, { arg: 'salesPersonFk', - type: 'integer', + type: 'number', description: 'The salesPerson id', http: {source: 'query'} }, { arg: 'attenderFk', - type: 'integer', + type: 'number', description: 'The attender worker id', http: {source: 'query'} }, @@ -67,6 +67,18 @@ module.exports = Self => { type: 'date', description: 'The to date filter', 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: { @@ -100,9 +112,10 @@ module.exports = Self => { case 'clientName': return {'cl.clientName': {like: `%${value}%`}}; case 'clientFk': - return {'cl.clientFk': value}; case 'id': case 'claimStateFk': + case 'itemFk': + case 'claimResponsibleFk': case 'priority': return {[`cl.${param}`]: value}; case 'salesPersonFk': @@ -123,9 +136,9 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT * + `SELECT * FROM ( - SELECT + SELECT DISTINCT cl.id, cl.clientFk, c.name AS clientName, @@ -135,12 +148,17 @@ module.exports = Self => { cl.created, cs.priority, cl.claimStateFk, - c.salesPersonFk + c.salesPersonFk, + s.itemFk, + cd.claimResponsibleFk FROM claim cl 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 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)); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index eec8cd727..151a06c8e 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -58,8 +58,28 @@ ng-model="filter.created"> + + + {{::id}} - {{::name}} + + + + - \ No newline at end of file + diff --git a/modules/claim/front/search-panel/index.js b/modules/claim/front/search-panel/index.js index a7e8fb046..2400b8ede 100644 --- a/modules/claim/front/search-panel/index.js +++ b/modules/claim/front/search-panel/index.js @@ -1,7 +1,14 @@ import ngModule from '../module'; 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', { template: require('./index.html'), - controller: SearchPanel + controller: Controller });