2018-07-18 12:38:43 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 14:18:02 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-10-10 10:55:04 +00:00
|
|
|
import './style.scss';
|
2018-07-18 12:38:43 +00:00
|
|
|
|
2020-03-17 14:18:02 +00:00
|
|
|
class Controller extends Section {
|
2018-10-10 10:55:04 +00:00
|
|
|
setSummary() {
|
2020-04-28 12:26:02 +00:00
|
|
|
this.$http.get(`Orders/${this.order.id}/summary`)
|
|
|
|
.then(res => this.summary = res.data);
|
2018-10-10 10:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get formattedAddress() {
|
2020-03-17 14:18:02 +00:00
|
|
|
if (!this.summary) return null;
|
2018-10-10 10:55:04 +00:00
|
|
|
|
|
|
|
let address = this.summary.address;
|
|
|
|
let province = address.province ? `(${address.province.name})` : '';
|
|
|
|
|
|
|
|
return `${address.street} - ${address.city} ${province}`;
|
|
|
|
}
|
|
|
|
|
2018-10-10 12:03:56 +00:00
|
|
|
$onChanges() {
|
|
|
|
if (this.order && this.order.id)
|
|
|
|
this.setSummary();
|
|
|
|
}
|
2020-06-30 06:32:04 +00:00
|
|
|
|
|
|
|
save() {
|
2020-07-09 09:21:06 +00:00
|
|
|
this.$http.post(`Orders/${this.order.id}/confirm`).then(() => {
|
2020-06-30 06:32:04 +00:00
|
|
|
this.vnApp.showSuccess(this.$t('Order confirmed'));
|
|
|
|
this.$state.go(`ticket.index`, {
|
|
|
|
q: JSON.stringify({clientFk: this.order.clientFk})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-07-18 12:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnOrderSummary', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
order: '<'
|
|
|
|
}
|
|
|
|
});
|