Localizador: acciones separadas a nuevo componente vnProductionActions
This commit is contained in:
parent
6815ab2b3c
commit
bfdd8ecd8e
|
@ -1,7 +1,6 @@
|
|||
vn-grid-header {
|
||||
border-bottom: 3px solid #9D9D9D;
|
||||
font-weight: bold;
|
||||
padding-right: 13px;
|
||||
.orderly{
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<vn-vertical vn-none class="multi-check {{$ctrl.className}}" tabindex="-1" ng-blur="$ctrl.showDropDown = false">
|
||||
<vn-vertical class="multi-check" vn-none class="multi-check {{$ctrl.className}}" tabindex="-1" ng-blur="$ctrl.showDropDown = false">
|
||||
<vn-one>
|
||||
<vn-horizontal>
|
||||
<vn-none class="primaryCheckbox" ng-if="$ctrl.checkAll===0">
|
||||
<vn-icon vn-none icon="check_box_outline_blank" ng-click="$ctrl.checkAll = 1"></vn-icon>
|
||||
</vn-none>
|
||||
<vn-none class="primaryCheckbox color" ng-if="$ctrl.checkAll===1">
|
||||
<vn-icon vn-none icon="check_box" ng-click="$ctrl.checkAll = 0"></vn-icon>
|
||||
<vn-icon vn-none icon="check_box" ng-click="$ctrl.checkAll = 0"></vn-icon>
|
||||
</vn-none>
|
||||
<vn-none class="primaryCheckbox color" ng-if="$ctrl.checkAll===2">
|
||||
<vn-icon vn-none icon="indeterminate_check_box" ng-click="$ctrl.checkAll = 0"></vn-icon>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
vn-multi-check {
|
||||
.multi-check {
|
||||
vn-icon{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<vn-one vn-horizontal>
|
||||
<vn-one></vn-one>
|
||||
<vn-autocomplete vn-two
|
||||
initial-value="$ctrl.warehouse"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.warehouseFk"
|
||||
|
@ -30,22 +29,7 @@
|
|||
</vn-horizontal>
|
||||
<vn-horizontal vn-one margin-large-bottom>
|
||||
<vn-one>
|
||||
<vn-horizontal class="actionPanel">
|
||||
<vn-button vn-none margin-medium-right label="Printed" ng-click="$ctrl.doAction('markPrinted')"></vn-button>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="assignment" items="$ctrl.states" selected="$ctrl.actions.state"></vn-icon-menu>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="person" items="[{id:1,name:'trabajador 01'},{id:2,name:'trabajador 02'},{id:3,name:'trabajador 03'}]"
|
||||
selected="$ctrl.actions.worker"></vn-icon-menu>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="query_builder" items="$ctrl.hourItems" selected="$ctrl.actions.hours"></vn-icon-menu>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-production-actions tickets="$ctrl.tickets" states="$ctrl.states"></vn-production-actions>
|
||||
</vn-one>
|
||||
<vn-two></vn-two>
|
||||
</vn-horizontal>
|
||||
|
|
|
@ -2,103 +2,23 @@ import ngModule from '../module';
|
|||
import './style.scss';
|
||||
|
||||
export default class ProductionIndex {
|
||||
constructor($element, $scope, $http, vnPopover, vnApp, $translate) {
|
||||
constructor($element, $scope, $http, vnPopover) {
|
||||
this.$element = $element;
|
||||
this.$ = $scope;
|
||||
this.$http = $http;
|
||||
this.vnPopover = vnPopover;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.filter = {};
|
||||
this.tickets = [];
|
||||
this.states = [];
|
||||
this.ticketsSelected = [];
|
||||
this.actions = {
|
||||
state: null,
|
||||
worker: null,
|
||||
hours: null
|
||||
};
|
||||
this.footer = {
|
||||
total: null,
|
||||
lines: null,
|
||||
meters: null
|
||||
};
|
||||
|
||||
this.hourItems = [];
|
||||
this.child = undefined;
|
||||
this.warehouse = {
|
||||
id: 1,
|
||||
name: "Silla FV"
|
||||
};
|
||||
}
|
||||
|
||||
// Actions Callbacks
|
||||
_changeState(ids, sateteId, stateName, index) {
|
||||
this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then(
|
||||
() => {
|
||||
index.forEach(
|
||||
val => {
|
||||
this.tickets[val].state = stateName;
|
||||
this.tickets[val].stateFk = sateteId;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
_sendMessage(tickets) {
|
||||
this.$http.post(`/production/api/TicketStates/messageSend`, {tickets: tickets}).then(
|
||||
() => {
|
||||
this.vnApp.showMessage(this.$translate.instant('Success: message send!'));
|
||||
}
|
||||
);
|
||||
}
|
||||
_changeTime(ids, time, index) {
|
||||
this.$http.put(`/production/api/changeTime?time=${time}`, {tickets: ids}).then(
|
||||
() => {
|
||||
index.forEach(
|
||||
val => {
|
||||
this.tickets[val].hour = time;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// End Actions Callbacks
|
||||
doAction(action) {
|
||||
let ids = [];
|
||||
let index = [];
|
||||
let tickets = [];
|
||||
this.tickets.forEach(
|
||||
(val, i) => {
|
||||
if (val.checked) {
|
||||
ids.push(val.ticketFk);
|
||||
index.push(i);
|
||||
tickets.push({ticketFk: val.ticketFk, salesPersonFk: val.salesPersonFk});
|
||||
}
|
||||
}
|
||||
);
|
||||
if (tickets.length) {
|
||||
switch (action) {
|
||||
case 'changeState' :
|
||||
this._changeState(ids, this.actions.state.id, this.actions.state.name, index);
|
||||
break;
|
||||
case 'addComment':
|
||||
this._sendMessage(tickets);
|
||||
break;
|
||||
case 'markPrinted':
|
||||
this._changeState(ids, 4, 'Impreso', index);
|
||||
break;
|
||||
case 'changeTime':
|
||||
this._changeTime(ids, this.actions.hours.name, index);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!'));
|
||||
}
|
||||
}
|
||||
|
||||
// Start modals and actions modals
|
||||
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;
|
||||
|
@ -117,19 +37,13 @@ export default class ProductionIndex {
|
|||
angular.element(this.child).remove();
|
||||
delete this.child;
|
||||
}
|
||||
// END modals and actions modals
|
||||
searchTickets(filter) {
|
||||
if (filter) {
|
||||
this.filter = Object.assign({}, this.filter, filter);
|
||||
}
|
||||
|
||||
let filters = Object.assign({}, {
|
||||
where: this.filter
|
||||
where: Object.assign({}, filter, this.filter)
|
||||
}, {
|
||||
page: 1,
|
||||
limit: 700
|
||||
});
|
||||
|
||||
this.$http.get('/production/api/FakeProductions/list?filter=' + JSON.stringify(filters)).then(
|
||||
json => {
|
||||
this.tickets = json.data.tickets;
|
||||
|
@ -139,16 +53,6 @@ export default class ProductionIndex {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
$doCheck() {
|
||||
if (this.actions.state) {
|
||||
this.doAction('changeState');
|
||||
this.actions.state = null;
|
||||
} else if (this.actions.hours) {
|
||||
this.doAction('changeTime');
|
||||
this.actions.hours = null;
|
||||
}
|
||||
}
|
||||
$onInit() {
|
||||
for (let i = 6; i < 21; i++) {
|
||||
let hour = [i].join('');
|
||||
|
@ -161,7 +65,7 @@ export default class ProductionIndex {
|
|||
this.searchTickets();
|
||||
}
|
||||
}
|
||||
ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'vnApp', '$translate'];
|
||||
ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover'];
|
||||
|
||||
ngModule.component('vnProductionIndex', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<vn-horizontal class="actionPanel">
|
||||
<vn-button vn-none margin-medium-right label="Printed" ng-click="$ctrl.doAction('markPrinted')"></vn-button>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="assignment" items="$ctrl.states" selected="$ctrl.actionState"></vn-icon-menu>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="person" items="[{id:1,name:'trabajador 01'},{id:2,name:'trabajador 02'},{id:3,name:'trabajador 03'}]"
|
||||
selected="$ctrl.actionWorker"></vn-icon-menu>
|
||||
</vn-none>
|
||||
<vn-none margin-medium-right>
|
||||
<vn-icon-menu icon="query_builder" items="$ctrl.hourItems" selected="$ctrl.actionHours"></vn-icon-menu>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
|
@ -0,0 +1,113 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
export default class ProductionActions {
|
||||
constructor($http, $translate) {
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
|
||||
this._actionState = null;
|
||||
this._actionWorker = null;
|
||||
this._actionHours = null;
|
||||
}
|
||||
|
||||
set actionState(value) {
|
||||
this._actionState = value;
|
||||
this.doAction('changeState');
|
||||
}
|
||||
get actionState() {
|
||||
return this._actionState;
|
||||
}
|
||||
|
||||
set actionHours(value) {
|
||||
this._actionHours = value;
|
||||
this.doAction('changeTime');
|
||||
}
|
||||
get actionHours() {
|
||||
return this._actionHours;
|
||||
}
|
||||
|
||||
set actionWorker(value) {
|
||||
this._actionWorker = value;
|
||||
this.doAction('changeWorker');
|
||||
}
|
||||
get actionWorker() {
|
||||
return this._actionWorker;
|
||||
}
|
||||
|
||||
_changeState(ids, sateteId, stateName, index) {
|
||||
this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then(
|
||||
() => {
|
||||
index.forEach(
|
||||
val => {
|
||||
this.tickets[val].state = stateName;
|
||||
this.tickets[val].stateFk = sateteId;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
_sendMessage(tickets) {
|
||||
this.$http.post(`/production/api/TicketStates/messageSend`, {tickets: tickets}).then(
|
||||
() => {
|
||||
this.vnApp.showMessage(this.$translate.instant('Success: message send!'));
|
||||
}
|
||||
);
|
||||
}
|
||||
_changeTime(ids, time, index) {
|
||||
this.$http.put(`/production/api/changeTime?time=${time}`, {tickets: ids}).then(
|
||||
() => {
|
||||
index.forEach(
|
||||
val => {
|
||||
this.tickets[val].hour = time;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
doAction(actionName) {
|
||||
let ids = [];
|
||||
let index = [];
|
||||
let tickets = [];
|
||||
this.tickets.forEach(
|
||||
(val, i) => {
|
||||
if (val.checked) {
|
||||
ids.push(val.ticketFk);
|
||||
index.push(i);
|
||||
tickets.push({ticketFk: val.ticketFk, salesPersonFk: val.salesPersonFk});
|
||||
}
|
||||
}
|
||||
);
|
||||
if (tickets.length) {
|
||||
switch (actionName) {
|
||||
case 'changeState' :
|
||||
this._changeState(ids, this.actionState.id, this.actionState.name, index);
|
||||
break;
|
||||
case 'addComment':
|
||||
this._sendMessage(tickets);
|
||||
break;
|
||||
case 'markPrinted':
|
||||
this._changeState(ids, 4, 'Impreso', index);
|
||||
break;
|
||||
case 'changeTime':
|
||||
this._changeTime(ids, this.actionHours.name, index);
|
||||
break;
|
||||
default:
|
||||
this.vnApp.showMessage(this.$translate.instant('Error: No jet implemented!'));
|
||||
}
|
||||
} else {
|
||||
this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProductionActions.$inject = ['$http', '$translate'];
|
||||
|
||||
ngModule.component('vnProductionActions', {
|
||||
template: require('./production-actions.html'),
|
||||
bindings: {
|
||||
tickets: '<',
|
||||
states: '<'
|
||||
},
|
||||
controller: ProductionActions
|
||||
});
|
|
@ -4,7 +4,7 @@ export class ProductionTable {
|
|||
constructor($filter) {
|
||||
this.$filter = $filter;
|
||||
this._tickets = [];
|
||||
this.itemsDisplayedInList = 10;
|
||||
this.itemsDisplayedInList = 14;
|
||||
this.pageTable = {
|
||||
filter: {
|
||||
page: 1,
|
||||
|
|
|
@ -4,5 +4,5 @@ export * from './module';
|
|||
// import components
|
||||
import './index/index';
|
||||
import './production-filters/production-filters';
|
||||
// import './production-comment/production-comment';
|
||||
import './production-actions/production-actions';
|
||||
import './production-table/production-table';
|
||||
|
|
|
@ -94,4 +94,4 @@ html [vn-center], .vn-center{
|
|||
}
|
||||
.flatpickr-month, .flatpickr-weekdays, span.flatpickr-weekday {
|
||||
background-color: $color-orange;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue