salix/modules/client/front/credit-insurance/create/index.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import ngModule from '../../module';
2020-03-17 10:17:50 +00:00
import Section from 'salix/components/section';
2020-03-17 10:17:50 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.creditClassification = {
2020-03-17 10:17:50 +00:00
started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
};
2018-03-28 13:07:48 +00:00
}
2018-08-09 10:54:29 +00:00
onSubmit() {
2020-03-17 10:17:50 +00:00
if (this.$.form.$invalid)
return this.vnApp.showError(this.$t('Some fields are invalid'));
2018-03-28 13:07:48 +00:00
let query = `creditClassifications/createWithInsurance`;
2018-03-28 13:07:48 +00:00
let data = this.creditClassification;
data.clientFk = this.client.id;
2018-07-10 06:23:32 +00:00
this.$http.post(query, data).then(res => {
if (res.data) {
this.card.reload();
2018-05-23 12:26:51 +00:00
this.$state.go('client.card.creditInsurance.index');
2018-07-10 06:23:32 +00:00
}
2018-03-28 13:07:48 +00:00
});
}
}
2020-03-17 10:17:50 +00:00
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnClientCreditInsuranceCreate', {
2018-05-23 12:26:51 +00:00
template: require('./index.html'),
controller: Controller,
2018-07-10 06:23:32 +00:00
require: {
card: '^vnClientCard'
},
bindings: {
client: '<'
}
});