salix/modules/entry/front/latest-buys/index.js

79 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-07-20 09:31:47 +00:00
import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.showFields = {
id: false,
actions: false
};
2020-08-26 14:33:47 +00:00
this.editedColumn;
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: 'quantity', displayName: this.$t('Quantity')},
{field: 'buyingValue', displayName: this.$t('Buying value')},
{field: 'freightValue', displayName: this.$t('Freight value')},
{field: 'packing', displayName: this.$t('Packing')},
{field: 'grouping', displayName: this.$t('Grouping')},
{field: 'comissionValue', displayName: this.$t('Commission value')},
{field: 'packageValue', displayName: this.$t('Package value')},
{field: 'price2', displayName: this.$t('Grouping price')},
{field: 'price3', displayName: this.$t('Packing price')},
{field: 'weight', displayName: this.$t('Weight')},
{field: 'description', displayName: this.$t('Description')},
{field: 'minPrice', displayName: this.$t('Min price')},
{field: 'size', displayName: this.$t('Size')},
{field: 'density', displayName: this.$t('Density')}
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) {
if (buy.checked)
checkedBuys.push(buy);
}
return checkedBuys;
}
2020-08-26 14:33:47 +00:00
uncheck() {
const lines = this.checked;
for (let line of lines) {
if (line.checked)
line.checked = false;
}
}
2020-07-20 09:31:47 +00:00
get totalChecked() {
return this.checked.length;
}
2020-08-26 14:33:47 +00:00
onEditAccept() {
let data = {
2020-09-02 11:09:30 +00:00
field: this.editedColumn.field,
newValue: this.editedColumn.newValue,
lines: this.checked
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
});