2017-12-20 13:36:12 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
class Controller {
|
2018-02-20 13:30:02 +00:00
|
|
|
constructor($http, $state, $timeout) {
|
2017-12-21 13:09:55 +00:00
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
2018-02-20 13:30:02 +00:00
|
|
|
this.$timeout = $timeout;
|
2018-02-20 10:10:54 +00:00
|
|
|
|
2018-02-20 13:30:02 +00:00
|
|
|
this.item = null;
|
2018-03-02 09:51:01 +00:00
|
|
|
this.tags = {};
|
|
|
|
this.itemTags = null;
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-03-02 09:51:01 +00:00
|
|
|
_getItemTags() {
|
|
|
|
let filter = {
|
|
|
|
where: {itemFk: this.$state.params.id},
|
|
|
|
order: "priority ASC",
|
|
|
|
include: {relation: "tag"}
|
|
|
|
};
|
|
|
|
this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(filter)}`).then(response => {
|
|
|
|
this.itemTags = response.data;
|
|
|
|
});
|
2017-12-20 13:36:12 +00:00
|
|
|
}
|
2017-12-21 13:09:55 +00:00
|
|
|
|
2018-03-02 09:51:01 +00:00
|
|
|
_getTags() {
|
|
|
|
this.$http.get(`/item/api/Tags`).then(response => {
|
|
|
|
response.data.forEach(tag => {
|
|
|
|
this.tags[tag.id] = Object.assign({}, tag);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getItem() {
|
2017-12-21 13:09:55 +00:00
|
|
|
let filter = {
|
|
|
|
include: [
|
2018-04-16 11:47:16 +00:00
|
|
|
{relation: "itemType",
|
|
|
|
scope: {
|
2018-07-04 06:50:34 +00:00
|
|
|
fields: ['name', 'workerFk', 'warehouseFk'],
|
2018-04-16 11:47:16 +00:00
|
|
|
include: {
|
|
|
|
relation: 'worker',
|
|
|
|
fields: ['firstName', 'name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-12-21 13:09:55 +00:00
|
|
|
{relation: "origin"},
|
|
|
|
{relation: "ink"},
|
|
|
|
{relation: "producer"},
|
2018-01-30 07:59:43 +00:00
|
|
|
{relation: "intrastat"},
|
2018-03-02 09:51:01 +00:00
|
|
|
{relation: "expence"}
|
2017-12-21 13:09:55 +00:00
|
|
|
]
|
|
|
|
};
|
2018-02-20 10:10:54 +00:00
|
|
|
this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`)
|
2018-03-02 09:51:01 +00:00
|
|
|
.then(res => {
|
|
|
|
if (res.data && res.data.id) {
|
|
|
|
this.$timeout(() => {
|
|
|
|
this.item = res.data;
|
|
|
|
});
|
2018-02-20 10:10:54 +00:00
|
|
|
}
|
2018-03-02 09:51:01 +00:00
|
|
|
}
|
2017-12-21 13:09:55 +00:00
|
|
|
);
|
|
|
|
}
|
2018-03-02 09:51:01 +00:00
|
|
|
|
|
|
|
$onInit() {
|
|
|
|
this._getItem();
|
|
|
|
this._getTags();
|
|
|
|
this._getItemTags();
|
|
|
|
}
|
2017-12-20 13:36:12 +00:00
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
|
|
|
Controller.$inject = ['$http', '$state', '$timeout'];
|
2017-12-20 13:36:12 +00:00
|
|
|
|
|
|
|
ngModule.component('vnItemCard', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2017-12-20 13:36:12 +00:00
|
|
|
});
|