change time
This commit is contained in:
parent
7b38d2f188
commit
ddcec00c4f
|
@ -58,7 +58,7 @@ export default class ProductionIndex {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_changeTime(ids, time, index) {
|
_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(
|
index.forEach(
|
||||||
val => {
|
val => {
|
||||||
|
|
|
@ -1,36 +1,44 @@
|
||||||
module.exports = function(Ticket) {
|
module.exports = function(Ticket) {
|
||||||
Ticket.remoteMethodCtx('changeTime', {
|
Ticket.remoteMethodCtx('changeTime', {
|
||||||
description: 'List tickets for production',
|
description: 'Change time of tickets',
|
||||||
accepts: {
|
accepts: [{
|
||||||
arg: 'time',
|
arg: 'time',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'New time of ticket',
|
description: 'New time of tickets',
|
||||||
http: {source: 'path'}
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
arg: 'response',
|
||||||
|
type: 'boolean'
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
verb: 'get',
|
verb: 'put',
|
||||||
path: '/changeTime'
|
path: '/:time/changeTime'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ticket.changeTime = function(ctx, time, cb) {
|
Ticket.changeTime = function(ctx, time, cb) {
|
||||||
var tickets = ctx.req.body.tickets;
|
var tickets = ctx.req.body.tickets;
|
||||||
|
changeTime(tickets, time, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
var changeTime = function(tickets, time, cb){
|
var changeTime = function(tickets, time, cb){
|
||||||
|
|
||||||
var FakeProduction = Ticket.app.models.FakeProduction;
|
var FakeProduction = Ticket.app.models.FakeProduction;
|
||||||
|
var hour = `${time}:00`;
|
||||||
|
|
||||||
time = `CONCAT(DATE(Fecha), ' ${time}')`;
|
var query = `update Ticket set date = CONCAT(DATE(date), ' ', ?) where id in (?)`;
|
||||||
|
var params = [time, tickets];
|
||||||
|
|
||||||
Ticket.updateAll({id: {inq: tickets}}, {date: time}, function(err, res){
|
FakeProduction.updateAll({ticketFk: {inq: tickets}}, {hour: hour}, function(err, res){
|
||||||
if(err)
|
if(err)
|
||||||
cb(err, null)
|
cb(err, null)
|
||||||
else
|
else{
|
||||||
FakeProduction.updateAll({id: {inq: tickets}}, {date: time}, function(err, res){
|
var response = Ticket.rawSql(query, params, cb);
|
||||||
(err) ? cb(err, null) : cb(null, res)
|
cb(null, response);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,5 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(Agency) {
|
module.exports = function(Agency) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
|
|
||||||
require('../methods/agency/list.js')(Agency);
|
require('../methods/agency/list.js')(Agency);
|
||||||
};
|
};
|
|
@ -1,9 +1,6 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(FakeProduction) {
|
module.exports = function(FakeProduction) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
require('../methods/fake-production/list.js')(FakeProduction);
|
require('../methods/fake-production/list.js')(FakeProduction);
|
||||||
require('../methods/fake-production/message-send.js')(FakeProduction);
|
require('../methods/fake-production/message-send.js')(FakeProduction);
|
||||||
};
|
};
|
|
@ -1,9 +1,5 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(State) {
|
module.exports = function(State) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
|
|
||||||
require('../methods/state/list.js')(State);
|
require('../methods/state/list.js')(State);
|
||||||
};
|
};
|
|
@ -1,8 +1,5 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(TicketState) {
|
module.exports = function(TicketState) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
require('../methods/ticket-state/change-state.js')(TicketState);
|
require('../methods/ticket-state/change-state.js')(TicketState);
|
||||||
};
|
};
|
|
@ -1,8 +1,5 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(Ticket) {
|
module.exports = function(Ticket) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
require('../methods/ticket/change-time.js')(Ticket);
|
require('../methods/ticket/change-time.js')(Ticket);
|
||||||
};
|
};
|
|
@ -1,9 +1,5 @@
|
||||||
var app = require('../../server/server');
|
var app = require('../../server/server');
|
||||||
|
|
||||||
module.exports = function(Warehouse) {
|
module.exports = function(Warehouse) {
|
||||||
var models = app.models;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
|
|
||||||
require('../methods/warehouse/list.js')(Warehouse);
|
require('../methods/warehouse/list.js')(Warehouse);
|
||||||
};
|
};
|
Loading…
Reference in New Issue