113 lines
3.1 KiB
JavaScript
113 lines
3.1 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
|
|
this.smartTableOptions = {
|
|
activeButtons: {
|
|
search: true,
|
|
shownColumns: true,
|
|
},
|
|
columns: [
|
|
{
|
|
field: 'category',
|
|
autocomplete: {
|
|
url: 'ItemCategories',
|
|
valueField: 'name',
|
|
}
|
|
},
|
|
{
|
|
field: 'origin',
|
|
autocomplete: {
|
|
url: 'Origins',
|
|
showField: 'code',
|
|
valueField: 'code'
|
|
}
|
|
},
|
|
{
|
|
field: 'typeFk',
|
|
autocomplete: {
|
|
url: 'ItemTypes',
|
|
}
|
|
},
|
|
{
|
|
field: 'intrastat',
|
|
autocomplete: {
|
|
url: 'Intrastats',
|
|
showField: 'description',
|
|
valueField: 'description'
|
|
}
|
|
},
|
|
{
|
|
field: 'buyerFk',
|
|
autocomplete: {
|
|
url: 'TicketRequests/getItemTypeWorker',
|
|
searchFunction: '{firstName: $search}',
|
|
showField: 'nickname',
|
|
valueField: 'id',
|
|
}
|
|
},
|
|
{
|
|
field: 'active',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'landed',
|
|
searchable: false
|
|
},
|
|
]
|
|
};
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'category':
|
|
return {'ic.name': value};
|
|
case 'buyerFk':
|
|
return {'it.workerFk': value};
|
|
case 'grouping':
|
|
return {'b.grouping': value};
|
|
case 'packing':
|
|
return {'b.packing': value};
|
|
case 'origin':
|
|
return {'ori.code': value};
|
|
case 'typeFk':
|
|
return {'i.typeFk': value};
|
|
case 'intrastat':
|
|
return {'intr.description': value};
|
|
case 'name':
|
|
return {'i.name': {like: `%${value}%`}};
|
|
case 'producer':
|
|
return {'pr.name': {like: `%${value}%`}};
|
|
case 'id':
|
|
case 'size':
|
|
case 'subname':
|
|
case 'isActive':
|
|
case 'weightByPiece':
|
|
case 'stemMultiplier':
|
|
case 'stems':
|
|
return {[`i.${param}`]: value};
|
|
}
|
|
}
|
|
|
|
onCloneAccept(itemFk) {
|
|
return this.$http.post(`Items/${itemFk}/clone`)
|
|
.then(res => {
|
|
this.$state.go('item.card.tags', {id: res.data.id});
|
|
});
|
|
}
|
|
|
|
preview(item) {
|
|
this.itemSelected = item;
|
|
this.$.preview.show();
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnItemIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|