82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
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
|
|
};
|
|
this.editedColumn;
|
|
}
|
|
|
|
get columns() {
|
|
if (this._columns) return this._columns;
|
|
|
|
this._columns = [
|
|
{field: 'quantity', displayName: 'quantity'},
|
|
{field: 'buyingValue', displayName: 'buyingValue'},
|
|
{field: 'freightValue', displayName: 'freightValue'},
|
|
{field: 'packing', displayName: 'packing'},
|
|
{field: 'grouping', displayName: 'grouping'},
|
|
{field: 'groupingMode', displayName: 'groupingMode'},
|
|
{field: 'comissionValue', displayName: 'comissionValue'},
|
|
{field: 'packageValue', displayName: 'packageValue'},
|
|
{field: 'price2', displayName: 'price2'},
|
|
{field: 'price3', displayName: 'price3'},
|
|
{field: 'minPrice', displayName: 'minPrice'},
|
|
{field: 'weight', displayName: 'weight'},
|
|
{field: 'size', displayName: 'size'},
|
|
{field: 'density', displayName: 'density'},
|
|
{field: 'description', displayName: 'description'}
|
|
];
|
|
|
|
return this._columns;
|
|
}
|
|
|
|
get checked() {
|
|
const buys = this.$.model.data || [];
|
|
const checkedBuys = [];
|
|
for (let buy of buys) {
|
|
if (buy.checked)
|
|
checkedBuys.push(buy);
|
|
}
|
|
|
|
return checkedBuys;
|
|
}
|
|
|
|
uncheck() {
|
|
const lines = this.checked;
|
|
for (let line of lines) {
|
|
if (line.checked)
|
|
line.checked = false;
|
|
}
|
|
}
|
|
|
|
get totalChecked() {
|
|
return this.checked.length;
|
|
}
|
|
|
|
onEditAccept() {
|
|
let data = {
|
|
column: this.editedColumn,
|
|
buys: this.checked
|
|
};
|
|
|
|
this.$http.post('Buys/editLatestBuys', data)
|
|
.then(() => {
|
|
this.$.edit.hide();
|
|
this.uncheck();
|
|
this.$.model.refresh();
|
|
});
|
|
|
|
this.editedColumn = null;
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnEntryLatestBuys', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|