2018-03-22 17:02:48 +00:00
|
|
|
import ngModule from '../module';
|
2018-04-30 10:48:29 +00:00
|
|
|
import FilterTicketList from '../filter-ticket-list';
|
2018-03-22 17:02:48 +00:00
|
|
|
|
2018-04-30 10:48:29 +00:00
|
|
|
class Controller extends FilterTicketList {
|
2018-05-08 07:25:15 +00:00
|
|
|
constructor($scope, $timeout, $stateParams, $http) {
|
2018-04-30 10:48:29 +00:00
|
|
|
super($scope, $timeout, $stateParams);
|
2018-04-26 14:41:08 +00:00
|
|
|
this.$ = $scope;
|
|
|
|
this.$timeout = $timeout;
|
2018-04-30 10:48:29 +00:00
|
|
|
this.onOrder('itemFk', 'ASC');
|
2018-05-08 07:25:15 +00:00
|
|
|
this.$http = $http;
|
|
|
|
}
|
|
|
|
|
2018-05-08 07:54:14 +00:00
|
|
|
get isChecked() {
|
|
|
|
let data = this.$.index.model.instances;
|
|
|
|
if (data)
|
|
|
|
for (let instance of data)
|
|
|
|
if (instance.checked)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-08 07:25:15 +00:00
|
|
|
onStateOkClick() {
|
|
|
|
let filter = {where: {code: "OK"}, fields: ["id"]};
|
|
|
|
let json = encodeURIComponent(JSON.stringify(filter));
|
|
|
|
this.$http.get(`/ticket/api/States?filter=${json}`).then(res => {
|
|
|
|
this.onStateChange(res.data[0].id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onStateChange(value) {
|
|
|
|
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
|
|
|
this.$http.post(`/ticket/api/TicketTrackings`, params).then(() => {
|
|
|
|
this.card.reload();
|
|
|
|
});
|
2018-04-26 14:41:08 +00:00
|
|
|
}
|
2018-03-26 12:55:10 +00:00
|
|
|
|
2018-05-08 07:54:14 +00:00
|
|
|
onRemoveLinesClick() {
|
|
|
|
let lines = {
|
|
|
|
delete: []
|
|
|
|
};
|
|
|
|
let data = this.$.index.model.instances;
|
|
|
|
if (data)
|
|
|
|
for (let i = 0; i < data.length;) {
|
|
|
|
if (data[i].checked) {
|
|
|
|
lines.delete.push(data[i].id);
|
|
|
|
data.splice(i, 1);
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let query = `/ticket/api/Sales/crudSale`;
|
|
|
|
this.$http.post(query, lines);
|
|
|
|
}
|
|
|
|
|
2018-04-26 14:41:08 +00:00
|
|
|
showDescriptor(event, itemFk) {
|
|
|
|
this.$.descriptor.itemFk = itemFk;
|
|
|
|
this.$.descriptor.parent = event.target;
|
|
|
|
this.$.descriptor.show();
|
|
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
|
|
this.$.popover.relocate();
|
2018-03-26 12:55:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 07:25:15 +00:00
|
|
|
Controller.$inject = ['$scope', '$timeout', '$state', '$http'];
|
2018-03-26 12:55:10 +00:00
|
|
|
|
2018-03-22 17:02:48 +00:00
|
|
|
ngModule.component('vnTicketSale', {
|
|
|
|
template: require('./sale.html'),
|
2018-05-08 07:25:15 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^vnTicketCard'
|
|
|
|
}
|
2018-03-22 17:02:48 +00:00
|
|
|
});
|