56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
import ngModule from '../module';
|
|
import Descriptor from 'salix/components/descriptor';
|
|
|
|
class Controller extends Descriptor {
|
|
get entity() {
|
|
return super.entity;
|
|
}
|
|
|
|
set entity(value) {
|
|
super.entity = value;
|
|
|
|
if (value && this.$params.sendSMS)
|
|
this.showSMSDialog();
|
|
}
|
|
|
|
get client() {
|
|
return this.entity;
|
|
}
|
|
|
|
set client(value) {
|
|
this.entity = value;
|
|
}
|
|
|
|
get filter() {
|
|
return JSON.stringify({clientFk: this.id});
|
|
}
|
|
|
|
loadData() {
|
|
return this.getData(`Clients/${this.id}/getCard`)
|
|
.then(res => this.entity = res.data);
|
|
}
|
|
|
|
showSMSDialog() {
|
|
const client = this.client || {};
|
|
this.newSMS = {
|
|
destinationFk: this.id,
|
|
destination: this.$params.phone || client.mobile || client.phone,
|
|
message: this.$params.message || ''
|
|
};
|
|
|
|
const route = `Clients/${this.id}/sendSms`;
|
|
|
|
document.dispatchEvent(new CustomEvent('openSmsDialog', {
|
|
detail: {route}
|
|
}));
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnClientDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
client: '<'
|
|
}
|
|
});
|