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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-11 17:35:23 +00:00
|
|
|
onResponse(response) {
|
2021-02-17 11:07:04 +00:00
|
|
|
const data = this.$.model.data;
|
|
|
|
const supplierAccount = data[this.currentRowIndex];
|
|
|
|
supplierAccount.bankEntityFk = response.id;
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
2021-02-17 11:07:04 +00:00
|
|
|
showBankEntity(event, $index) {
|
2021-01-07 14:14:38 +00:00
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
2021-02-17 11:07:04 +00:00
|
|
|
this.currentRowIndex = $index;
|
|
|
|
this.$.bankEntity.open();
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onBankEntityAccept() {
|
|
|
|
const query = `SupplierAccounts/${this.$params.id}/createBankEntity`;
|
|
|
|
return this.$http.patch(query, this.newBankEntity)
|
|
|
|
.then(res => this.supplierAccount.bankEntityFk = res.data.id);
|
|
|
|
}
|
2021-02-11 17:35:23 +00:00
|
|
|
|
|
|
|
onSubmit() {
|
|
|
|
this.$.watcher.check();
|
|
|
|
this.$.model.save().then(() => {
|
|
|
|
this.$.watcher.notifySaved();
|
|
|
|
this.$.watcher.updateOriginalData();
|
|
|
|
this.card.reload();
|
|
|
|
});
|
|
|
|
}
|
2021-01-07 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnSupplierAccount', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
require: {
|
|
|
|
card: '^vnSupplierCard'
|
|
|
|
}
|
|
|
|
});
|