salix/modules/supplier/front/account/index.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-07 14:14:38 +00:00
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.include = {
relation: 'bankEntity',
scope: {
fields: ['countryFk', 'id', 'name', 'bic']
}
};
}
add() {
this.$.model.insert({
supplierFk: this.$params.id
});
}
onSubmit() {
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
this.card.reload();
});
}
showBankEntity(event) {
if (event.defaultPrevented) return;
event.preventDefault();
this.$.bankEntity.show();
}
onBankEntityAccept() {
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
return this.$http.patch(query, this.newBankEntity)
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
}
}
ngModule.vnComponent('vnSupplierAccount', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnSupplierCard'
}
});