salix/modules/ticket/front/basic-data/step-three/index.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

import ngModule from '../../module';
class Controller {
constructor($http, $scope, $state, $translate, vnApp) {
this.$http = $http;
this.$scope = $scope;
this.$state = $state;
this.$translate = $translate;
this.vnApp = vnApp;
}
$onInit() {
this.data.registerChild(this);
}
$onChanges() {
this.ticket.option = 1;
this.ticket.hasToBeUnrouted = true;
}
onStepChange(state) {
return true;
}
onSubmit() {
if (!this.ticket.option) {
return this.vnApp.showError(
this.$translate.instant('Choose an option')
);
}
let query = `/ticket/api/tickets/${this.ticket.id}/componentUpdate`;
let data = {
clientFk: this.ticket.clientFk,
agencyModeFk: this.ticket.agencyModeFk,
addressFk: this.ticket.addressFk,
warehouseFk: this.ticket.warehouseFk,
companyFk: this.ticket.companyFk,
shipped: this.ticket.shipped,
landed: this.ticket.landed,
isDeleted: this.ticket.isDeleted,
hasToBeUnrouted: this.ticket.hasToBeUnrouted,
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();
}
});
}
}
Controller.$inject = ['$http', '$scope', '$state', '$translate', 'vnApp'];
ngModule.component('vnTicketBasicDataStepThree', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
},
require: {
card: '^vnTicketCard',
data: '^vnTicketBasicData'
}
});