salix/modules/order/front/index/index.js

88 lines
2.3 KiB
JavaScript

import ngModule from '../module';
export default class Controller {
constructor($scope) {
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
relation: 'client',
scope: {
fields: ['name', 'salesPersonFk'],
include: {
relation: 'salesPerson',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
}
}
},
{
relation: 'company',
fields: ['code']
}
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {id: value};
case 'from':
return {landed: {gte: value}};
case 'to':
return {landed: {lte: value}};
case 'id':
case 'clientFk':
case 'workerFk':
case 'sourceApp':
case 'agencyModeFk':
case 'isConfirmed':
return {[param]: value};
}
}
showClientDescriptor(event, clientFk) {
this.$.clientDescriptor.clientFk = clientFk;
this.$.clientDescriptor.parent = event.target;
this.$.clientDescriptor.show();
event.preventDefault();
event.stopImmediatePropagation();
}
showWorkerDescriptor(event, userId) {
event.preventDefault();
event.stopImmediatePropagation();
this.selectedWorker = userId;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
onDescriptorLoad() {
this.$.popover.relocate();
}
preview(event, order) {
event.preventDefault();
event.stopImmediatePropagation();
this.selectedOrder = order;
this.$.summary.show();
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnOrderIndex', {
template: require('./index.html'),
controller: Controller
});