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