salix/modules/ticket/front/tracking/edit/index.js

76 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-03-27 12:26:20 +00:00
import ngModule from '../../module';
2018-04-05 09:09:22 +00:00
class Controller {
2019-01-22 09:04:42 +00:00
constructor($scope, $state, vnApp, $translate, $http) {
this.$http = $http;
2018-03-27 12:26:20 +00:00
this.$ = $scope;
this.$state = $state;
2018-04-05 09:09:22 +00:00
this.vnApp = vnApp;
this.$translate = $translate;
2018-03-27 12:26:20 +00:00
this.ticket = {
ticketFk: $state.params.id
2018-03-27 12:26:20 +00:00
};
2019-01-22 09:04:42 +00:00
this.params = {ticketFk: $state.params.id};
2018-03-27 12:26:20 +00:00
}
2019-01-22 09:04:42 +00:00
$onInit() {
this.getPickerDesignedState();
}
set stateFk(value) {
this.params.stateFk = value;
this.isPickerDesignedState = this.getIsPickerDesignedState(value);
2019-08-19 05:56:20 +00:00
this.workerFk = window.localStorage.currentUserWorkerId;
2019-01-22 09:04:42 +00:00
}
get stateFk() {
return this.params.stateFk;
}
set workerFk(value) {
this.params.workerFk = value;
}
get workerFk() {
return this.params.workerFk;
}
getPickerDesignedState() {
let filter = {
where: {
code: 'PICKER_DESIGNED'
2018-03-27 12:26:20 +00:00
}
2019-01-22 09:04:42 +00:00
};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`States?filter=${json}`).then(res => {
2019-01-22 09:04:42 +00:00
if (res && res.data)
this.pickerDesignedState = res.data[0].id;
});
}
getIsPickerDesignedState(value) {
if (value == this.pickerDesignedState)
return true;
return false;
}
onSubmit() {
this.$http.post(`TicketTrackings/changeState`, this.params).then(() => {
2019-01-22 09:04:42 +00:00
this.$.watcher.updateOriginalData();
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.$state.go('ticket.card.tracking.index');
});
2018-03-27 12:26:20 +00:00
}
}
2019-01-22 09:04:42 +00:00
Controller.$inject = ['$scope', '$state', 'vnApp', '$translate', '$http'];
2018-03-27 12:26:20 +00:00
ngModule.component('vnTicketTrackingEdit', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnTicketCard'
}
2018-03-27 12:26:20 +00:00
});