58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
let isDirty = false;
|
|
this.$.$watch('$ctrl.selection', newValue => {
|
|
if (newValue) {
|
|
this.$.addressModel.where = {clientFk: newValue.id};
|
|
this.$.addressModel.refresh();
|
|
if (isDirty)
|
|
this.order.addressFk = newValue.defaultAddressFk;
|
|
isDirty = true;
|
|
} else {
|
|
this.$.addressModel.clear();
|
|
if (isDirty)
|
|
this.order.addressFk = null;
|
|
}
|
|
});
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnOrderBasicData', {
|
|
controller: Controller,
|
|
template: require('./index.html'),
|
|
bindings: {
|
|
order: '<'
|
|
}
|
|
});
|