production with searchbar
This commit is contained in:
parent
c615df2c1e
commit
13c15bb5b3
|
@ -7,7 +7,9 @@
|
|||
index="index"
|
||||
on-search="$ctrl.search(index)"
|
||||
advanced="true"
|
||||
popover="vn-client-search-panel">
|
||||
popover="vn-client-search-panel"
|
||||
ignore-keys = "['page', 'size', 'search']"
|
||||
>
|
||||
</vn-searchbar>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -8,6 +8,14 @@ function index(mgIndex) {
|
|||
}
|
||||
module.factory('vnIndex', index);
|
||||
|
||||
nonAuto.$inject = ['mgIndex'];
|
||||
function nonAuto(mgIndex) {
|
||||
return Object.assign({}, mgIndex, {
|
||||
auto: false
|
||||
});
|
||||
}
|
||||
module.factory('vnIndexNonAuto', nonAuto);
|
||||
|
||||
successFactoryCreate.$inject = ['mgSuccessFactoryCreate'];
|
||||
function successFactoryCreate(create) {
|
||||
return Object.assign({}, create, {
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
<mg-ajax path="/production/api/States/list" options="vnIndex as states" actions="$ctrl.states = states.model;"></mg-ajax>
|
||||
|
||||
<mg-ajax path="/production/api/FakeProductions/list" options="vnIndexNonAuto as index"></mg-ajax>
|
||||
<vn-card margin-large>
|
||||
<vn-vertical pad-medium>
|
||||
<vn-horizontal vn-one margin-large-bottom class="locator-header">
|
||||
<vn-title vn-one><span translate>Finder</span></vn-title>
|
||||
|
||||
<form vn-two vn-horizontal class="filterPanel" ng-submit="$ctrl.searchTickets()">
|
||||
<vn-textfield vn-one label="Filtro" model="$ctrl.search"></vn-textfield>
|
||||
<vn-icon
|
||||
vn-none
|
||||
margin-medium-right
|
||||
pad-medium-top
|
||||
icon="keyboard_arrow_down"
|
||||
ng-click="$ctrl.moreFilters($event)">
|
||||
</vn-icon>
|
||||
<vn-button vn-none pad-small-top label="Filtrar" ng-click="$ctrl.searchTickets()"></vn-button>
|
||||
</form>
|
||||
<vn-searchbar vn-two
|
||||
index="index"
|
||||
on-search="$ctrl.searchTickets(index.filter)"
|
||||
advanced="true"
|
||||
popover="vn-production-filter-panel"
|
||||
ignore-keys = "['page', 'size', 'search', 'warehouseFk']"
|
||||
>
|
||||
</vn-searchbar>
|
||||
|
||||
<vn-one vn-horizontal>
|
||||
<vn-one></vn-one>
|
||||
|
@ -26,8 +23,8 @@
|
|||
field="$ctrl.filter.warehouseFk"
|
||||
url="/production/api/Warehouses/production"
|
||||
on-change = "$ctrl.onChangeWareHouse(item)"
|
||||
label="Store">
|
||||
</vn-autocomplete>
|
||||
label="Store"
|
||||
></vn-autocomplete>
|
||||
<vn-icon-button vn-none pad-ten-top margin-medium-left icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -2,11 +2,10 @@ import ngModule from '../module';
|
|||
import './style.scss';
|
||||
|
||||
export default class ProductionIndex {
|
||||
constructor($element, $scope, $http, vnPopover, aclConstant) {
|
||||
constructor($element, $scope, $http, aclConstant) {
|
||||
this.$element = $element;
|
||||
this.$ = $scope;
|
||||
this.$http = $http;
|
||||
this.vnPopover = vnPopover;
|
||||
this.filter = {};
|
||||
this.tickets = [];
|
||||
this.states = [];
|
||||
|
@ -23,17 +22,6 @@ export default class ProductionIndex {
|
|||
this.filter.warehouseFk = this.userProfile.warehouseId;
|
||||
}
|
||||
|
||||
get search() {
|
||||
return this._search;
|
||||
}
|
||||
set search(value) {
|
||||
this._search = value;
|
||||
this.filter.q = value;
|
||||
if (!value) {
|
||||
this.searchTickets();
|
||||
}
|
||||
}
|
||||
|
||||
get checkAll() {
|
||||
return this._checkAll;
|
||||
}
|
||||
|
@ -72,55 +60,21 @@ export default class ProductionIndex {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
moreFilters(event) {
|
||||
this.child = this.vnPopover.showComponent('vn-production-filter-panel', this.$, this.$element[0].querySelector('.filterPanel'));
|
||||
var childCtrl = angular.element(this.child).isolateScope().$ctrl;
|
||||
childCtrl.filter = Object.assign({}, this.filter);
|
||||
childCtrl.data = Object.assign({}, {states: this.states}, {hourItems: this.hourItems});
|
||||
childCtrl.onSubmit = filter => this.onChildSubmit(filter);
|
||||
childCtrl.onCancel = () => this.onChildCancel();
|
||||
event.preventDefault();
|
||||
}
|
||||
onChildSubmit(filter) {
|
||||
let newFilter = {};
|
||||
Object.keys(filter).forEach(
|
||||
field => {
|
||||
if (filter[field] !== null) {
|
||||
newFilter[field] = filter[field];
|
||||
}
|
||||
}
|
||||
);
|
||||
this.searchTickets(newFilter);
|
||||
this.onChildCancel();
|
||||
}
|
||||
onChildCancel() {
|
||||
angular.element(this.child).scope().$destroy();
|
||||
angular.element(this.child).remove();
|
||||
delete this.child;
|
||||
}
|
||||
searchTickets(filter) {
|
||||
this.filter = Object.assign({}, this.filter, filter || {});
|
||||
let filters = Object.assign({}, {
|
||||
where: this.filter
|
||||
}, {
|
||||
page: 1,
|
||||
limit: 1000
|
||||
});
|
||||
this.$.index.filter.filter = Object.assign({}, this.filter, filter || {});
|
||||
this.checkAll = 0;
|
||||
this.$http.get('/production/api/FakeProductions/list?filter=' + JSON.stringify(filters)).then(
|
||||
this.$.index.accept().then(
|
||||
json => {
|
||||
this.tickets = json.data.tickets;
|
||||
this.footer.lines = json.data.lines;
|
||||
this.footer.meters = json.data.m3;
|
||||
this.footer.total = json.data.total;
|
||||
this.tickets = json.tickets;
|
||||
this.footer.lines = json.lines;
|
||||
this.footer.meters = json.m3;
|
||||
this.footer.total = json.total;
|
||||
}
|
||||
);
|
||||
}
|
||||
refreshTickets() {
|
||||
this.filter = {};
|
||||
this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId;
|
||||
this.search = null;
|
||||
}
|
||||
onChangeWareHouse(warehouse) {
|
||||
if (warehouse && warehouse != this.filter.warehouseFk) {
|
||||
|
@ -141,7 +95,7 @@ export default class ProductionIndex {
|
|||
}
|
||||
}
|
||||
|
||||
ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'aclConstant'];
|
||||
ProductionIndex.$inject = ['$element', '$scope', '$http', 'aclConstant'];
|
||||
|
||||
ngModule.component('vnProductionIndex', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -40,7 +40,8 @@ export default class Controller {
|
|||
let keys = Object.keys(filter);
|
||||
if (keys.length) {
|
||||
keys.forEach(k => {
|
||||
if (k !== 'page' && k !== 'size' && k !== 'search') {
|
||||
let ignore = (this.ignoreKeys && this.ignoreKeys instanceof Array && this.ignoreKeys.indexOf(k) !== -1);
|
||||
if (!ignore) {
|
||||
let value = filter[k];
|
||||
|
||||
if (typeof value === 'string' && value.indexOf(' ') !== -1) {
|
||||
|
@ -110,7 +111,8 @@ ngModule.component('vnSearchbar', {
|
|||
onSearch: '&',
|
||||
advanced: '=',
|
||||
popover: '@',
|
||||
label: '@?'
|
||||
label: '@?',
|
||||
ignoreKeys: '<?'
|
||||
},
|
||||
controller: Controller
|
||||
});
|
||||
|
|
|
@ -3,10 +3,10 @@ module.exports = function(Self) {
|
|||
|
||||
Self.list = function(ctx, filter, callback) {
|
||||
let daysTickets = 0;
|
||||
let warehouseFk = filter.where.warehouseFk;
|
||||
let warehouseFk = filter.warehouseFk;
|
||||
delete filter.limit;
|
||||
delete filter.page;
|
||||
delete filter.where.warehouseFk;
|
||||
delete filter.warehouseFk;
|
||||
|
||||
let call = `call salix.production_control_source(? , ?)`;
|
||||
var params = [warehouseFk, daysTickets];
|
||||
|
@ -25,17 +25,19 @@ module.exports = function(Self) {
|
|||
onFinish(err);
|
||||
}
|
||||
|
||||
reBuildFilter();
|
||||
buildWhereObject();
|
||||
|
||||
let where = Self.dataSource.connector.buildWhere(Self.modelName, filter.where);
|
||||
let query = `SELECT * FROM tmp.production ${where.sql} GROUP BY RouteFk ORDER BY routeFk`;
|
||||
conn.query(query, where.params, onFinish);
|
||||
}
|
||||
|
||||
function reBuildFilter() {
|
||||
if (filter.where && filter.where.q) {
|
||||
let regexQ = new RegExp(filter.where.q);
|
||||
delete filter.where.q;
|
||||
let newFilter = {
|
||||
function buildWhereObject() {
|
||||
let newFilter = {};
|
||||
if (filter.q) {
|
||||
let regexQ = new RegExp(filter.q);
|
||||
delete filter.q;
|
||||
newFilter = {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
|
@ -46,17 +48,20 @@ module.exports = function(Self) {
|
|||
]
|
||||
};
|
||||
|
||||
if (Object.keys(filter.where).length) {
|
||||
Object.keys(filter.where).forEach(
|
||||
if (Object.keys(filter).length) {
|
||||
Object.keys(filter).forEach(
|
||||
key => {
|
||||
let field = {};
|
||||
field[key] = filter.where[key];
|
||||
field[key] = filter[key];
|
||||
newFilter.and.push(field);
|
||||
}
|
||||
);
|
||||
}
|
||||
filter.where = newFilter;
|
||||
} else if (Object.keys(filter).length) {
|
||||
newFilter = filter;
|
||||
}
|
||||
|
||||
filter.where = newFilter;
|
||||
}
|
||||
|
||||
function onFinish(err, results) {
|
||||
|
|
Loading…
Reference in New Issue