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">
-
-