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

72 lines
1.8 KiB
JavaScript

import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.ticket = {
ticketFk: this.$params.id
};
this.params = {ticketFk: this.$params.id};
}
$onInit() {
this.getPickerDesignedState();
}
set stateFk(value) {
this.params.stateFk = value;
this.isPickerDesignedState = this.getIsPickerDesignedState(value);
this.workerFk = window.localStorage.currentUserWorkerId;
}
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'
}
};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`States?filter=${json}`).then(res => {
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(() => {
this.$.watcher.updateOriginalData();
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.$state.go('ticket.card.tracking.index');
});
}
}
ngModule.component('vnTicketTrackingEdit', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnTicketCard'
}
});