118 lines
2.8 KiB
JavaScript
118 lines
2.8 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
get ticket() {
|
|
return this._ticket;
|
|
}
|
|
|
|
set ticket(value) {
|
|
this._ticket = value;
|
|
|
|
if (value) this.getSummary();
|
|
}
|
|
|
|
get formattedAddress() {
|
|
if (!this.summary) return '';
|
|
|
|
let address = this.summary.address;
|
|
let province = address.province ? `(${address.province.name})` : '';
|
|
|
|
return `${address.street} - ${address.city} ${province}`;
|
|
}
|
|
|
|
getSummary() {
|
|
this.$http.get(`Tickets/${this.ticket.id}/summary`).then(res => {
|
|
if (res && res.data)
|
|
this.summary = res.data;
|
|
});
|
|
}
|
|
|
|
showRouteDescriptor(event) {
|
|
this.routeQuicklinks = {
|
|
btnThree: {
|
|
icon: 'icon-delivery',
|
|
state: `route.card.summary({
|
|
id: ${this.summary.routeFk},
|
|
})`,
|
|
tooltip: 'Route summary'
|
|
}
|
|
};
|
|
this.$.routeDescriptor.routeFk = this.summary.routeFk;
|
|
this.$.routeDescriptor.parent = event.target;
|
|
this.$.routeDescriptor.show();
|
|
}
|
|
|
|
showDescriptor(event, itemFk) {
|
|
this.quicklinks = {
|
|
btnThree: {
|
|
icon: 'icon-transaction',
|
|
state: `item.card.diary({
|
|
id: ${itemFk},
|
|
warehouseFk: ${this.ticket.warehouseFk},
|
|
ticketFk: ${this.ticket.id}
|
|
})`,
|
|
tooltip: 'Item diary'
|
|
}
|
|
};
|
|
this.$.descriptor.itemFk = itemFk;
|
|
this.$.descriptor.parent = event.target;
|
|
this.$.descriptor.show();
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
this.$.popover.relocate();
|
|
}
|
|
|
|
get isEditable() {
|
|
try {
|
|
return !this.ticket.state.state.alertLevel;
|
|
} catch (e) {}
|
|
|
|
return true;
|
|
}
|
|
|
|
setOkState() {
|
|
let params = {};
|
|
|
|
if (this.$params.id)
|
|
params = {ticketFk: this.$params.id};
|
|
|
|
if (!this.$params.id)
|
|
params = {ticketFk: this.ticket.id};
|
|
|
|
params.code = 'OK';
|
|
|
|
this.$http.post(`TicketTrackings/changeState`, params).then(() => {
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
|
if (this.card)
|
|
this.card.reload();
|
|
else
|
|
this.getSummary();
|
|
});
|
|
}
|
|
|
|
getRequestState(state) {
|
|
switch (state) {
|
|
case null:
|
|
return 'New';
|
|
case false:
|
|
return 'Denied';
|
|
case true:
|
|
return 'Acepted';
|
|
}
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnTicketSummary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
ticket: '<'
|
|
},
|
|
require: {
|
|
card: '?^vnTicketCard'
|
|
}
|
|
});
|