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 = [
|
|
|
|
{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;
|
|
|
|
}
|
|
|
|
|
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 = {
|
|
|
|
column: this.editedColumn,
|
|
|
|
buys: this.checked
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.post('Buys/editLatestBuys', data)
|
|
|
|
.then(() => {
|
|
|
|
this.$.edit.hide();
|
|
|
|
this.uncheck();
|
|
|
|
this.$.model.refresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.editedColumn = null;
|
|
|
|
}
|
2020-07-20 09:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnEntryLatestBuys', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|