salix/modules/client/front/descriptor/index.js

62 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2017-06-03 11:01:47 +00:00
import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2019-11-21 13:00:27 +00:00
2020-04-25 09:50:04 +00:00
class Controller extends Descriptor {
get entity() {
return super.entity;
}
set entity(value) {
super.entity = value;
2020-06-18 10:59:37 +00:00
if (value && this.$params.sendSMS)
this.showSMSDialog();
2018-08-02 08:06:11 +00:00
}
2019-10-21 12:21:52 +00:00
get client() {
return this.entity;
2019-10-21 12:21:52 +00:00
}
2018-08-02 08:06:11 +00:00
set client(value) {
this.entity = value;
}
2020-04-25 09:50:04 +00:00
get filter() {
return JSON.stringify({clientFk: this.id});
}
loadData() {
return this.getData(`Clients/${this.id}/getCard`)
.then(res => this.entity = res.data);
2019-01-07 07:49:01 +00:00
}
2019-11-21 13:00:27 +00:00
showSMSDialog() {
2020-04-25 09:50:04 +00:00
const client = this.client || {};
2019-11-21 13:00:27 +00:00
this.newSMS = {
destinationFk: this.id,
2020-04-25 09:50:04 +00:00
destination: this.$params.phone || client.mobile || client.phone,
message: this.$params.message || ''
2019-11-21 13:00:27 +00:00
};
2022-11-25 08:59:02 +00:00
this.$.sms.open();
}
2022-11-21 07:45:45 +00:00
2022-11-25 08:59:02 +00:00
onSmsSend(sms) {
return this.$http.post(`Clients/${this.id}/sendSms`, sms)
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
2019-11-21 13:00:27 +00:00
}
2023-02-13 12:04:22 +00:00
clientUnpaid() {
return this.$t(`Unpaid`) + '<br/>'
+ this.$t(`Unpaid Dated`, {dated: this.client.unpaid.dated}) + '<br/>'
+ this.$t(`Unpaid Amount`, {amount: this.client.unpaid.amount});
2023-02-13 12:04:22 +00:00
}
}
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnClientDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
2020-04-25 09:50:04 +00:00
client: '<'
}
2017-06-03 11:01:47 +00:00
});