This commit is contained in:
parent
f37c66304f
commit
bb5247c49b
|
@ -1,5 +1,3 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
|
@ -51,7 +49,6 @@ 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':
|
||||
|
@ -71,9 +68,7 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
filter = mergeFilters(ctx.args.filter, {where});
|
||||
console.log(filter);
|
||||
const departments = await Self.app.models.Department.find(filter);
|
||||
console.log(departments);
|
||||
return departments;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -25,14 +25,12 @@ module.exports = Self => {
|
|||
`CALL department_getLeaves(?, ?)`,
|
||||
[parentId, search]
|
||||
);
|
||||
|
||||
let map = new Map();
|
||||
for (let node of res) {
|
||||
if (!map.has(node.parentFk))
|
||||
map.set(node.parentFk, []);
|
||||
map.get(node.parentFk).push(node);
|
||||
}
|
||||
|
||||
function setLeaves(nodes) {
|
||||
if (!nodes) return;
|
||||
for (let node of nodes) {
|
||||
|
@ -42,6 +40,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
let leaves = map.get(parentId);
|
||||
|
||||
setLeaves(leaves);
|
||||
|
||||
return leaves || [];
|
||||
|
|
|
@ -3,5 +3,4 @@ module.exports = Self => {
|
|||
require('../methods/department/createChild')(Self);
|
||||
require('../methods/department/removeChild')(Self);
|
||||
require('../methods/department/moveChild')(Self);
|
||||
require('../methods/department/filter')(Self);
|
||||
};
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
<vn-popup vn-id="summary">
|
||||
<vn-worker-summary worker="$ctrl.worker"></vn-worker-summary>
|
||||
</vn-popup>
|
||||
|
||||
<vn-confirm
|
||||
vn-id="deleteConfirmation"
|
||||
on-accept="$ctrl.deleteDepartment()"
|
||||
|
|
|
@ -4,5 +4,4 @@ import './summary';
|
|||
import './card';
|
||||
import './descriptor';
|
||||
import './basic-data';
|
||||
import './search-panel';
|
||||
import './descriptor-popover';
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
url="departments/getLeaves"
|
||||
auto-load="false">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
info="Search departments by id, name or code"
|
||||
on-search="$ctrl.onSearch($params)"
|
||||
base-state="worker.department">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<form name="form" class="vn-w-md">
|
||||
<vn-card class="vn-pa-md">
|
||||
<vn-treeview vn-id="treeview" root-label="Departments" read-only="false"
|
||||
|
|
|
@ -6,6 +6,13 @@ class Controller extends Section {
|
|||
this.$.treeview.fetch();
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
this.$.model.applyFilter({}, params).then(() => {
|
||||
const data = this.$.model.data;
|
||||
this.$.treeview.data = data;
|
||||
});
|
||||
}
|
||||
|
||||
onFetch(item) {
|
||||
const params = item ? {parentId: item.id} : null;
|
||||
return this.$.model.applyFilter({}, params).then(() => {
|
||||
|
|
|
@ -4,15 +4,6 @@
|
|||
limit="20"
|
||||
order="id">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
vn-focus
|
||||
panel="vn-worker-department-search-panel"
|
||||
info="Search departments by id, name or code"
|
||||
model="model"
|
||||
base-state="worker.department">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<ui-view>
|
||||
<vn-worker-department-index></vn-worker-department-index>
|
||||
</ui-view>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<div class="search-panel">
|
||||
<form ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="filter.name"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Code"
|
||||
ng-model="filter.code">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -1,7 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
ngModule.component('vnWorkerDepartmentSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
});
|
|
@ -33,7 +33,6 @@ module.exports = Self => {
|
|||
|
||||
Self.getLeaves = async(id, parentId = null, search, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue