2022-10-05 13:13:48 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
export default class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
|
|
|
|
this.smartTableOptions = {
|
|
|
|
activeButtons: {
|
|
|
|
search: true
|
|
|
|
},
|
|
|
|
columns: [
|
|
|
|
{
|
2022-10-06 07:47:53 +00:00
|
|
|
field: 'parking',
|
2022-10-05 13:13:48 +00:00
|
|
|
autocomplete: {
|
2022-10-06 07:47:53 +00:00
|
|
|
url: 'Parkings',
|
|
|
|
showField: 'code',
|
|
|
|
valueField: 'code'
|
2022-10-05 13:13:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-10-06 07:47:53 +00:00
|
|
|
field: 'shelving',
|
2022-10-05 13:13:48 +00:00
|
|
|
autocomplete: {
|
2022-10-06 07:47:53 +00:00
|
|
|
url: 'Shelvings',
|
|
|
|
showField: 'code',
|
|
|
|
valueField: 'code'
|
2022-10-05 13:13:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-10-06 07:47:53 +00:00
|
|
|
field: 'created',
|
2022-10-05 13:13:48 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-10-06 07:47:53 +00:00
|
|
|
field: 'itemFk',
|
2022-10-05 13:13:48 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-10-06 07:47:53 +00:00
|
|
|
field: 'longName',
|
2022-10-05 13:13:48 +00:00
|
|
|
searchable: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
get checked() {
|
2022-10-06 07:47:53 +00:00
|
|
|
const itemShelvings = this.$.model.data || [];
|
2022-10-05 13:13:48 +00:00
|
|
|
const checkedLines = [];
|
2022-10-06 07:47:53 +00:00
|
|
|
for (let itemShelving of itemShelvings) {
|
|
|
|
if (itemShelving.checked)
|
2022-10-11 06:40:22 +00:00
|
|
|
checkedLines.push(itemShelving.itemShelvingFk);
|
2022-10-05 13:13:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return checkedLines;
|
|
|
|
}
|
|
|
|
|
2022-10-11 06:40:22 +00:00
|
|
|
calculateTotals() {
|
|
|
|
this.labelTotal = 0;
|
2022-10-06 07:47:53 +00:00
|
|
|
const itemShelvings = this.$.model.data || [];
|
2022-10-11 06:40:22 +00:00
|
|
|
itemShelvings.forEach(itemShelving => {
|
|
|
|
const label = itemShelving.stock / itemShelving.packing;
|
|
|
|
this.labelTotal += label;
|
|
|
|
});
|
2022-10-06 07:47:53 +00:00
|
|
|
}
|
|
|
|
|
2022-10-11 06:40:22 +00:00
|
|
|
onRemove() {
|
|
|
|
const params = {itemShelvingIds: this.checked};
|
|
|
|
const query = `ItemShelvings/deleteItemShelvings`;
|
|
|
|
this.$http.post(query, params)
|
|
|
|
.then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$t('ItemShelvings removed'));
|
|
|
|
this.$.model.refresh();
|
2022-10-05 13:13:48 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
2022-10-06 07:47:53 +00:00
|
|
|
case 'parking':
|
|
|
|
case 'shelving':
|
|
|
|
case 'label':
|
|
|
|
case 'packing':
|
|
|
|
return {[param]: value};
|
2022-10-05 13:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnItemShelving', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|