change time

This commit is contained in:
nelo 2017-06-29 09:48:00 +02:00
parent 7b38d2f188
commit ddcec00c4f
8 changed files with 21 additions and 34 deletions

View File

@ -58,7 +58,7 @@ export default class ProductionIndex {
);
}
_changeTime(ids, time, index) {
this.$http.put(`/production/api/changeTime?time=${time}`, {tickets: ids}).then(
this.$http.put(`/production/api/Tickets/${time}/changeTime`, {tickets: ids}).then(
() => {
index.forEach(
val => {

View File

@ -1,36 +1,44 @@
module.exports = function(Ticket) {
Ticket.remoteMethodCtx('changeTime', {
description: 'List tickets for production',
accepts: {
description: 'Change time of tickets',
accepts: [{
arg: 'time',
type: 'string',
required: true,
description: 'New time of ticket',
description: 'New time of tickets',
http: {source: 'path'}
}],
returns: {
arg: 'response',
type: 'boolean'
},
http: {
verb: 'get',
path: '/changeTime'
verb: 'put',
path: '/:time/changeTime'
}
});
Ticket.changeTime = function(ctx, time, cb) {
var tickets = ctx.req.body.tickets;
changeTime(tickets, time, cb);
};
var changeTime = function(tickets, time, cb){
var FakeProduction = Ticket.app.models.FakeProduction;
var hour = `${time}:00`;
time = `CONCAT(DATE(Fecha), ' ${time}')`;
Ticket.updateAll({id: {inq: tickets}}, {date: time}, function(err, res){
var query = `update Ticket set date = CONCAT(DATE(date), ' ', ?) where id in (?)`;
var params = [time, tickets];
FakeProduction.updateAll({ticketFk: {inq: tickets}}, {hour: hour}, function(err, res){
if(err)
cb(err, null)
else
FakeProduction.updateAll({id: {inq: tickets}}, {date: time}, function(err, res){
(err) ? cb(err, null) : cb(null, res)
});
else{
var response = Ticket.rawSql(query, params, cb);
cb(null, response);
}
});
}
}

View File

@ -1,9 +1,5 @@
var app = require('../../server/server');
module.exports = function(Agency) {
var models = app.models;
// Methods
require('../methods/agency/list.js')(Agency);
};

View File

@ -1,9 +1,6 @@
var app = require('../../server/server');
module.exports = function(FakeProduction) {
var models = app.models;
// Methods
require('../methods/fake-production/list.js')(FakeProduction);
require('../methods/fake-production/message-send.js')(FakeProduction);
};

View File

@ -1,9 +1,5 @@
var app = require('../../server/server');
module.exports = function(State) {
var models = app.models;
// Methods
require('../methods/state/list.js')(State);
};

View File

@ -1,8 +1,5 @@
var app = require('../../server/server');
module.exports = function(TicketState) {
var models = app.models;
// Methods
require('../methods/ticket-state/change-state.js')(TicketState);
};

View File

@ -1,8 +1,5 @@
var app = require('../../server/server');
module.exports = function(Ticket) {
var models = app.models;
// Methods
require('../methods/ticket/change-time.js')(Ticket);
};

View File

@ -1,9 +1,5 @@
var app = require('../../server/server');
module.exports = function(Warehouse) {
var models = app.models;
// Methods
require('../methods/warehouse/list.js')(Warehouse);
};