refactorizacion de production, menos watchers

This commit is contained in:
Daniel Herrero 2017-12-12 14:00:02 +01:00
parent 93c915ec26
commit 5c54550283
6 changed files with 46 additions and 47 deletions

View File

@ -31,7 +31,7 @@
</vn-horizontal> </vn-horizontal>
<vn-horizontal vn-one margin-large-bottom> <vn-horizontal vn-one margin-large-bottom>
<vn-one> <vn-one>
<vn-production-actions tickets="$ctrl.tickets" states="$ctrl.sharedData.states" hour-items="$ctrl.sharedData.hourItems"></vn-production-actions> <vn-production-actions></vn-production-actions>
</vn-one> </vn-one>
<vn-two></vn-two> <vn-two></vn-two>
</vn-horizontal> </vn-horizontal>

View File

@ -22,5 +22,9 @@
"Province" : "Provincia", "Province" : "Provincia",
"Filter" : "Filtrar", "Filter" : "Filtrar",
"Cancel" : "Cancelar", "Cancel" : "Cancelar",
"Worker" : "Trabajador",
"Town" : "Población",
"Client ID" : "ID Cliente",
"Ticket with incidence" : "Ticket con incidencia" "Ticket with incidence" : "Ticket con incidencia"
} }

View File

@ -1,7 +1,7 @@
<vn-horizontal class="actionPanel"> <vn-horizontal class="actionPanel">
<vn-button vn-none margin-medium-right label="Printed" ng-click="$ctrl.doAction('markPrinted')"></vn-button> <vn-button vn-none margin-medium-right label="Printed" ng-click="$ctrl.doAction('markPrinted')"></vn-button>
<vn-none margin-medium-right> <vn-none margin-medium-right>
<vn-icon-menu icon="assignment" items="$ctrl.states" selected="$ctrl.actionState"></vn-icon-menu> <vn-icon-menu icon="assignment" items="$ctrl.parent.sharedData.states" selected="$ctrl.actionState"></vn-icon-menu>
</vn-none> </vn-none>
<vn-none margin-medium-right> <vn-none margin-medium-right>
<vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button> <vn-icon-button icon="textsms" ng-click="$ctrl.doAction('addComment')"></vn-icon-button>
@ -10,6 +10,6 @@
<vn-icon-menu icon="person" url="/client/api/Clients/employeeList" selected="$ctrl.actionWorker"></vn-icon-menu> <vn-icon-menu icon="person" url="/client/api/Clients/employeeList" selected="$ctrl.actionWorker"></vn-icon-menu>
</vn-none> </vn-none>
<vn-none margin-medium-right> <vn-none margin-medium-right>
<vn-icon-menu icon="query_builder" items="$ctrl.hourItems" selected="$ctrl.actionHours"></vn-icon-menu> <vn-icon-menu icon="query_builder" items="$ctrl.parent.sharedData.hourItems" selected="$ctrl.actionHours"></vn-icon-menu>
</vn-none> </vn-none>
</vn-horizontal> </vn-horizontal>

View File

@ -35,45 +35,35 @@ export default class ProductionActions {
return this._actionWorker; return this._actionWorker;
} }
_changeState(ids, sateteId, stateName, index) { _changeState(ids, sateteId) {
this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then( this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids})
.then(
() => { () => {
index.forEach( this.parent.searchTickets();
i => {
this.tickets[i].state = stateName;
this.tickets[i].stateFk = sateteId;
}
);
} }
); );
} }
_sendMessage(tickets) { _sendMessage(tickets) {
this.$http.post(`/production/api/FakeProductions/messageSend`, {tickets: tickets}).then( this.$http.post(`/production/api/FakeProductions/messageSend`, {tickets: tickets})
.then(
() => { () => {
this.vnApp.showMessage(this.$translate.instant('Success: message send!')); this.vnApp.showMessage(this.$translate.instant('Success: message send!'));
} }
); );
} }
_changeTime(ids, time, index) { _changeTime(ids, time, index) {
this.$http.put(`/production/api/Tickets/${time}/changeTime`, {tickets: ids}).then( this.$http.put(`/production/api/Tickets/${time}/changeTime`, {tickets: ids})
.then(
() => { () => {
index.forEach( this.parent.searchTickets();
i => {
this.tickets[i].hour = time;
}
);
} }
); );
} }
_changeWorker(ids, workerFk, index) { _changeWorker(ids, workerFk, index) {
this.$http.put(`/production/api/Tickets/${workerFk}/changeWorker`, {tickets: ids}).then( this.$http.put(`/production/api/Tickets/${workerFk}/changeWorker`, {tickets: ids})
.then(
() => { () => {
index.forEach( this.parent.searchTickets();
i => {
this.tickets[i].workerFk = this.actionWorker.id;
this.tickets[i].worker = this.actionWorker.name;
}
);
} }
); );
} }
@ -82,7 +72,7 @@ export default class ProductionActions {
let ids = []; let ids = [];
let index = []; let index = [];
let tickets = []; let tickets = [];
this.tickets.forEach( this.parent.tickets.forEach(
(val, i) => { (val, i) => {
if (val.checked) { if (val.checked) {
ids.push(val.ticketFk); ids.push(val.ticketFk);
@ -94,13 +84,13 @@ export default class ProductionActions {
if (tickets.length) { if (tickets.length) {
switch (actionName) { switch (actionName) {
case 'changeState' : case 'changeState' :
this._changeState(ids, this.actionState.id, this.actionState.name, index); this._changeState(ids, this.actionState.id);
break; break;
case 'addComment': case 'addComment':
this._sendMessage(tickets); this._sendMessage(tickets);
break; break;
case 'markPrinted': case 'markPrinted':
this._changeState(ids, 4, 'Impreso', index); this._changeState(ids, 4);
break; break;
case 'changeTime': case 'changeTime':
this._changeTime(ids, this.actionHours.name, index); this._changeTime(ids, this.actionHours.name, index);
@ -121,10 +111,8 @@ ProductionActions.$inject = ['$http', '$translate', 'vnApp'];
ngModule.component('vnProductionActions', { ngModule.component('vnProductionActions', {
template: require('./production-actions.html'), template: require('./production-actions.html'),
bindings: { controller: ProductionActions,
tickets: '<', require: {
states: '<', parent: '^^vnProductionIndex'
hourItems: '<' }
},
controller: ProductionActions
}); });

View File

@ -8,6 +8,7 @@
<vn-column-header vn-two pad-medium-h field="agency" text="Agency"></vn-column-header> <vn-column-header vn-two pad-medium-h field="agency" text="Agency"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="routeFk" text="Route ID"></vn-column-header> <vn-column-header vn-one pad-medium-h field="routeFk" text="Route ID"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="salesPerson" text="Commercial"></vn-column-header> <vn-column-header vn-two pad-medium-h field="salesPerson" text="Commercial"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="worker" text="Worker"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="hour" text="Hour"></vn-column-header> <vn-column-header vn-one pad-medium-h field="hour" text="Hour"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="state" text="State"></vn-column-header> <vn-column-header vn-one pad-medium-h field="state" text="State"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="lines" text="Lines"></vn-column-header> <vn-column-header vn-one pad-medium-h field="lines" text="Lines"></vn-column-header>
@ -16,7 +17,7 @@
<vn-none min-none></vn-none> <vn-none min-none></vn-none>
</vn-grid-header> </vn-grid-header>
<vn-one class="list list-content"> <vn-one class="list list-content">
<vn-horizontal vn-one class="list list-element text-center" ng-repeat="ticket in $ctrl.pageTable.model track by ticket.id" ng-class="{warning: ticket.problem==='RIESGO'}"> <vn-horizontal vn-one class="list list-element text-center" ng-repeat="ticket in $ctrl.pageTable.model" ng-class="{warning: ticket.problem==='RIESGO'}">
<vn-none> <vn-none>
<vn-icon margin-small-left icon="report_problem" ng-if="ticket.problem" vn-tooltip="{{ticket.problem}}" tooltip-position="right"></vn-icon> <vn-icon margin-small-left icon="report_problem" ng-if="ticket.problem" vn-tooltip="{{ticket.problem}}" tooltip-position="right"></vn-icon>
</vn-none> </vn-none>
@ -27,8 +28,9 @@
<vn-two pad-medium-h>{{::ticket.agency}}</vn-two> <vn-two pad-medium-h>{{::ticket.agency}}</vn-two>
<vn-one pad-medium-h>{{::ticket.routeFk}}</vn-one> <vn-one pad-medium-h>{{::ticket.routeFk}}</vn-one>
<vn-two pad-medium-h>{{::ticket.salesPerson | ucwords}}</vn-two> <vn-two pad-medium-h>{{::ticket.salesPerson | ucwords}}</vn-two>
<vn-one pad-medium-h>{{ticket.hour}}</vn-one> <vn-two pad-medium-h>{{::ticket.worker | ucwords}}</vn-two>
<vn-one pad-medium-h>{{ticket.state}}</vn-one> <vn-one pad-medium-h>{{::ticket.hour}}</vn-one>
<vn-one pad-medium-h>{{::ticket.state}}</vn-one>
<vn-one pad-medium-h>{{::ticket.lines}}</vn-one> <vn-one pad-medium-h>{{::ticket.lines}}</vn-one>
<vn-one pad-medium-h>{{::ticket.m3}}</vn-one> <vn-one pad-medium-h>{{::ticket.m3}}</vn-one>
<vn-one pad-medium-h>{{::ticket.boxes}}</vn-one> <vn-one pad-medium-h>{{::ticket.boxes}}</vn-one>
@ -44,10 +46,15 @@
<span translate="Resultados"></span>: <span translate="Resultados"></span>:
<span>{{$ctrl.footer.total}}</span> <span>{{$ctrl.footer.total}}</span>
</vn-one> </vn-one>
<vn-seven pad-medium-h></vn-seven> <vn-two pad-medium-h></vn-two>
<vn-one pad-medium-h></vn-one>
<vn-two pad-medium-h></vn-two>
<vn-two pad-medium-h></vn-two>
<vn-one pad-medium-h></vn-one>
<vn-one pad-medium-h></vn-one>
<vn-one pad-medium-h text-center>{{$ctrl.footer.lines}}</vn-one> <vn-one pad-medium-h text-center>{{$ctrl.footer.lines}}</vn-one>
<vn-one pad-medium-h text-center>{{$ctrl.footer.meters}}</vn-one> <vn-one pad-medium-h text-center>{{$ctrl.footer.meters}}</vn-one>
<vn-one></vn-one> <vn-one pad-medium-h></vn-one>
<vn-none></vn-none> <vn-none></vn-none>
</vn-horizontal> </vn-horizontal>
<vn-one> <vn-one>

View File

@ -1,9 +1,9 @@
<vn-vertical> <vn-vertical>
<vn-horizontal class="list list-header"> <vn-horizontal class="list list-header">
<vn-one margin-medium-right>Población</vn-one> <vn-one margin-medium-right translate>Town</vn-one>
<vn-one margin-medium-right>Provincia</vn-one> <vn-one margin-medium-right translate>Province</vn-one>
<vn-two margin-medium-right>ID_Cliente</vn-two> <vn-two margin-medium-right translate>Client ID</vn-two>
<vn-two>Trabajador</vn-two> <vn-two translate>Worker</vn-two>
</vn-horizontal> </vn-horizontal>
<vn-horizontal class="list list-element"> <vn-horizontal class="list list-element">
<vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one> <vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one>