salix/modules/order/front/basic-data/index.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-11-30 10:45:17 +00:00
import ngModule from '../module';
2020-03-17 14:18:02 +00:00
import Section from 'salix/components/section';
2018-11-30 10:45:17 +00:00
import './style.scss';
2020-03-17 14:18:02 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
2019-02-06 13:56:36 +00:00
let isDirty = false;
2020-03-17 14:18:02 +00:00
this.$.$watch('$ctrl.selection', newValue => {
2019-02-06 13:56:36 +00:00
if (newValue) {
2020-03-17 14:18:02 +00:00
this.$.addressModel.where = {clientFk: newValue.id};
this.$.addressModel.refresh();
2019-02-06 13:56:36 +00:00
if (isDirty)
this.order.addressFk = newValue.defaultAddressFk;
2019-02-06 13:56:36 +00:00
isDirty = true;
} else {
2020-03-17 14:18:02 +00:00
this.$.addressModel.clear();
2019-02-06 13:56:36 +00:00
if (isDirty)
this.order.addressFk = null;
2019-02-06 13:56:36 +00:00
}
});
}
set order(value = {}) {
this._order = value;
const agencyModeFk = value.agencyModeFk;
this.getAvailableAgencies();
this._order.agencyModeFk = agencyModeFk;
}
get order() {
return this._order;
}
getAvailableAgencies() {
const order = this.order;
order.agencyModeFk = null;
const params = {
addressFk: order.addressFk,
landed: order.landed
};
if (params.landed && params.addressFk) {
this.$http.get(`Agencies/landsThatDay`, {params})
.then(res => this._availableAgencies = res.data);
}
}
2019-02-06 13:56:36 +00:00
}
ngModule.vnComponent('vnOrderBasicData', {
2019-02-06 13:56:36 +00:00
controller: Controller,
2018-11-30 10:45:17 +00:00
template: require('./index.html'),
bindings: {
order: '<'
}
});