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);
|
|
|
|
}
|
|
|
|
|
2019-11-14 13:19:39 +00:00
|
|
|
get ticket() {
|
|
|
|
return this._ticket;
|
|
|
|
}
|
|
|
|
|
|
|
|
set ticket(value) {
|
|
|
|
this._ticket = value;
|
|
|
|
|
|
|
|
if (value) this.ticket.option = 1;
|
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
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = `tickets/${this.ticket.id}/componentUpdate`;
|
2019-07-26 09:48:01 +00:00
|
|
|
let params = {
|
|
|
|
clientId: this.ticket.clientFk,
|
|
|
|
agencyModeId: this.ticket.agencyModeFk,
|
|
|
|
addressId: this.ticket.addressFk,
|
|
|
|
zoneId: this.ticket.zoneFk,
|
|
|
|
warehouseId: this.ticket.warehouseFk,
|
|
|
|
companyId: 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-16 06:13:39 +00:00
|
|
|
option: this.ticket.option
|
|
|
|
};
|
|
|
|
|
2019-07-26 09:48:01 +00:00
|
|
|
this.$http.post(query, params).then(res => {
|
2019-10-14 12:43:10 +00:00
|
|
|
this.vnApp.showMessage(
|
|
|
|
this.$translate.instant(`The ticket has been unrouted`)
|
|
|
|
);
|
|
|
|
this.card.reload();
|
|
|
|
this.$state.go('ticket.card.summary', {id: this.$state.params.id});
|
2018-05-16 06:13:39 +00:00
|
|
|
});
|
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
|
|
|
}
|
|
|
|
});
|