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';
|
2018-03-14 10:36:57 +00:00
|
|
|
|
2020-03-17 10:17:50 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-03-14 10:36:57 +00:00
|
|
|
this.creditClassification = {
|
2020-03-17 10:17:50 +00:00
|
|
|
started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
|
2018-03-14 10:36:57 +00:00
|
|
|
};
|
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)
|
2020-07-23 14:07:08 +00:00
|
|
|
return this.vnApp.showError(this.$t('Some fields are invalid'));
|
2018-03-28 13:07:48 +00:00
|
|
|
|
2019-10-24 22:53:53 +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
|
|
|
});
|
2018-03-14 10:36:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-17 10:17:50 +00:00
|
|
|
Controller.$inject = ['$element', '$scope'];
|
2018-03-14 10:36:57 +00:00
|
|
|
|
2018-05-23 12:26:51 +00:00
|
|
|
ngModule.component('vnClientCreditInsuranceCreate', {
|
|
|
|
template: require('./index.html'),
|
2018-03-14 10:36:57 +00:00
|
|
|
controller: Controller,
|
2018-07-10 06:23:32 +00:00
|
|
|
require: {
|
|
|
|
card: '^vnClientCard'
|
|
|
|
},
|
2018-03-14 10:36:57 +00:00
|
|
|
bindings: {
|
|
|
|
client: '<'
|
|
|
|
}
|
|
|
|
});
|