salix/modules/item/front/index/index.js

113 lines
3.1 KiB
JavaScript
Raw Normal View History

2017-12-19 10:05:07 +00:00
import ngModule from '../module';
2020-03-17 13:43:46 +00:00
import Section from 'salix/components/section';
2018-02-22 07:18:57 +00:00
import './style.scss';
2017-12-19 10:05:07 +00:00
2020-03-17 13:43:46 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
2021-11-08 13:46:23 +00:00
this.smartTableOptions = {
activeButtons: {
search: true,
shownColumns: true,
},
columns: [
{
field: 'category',
autocomplete: {
url: 'ItemCategories',
2021-11-08 16:46:40 +00:00
valueField: 'name',
2021-11-08 13:46:23 +00:00
}
},
{
field: 'origin',
autocomplete: {
url: 'Origins',
showField: 'code',
2021-11-08 16:46:40 +00:00
valueField: 'code'
}
},
{
field: 'typeFk',
autocomplete: {
url: 'ItemTypes',
}
},
{
field: 'intrastat',
autocomplete: {
url: 'Intrastats',
showField: 'description',
valueField: 'description'
}
},
{
field: 'buyerFk',
autocomplete: {
url: 'TicketRequests/getItemTypeWorker',
2021-11-08 16:46:40 +00:00
searchFunction: '{firstName: $search}',
showField: 'nickname',
valueField: 'id',
2021-11-08 13:46:23 +00:00
}
},
{
field: 'active',
searchable: false
},
{
field: 'landed',
searchable: false
},
2021-11-08 13:46:23 +00:00
]
2019-02-13 08:27:11 +00:00
};
}
2021-02-22 15:43:40 +00:00
exprBuilder(param, value) {
switch (param) {
case 'category':
return {'ic.name': value};
2021-11-08 16:46:40 +00:00
case 'buyerFk':
2021-02-24 13:49:58 +00:00
return {'it.workerFk': value};
2021-02-22 15:43:40 +00:00
case 'grouping':
return {'b.grouping': value};
case 'packing':
return {'b.packing': value};
case 'origin':
return {'ori.code': value};
2021-02-24 13:49:58 +00:00
case 'typeFk':
2021-02-22 15:43:40 +00:00
return {'i.typeFk': value};
case 'intrastat':
return {'intr.description': value};
case 'name':
return {'i.name': {like: `%${value}%`}};
case 'producer':
return {'pr.name': {like: `%${value}%`}};
2021-02-22 15:43:40 +00:00
case 'id':
case 'size':
case 'subname':
case 'isActive':
2022-08-24 12:13:26 +00:00
case 'weightByPiece':
2021-02-22 15:43:40 +00:00
case 'stemMultiplier':
case 'stems':
return {[`i.${param}`]: value};
}
}
2020-04-25 09:50:04 +00:00
onCloneAccept(itemFk) {
return this.$http.post(`Items/${itemFk}/clone`)
.then(res => {
this.$state.go('item.card.tags', {id: res.data.id});
2020-04-25 09:50:04 +00:00
});
2018-02-22 12:40:23 +00:00
}
2020-04-25 09:50:04 +00:00
preview(item) {
2018-02-22 07:18:57 +00:00
this.itemSelected = item;
this.$.preview.show();
2018-02-22 07:18:57 +00:00
}
2017-12-19 10:05:07 +00:00
}
2020-03-17 13:43:46 +00:00
ngModule.vnComponent('vnItemIndex', {
template: require('./index.html'),
controller: Controller
2017-12-19 10:05:07 +00:00
});