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

72 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-03-27 12:26:20 +00:00
import ngModule from '../../module';
2020-03-18 07:35:59 +00:00
import Section from 'salix/components/section';
2018-03-27 12:26:20 +00:00
2020-03-18 07:35:59 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
2018-03-27 12:26:20 +00:00
this.ticket = {
2020-03-18 07:35:59 +00:00
ticketFk: this.$params.id
2018-03-27 12:26:20 +00:00
};
2020-03-18 07:35:59 +00:00
this.params = {ticketFk: this.$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.$t('Data saved!'));
2019-01-22 09:04:42 +00:00
this.$state.go('ticket.card.tracking.index');
});
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
});