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)
|
2019-02-15 12:26:49 +00:00
|
|
|
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)
|
2019-02-15 12:26:49 +00:00
|
|
|
this.order.addressFk = null;
|
2019-02-06 13:56:36 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-08-31 11:02:14 +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
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +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: '<'
|
|
|
|
}
|
|
|
|
});
|