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

67 lines
1.7 KiB
JavaScript
Raw Permalink 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']
}
};
2021-08-15 06:35:14 +00:00
const filter = {
where: {code: 'wireTransfer'}
};
this.$http.get(`payMethods/findOne`, {filter})
.then(res => {
this.wireTransferFk = res.data.id;
});
2021-01-07 14:14:38 +00:00
}
add() {
this.$.model.insert({
supplierFk: this.$params.id
});
}
onAccept(data) {
const accounts = this.supplierAccounts;
const targetAccount = accounts[data.index];
targetAccount.bankEntityFk = data.id;
2021-08-15 06:35:14 +00:00
}
onSubmit() {
this.$.watcher.check();
2021-09-08 07:44:46 +00:00
return this.$.model.save()
2021-08-23 12:47:26 +00:00
.then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
return this.card.reload();
})
.then(() => {
if (this.supplier.payMethodFk != this.wireTransferFk)
this.$.payMethodToTransfer.show();
});
}
setWireTransfer() {
const params = {
id: this.$params.id,
payMethodFk: this.wireTransferFk
};
const query = `Suppliers/${this.$params.id}`;
return this.$http.patch(query, params)
.then(() => this.$.watcher.notifySaved());
}
2021-01-07 14:14:38 +00:00
}
ngModule.vnComponent('vnSupplierAccount', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnSupplierCard'
}
});