2020-07-20 09:31:47 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
2021-03-16 07:44:05 +00:00
|
|
|
import './style.scss';
|
2020-07-20 09:31:47 +00:00
|
|
|
|
|
|
|
export default class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2020-08-26 14:33:47 +00:00
|
|
|
this.editedColumn;
|
2021-11-11 15:38:41 +00:00
|
|
|
this.$checkAll = false;
|
2021-11-10 16:07:16 +00:00
|
|
|
|
|
|
|
this.smartTableOptions = {
|
|
|
|
activeButtons: {
|
|
|
|
search: true,
|
|
|
|
shownColumns: true,
|
|
|
|
},
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
field: 'code',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemTypes',
|
|
|
|
showField: 'code',
|
|
|
|
valueField: 'code',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'origin',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'Origins',
|
|
|
|
showField: 'code',
|
|
|
|
valueField: 'code'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'family',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemFamilies',
|
|
|
|
valueField: 'code',
|
|
|
|
showField: 'code'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'intrastat',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'Intrastats',
|
|
|
|
showField: 'description',
|
|
|
|
valueField: 'description'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'packageFk',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'Packagings',
|
|
|
|
showField: 'id'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'isActive',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'isIgnored',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
]
|
|
|
|
};
|
2020-07-20 09:31:47 +00:00
|
|
|
}
|
2020-08-26 14:33:47 +00:00
|
|
|
|
|
|
|
get columns() {
|
|
|
|
if (this._columns) return this._columns;
|
|
|
|
|
|
|
|
this._columns = [
|
2020-09-02 11:09:30 +00:00
|
|
|
{field: 'packing', displayName: this.$t('Packing')},
|
|
|
|
{field: 'grouping', displayName: this.$t('Grouping')},
|
|
|
|
{field: 'packageValue', displayName: this.$t('Package value')},
|
|
|
|
{field: 'weight', displayName: this.$t('Weight')},
|
|
|
|
{field: 'description', displayName: this.$t('Description')},
|
|
|
|
{field: 'size', displayName: this.$t('Size')},
|
2021-06-15 10:47:40 +00:00
|
|
|
{field: 'density', displayName: this.$t('Density')},
|
|
|
|
{field: 'packingOut', displayName: this.$t('PackingOut')}
|
2020-08-26 14:33:47 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
return this._columns;
|
|
|
|
}
|
|
|
|
|
2020-07-20 09:31:47 +00:00
|
|
|
get checked() {
|
|
|
|
const buys = this.$.model.data || [];
|
|
|
|
const checkedBuys = [];
|
|
|
|
for (let buy of buys) {
|
2021-11-10 16:07:16 +00:00
|
|
|
if (buy.$checked)
|
2020-07-20 09:31:47 +00:00
|
|
|
checkedBuys.push(buy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return checkedBuys;
|
|
|
|
}
|
|
|
|
|
2021-11-10 16:07:16 +00:00
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'id':
|
|
|
|
case 'size':
|
|
|
|
case 'density':
|
|
|
|
case 'isActive':
|
|
|
|
case 'family':
|
|
|
|
case 'minPrice':
|
|
|
|
case 'packingOut':
|
|
|
|
return {[`i.${param}`]: value};
|
|
|
|
case 'name':
|
|
|
|
case 'description':
|
|
|
|
return {[`i.${param}`]: {like: `%${value}%`}};
|
|
|
|
case 'code':
|
|
|
|
return {'it.code': value};
|
|
|
|
case 'intrastat':
|
|
|
|
return {'intr.description': value};
|
|
|
|
case 'origin':
|
|
|
|
return {'ori.code': value};
|
|
|
|
case 'packing':
|
|
|
|
case 'grouping':
|
|
|
|
case 'quantity':
|
|
|
|
case 'entryFk':
|
|
|
|
case 'buyingValue':
|
|
|
|
case 'freightValue':
|
|
|
|
case 'comissionValue':
|
|
|
|
case 'packageValue':
|
|
|
|
case 'isIgnored':
|
|
|
|
case 'price2':
|
|
|
|
case 'price3':
|
|
|
|
case 'ektFk':
|
|
|
|
case 'weight':
|
|
|
|
case 'packageFk':
|
|
|
|
return {[`b.${param}`]: value};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-26 14:33:47 +00:00
|
|
|
uncheck() {
|
2021-11-11 15:38:41 +00:00
|
|
|
this.checkAll = false;
|
2020-08-26 14:33:47 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 09:31:47 +00:00
|
|
|
get totalChecked() {
|
|
|
|
return this.checked.length;
|
|
|
|
}
|
2020-08-26 14:33:47 +00:00
|
|
|
|
|
|
|
onEditAccept() {
|
2021-06-16 10:29:40 +00:00
|
|
|
const rowsToEdit = [];
|
|
|
|
for (let row of this.checked)
|
|
|
|
rowsToEdit.push({id: row.id, itemFk: row.itemFk});
|
|
|
|
|
2020-08-26 14:33:47 +00:00
|
|
|
let data = {
|
2020-09-02 11:09:30 +00:00
|
|
|
field: this.editedColumn.field,
|
|
|
|
newValue: this.editedColumn.newValue,
|
2021-06-16 10:29:40 +00:00
|
|
|
lines: rowsToEdit
|
2020-08-26 14:33:47 +00:00
|
|
|
};
|
|
|
|
|
2020-09-02 11:09:30 +00:00
|
|
|
return this.$http.post('Buys/editLatestBuys', data)
|
2020-08-26 14:33:47 +00:00
|
|
|
.then(() => {
|
|
|
|
this.uncheck();
|
|
|
|
this.$.model.refresh();
|
|
|
|
});
|
|
|
|
}
|
2020-07-20 09:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnEntryLatestBuys', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|