2018-04-18 07:47:05 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
|
|
|
|
class Controller {
|
2018-05-16 06:13:39 +00:00
|
|
|
constructor($http, $scope, $state, $translate, vnApp) {
|
|
|
|
this.$http = $http;
|
2018-04-18 07:47:05 +00:00
|
|
|
this.$scope = $scope;
|
2018-05-16 06:13:39 +00:00
|
|
|
this.$state = $state;
|
|
|
|
this.$translate = $translate;
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
$onInit() {
|
|
|
|
this.data.registerChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
$onChanges() {
|
|
|
|
this.ticket.option = 1;
|
2018-05-30 08:55:54 +00:00
|
|
|
this.ticket.hasToBeUnrouted = true;
|
2018-05-16 06:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onStepChange(state) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit() {
|
2019-04-01 07:01:11 +00:00
|
|
|
if (!this.ticket.option) {
|
2018-05-16 06:13:39 +00:00
|
|
|
return this.vnApp.showError(
|
|
|
|
this.$translate.instant('Choose an option')
|
|
|
|
);
|
2019-04-01 07:01:11 +00:00
|
|
|
}
|
2018-05-16 06:13:39 +00:00
|
|
|
|
|
|
|
let query = `/ticket/api/tickets/${this.ticket.id}/componentUpdate`;
|
|
|
|
let data = {
|
2018-05-30 08:55:54 +00:00
|
|
|
clientFk: this.ticket.clientFk,
|
2018-05-16 06:13:39 +00:00
|
|
|
agencyModeFk: this.ticket.agencyModeFk,
|
|
|
|
addressFk: this.ticket.addressFk,
|
|
|
|
warehouseFk: this.ticket.warehouseFk,
|
2019-04-01 07:01:11 +00:00
|
|
|
companyFk: this.ticket.companyFk,
|
2018-05-16 06:13:39 +00:00
|
|
|
shipped: this.ticket.shipped,
|
|
|
|
landed: this.ticket.landed,
|
2018-05-25 09:40:04 +00:00
|
|
|
isDeleted: this.ticket.isDeleted,
|
2018-05-30 08:55:54 +00:00
|
|
|
hasToBeUnrouted: this.ticket.hasToBeUnrouted,
|
2018-05-16 06:13:39 +00:00
|
|
|
option: this.ticket.option
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.post(query, data).then(res => {
|
|
|
|
if (res.data) {
|
|
|
|
this.$state.go('ticket.card.summary', {id: this.$state.params.id});
|
|
|
|
this.card.reload();
|
|
|
|
}
|
|
|
|
});
|
2018-04-18 07:47:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-16 06:13:39 +00:00
|
|
|
Controller.$inject = ['$http', '$scope', '$state', '$translate', 'vnApp'];
|
|
|
|
|
2019-04-16 13:00:21 +00:00
|
|
|
ngModule.component('vnTicketBasicDataStepThree', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-04-18 07:47:05 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
2018-05-16 06:13:39 +00:00
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^vnTicketCard',
|
2019-04-16 13:00:21 +00:00
|
|
|
data: '^vnTicketBasicData'
|
2018-04-18 07:47:05 +00:00
|
|
|
}
|
|
|
|
});
|