2017-12-21 13:09:55 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
class Controller extends Section {
|
2020-02-17 06:22:55 +00:00
|
|
|
showIntrastat(event) {
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
event.preventDefault();
|
2017-12-21 13:09:55 +00:00
|
|
|
|
2020-02-17 06:22:55 +00:00
|
|
|
this.newIntrastat = {
|
|
|
|
taxClassFk: this.item.taxClassFk
|
|
|
|
};
|
|
|
|
this.$.intrastat.show();
|
2018-02-20 13:30:02 +00:00
|
|
|
}
|
2018-08-01 07:47:34 +00:00
|
|
|
|
2020-02-17 11:47:03 +00:00
|
|
|
onIntrastatAccept() {
|
|
|
|
const query = `Items/${this.$params.id}/createIntrastat`;
|
|
|
|
return this.$http.patch(query, this.newIntrastat)
|
|
|
|
.then(res => this.item.intrastatFk = res.data.id);
|
2018-02-20 13:30:02 +00:00
|
|
|
}
|
2021-11-24 07:51:07 +00:00
|
|
|
|
|
|
|
itemSearchFunc($search) {
|
|
|
|
return /^\d+$/.test($search)
|
|
|
|
? {id: $search}
|
|
|
|
: {name: {like: '%' + $search + '%'}};
|
|
|
|
}
|
|
|
|
|
|
|
|
showFilterDialog(item) {
|
|
|
|
this.activeItem = item;
|
|
|
|
this.itemFilterParams = {};
|
|
|
|
this.itemFilter = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'producer',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'ink',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$.filterDialog.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
selectItem(id) {
|
2021-11-26 07:34:32 +00:00
|
|
|
this.activeItem['genericFk'] = id;
|
2021-11-24 07:51:07 +00:00
|
|
|
this.$.filterDialog.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
filter() {
|
|
|
|
const filter = this.itemFilter;
|
|
|
|
const params = this.itemFilterParams;
|
|
|
|
const where = {};
|
|
|
|
for (let key in params) {
|
|
|
|
const value = params[key];
|
|
|
|
if (!value) continue;
|
|
|
|
|
|
|
|
switch (key) {
|
|
|
|
case 'name':
|
|
|
|
where[key] = {like: `%${value}%`};
|
|
|
|
break;
|
|
|
|
case 'producerFk':
|
|
|
|
case 'typeFk':
|
|
|
|
case 'size':
|
|
|
|
case 'inkFk':
|
|
|
|
where[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
filter.where = where;
|
|
|
|
|
|
|
|
this.$.itemsModel.applyFilter(filter);
|
|
|
|
}
|
2018-02-20 13:30:02 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnItemBasicData', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2017-12-21 13:09:55 +00:00
|
|
|
bindings: {
|
|
|
|
item: '<'
|
2018-02-20 13:30:02 +00:00
|
|
|
},
|
2018-05-25 08:03:45 +00:00
|
|
|
controller: Controller
|
2017-12-21 13:09:55 +00:00
|
|
|
});
|