From 4c7c7f5c962ba0664222dd4c367626bf0382e6be Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 1 Jun 2023 11:30:28 +0200 Subject: [PATCH] refs #5334 mod search-panel --- .../worker/back/methods/department/filter.js | 33 +++++++------------ .../front/department/basic-data/index.html | 24 ++++++++------ .../front/department/descriptor/index.html | 17 +++++----- .../worker/front/department/main/index.html | 2 +- modules/worker/front/routes.json | 5 +-- 5 files changed, 37 insertions(+), 44 deletions(-) diff --git a/modules/worker/back/methods/department/filter.js b/modules/worker/back/methods/department/filter.js index 232d30eed..c04d3b414 100644 --- a/modules/worker/back/methods/department/filter.js +++ b/modules/worker/back/methods/department/filter.js @@ -51,40 +51,29 @@ module.exports = Self => { Self.filter = async(ctx, filter) => { let conn = Self.dataSource.connector; - + console.log('ENTRY'); let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) - ? {'d.id': value} + ? {'id': value} : {or: [ - {'d.code': {like: `%${value}%`}}, - {'d.name': {like: `%${value}%`}} + {'code': {like: `%${value}%`}}, + {'name': {like: `%${value}%`}} ]}; case 'id': - return {'d.id': value}; + return {'id': value}; case 'code': - return {'d.code': value}; + return {'code': value}; case 'name': - return {'d.name': {like: `%${value}%`}}; + return {'name': {like: `%${value}%`}}; } }); filter = mergeFilters(ctx.args.filter, {where}); - - let stmts = []; - let stmt; - - stmt = new ParameterizedSQL( - `SELECT id, code, name - FROM department d` - ); - - stmt.merge(conn.makeSuffix(filter)); - let itemsIndex = stmts.push(stmt) - 1; - - let sql = ParameterizedSQL.join(stmts, ';'); - let result = await conn.executeStmt(sql); - return itemsIndex === 0 ? result : result[itemsIndex]; + console.log(filter); + const departments = await Self.app.models.Department.find(filter); + console.log(departments); + return departments; }; }; diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index ef5760be2..d8a3ac921 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -36,16 +36,20 @@ - - - - + + + + - - + @@ -44,8 +48,3 @@ on-accept="$ctrl.deleteDepartment()" question="You are going to delete this department"> - -