231801_test_to_master #1519
|
@ -31,15 +31,21 @@
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th shrink>
|
||||||
|
<vn-multi-check
|
||||||
|
model="model"
|
||||||
|
checked="$ctrl.checkAll"
|
||||||
|
check-field="checked"
|
||||||
|
check-dummy-enabled="true"
|
||||||
|
checked-dummy-count="$ctrl.checkedDummyCount">
|
||||||
|
</vn-multi-check>
|
||||||
|
</th>
|
||||||
<th field="itemFk">
|
<th field="itemFk">
|
||||||
<span translate>Item ID</span>
|
<span translate>Item ID</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="name">
|
<th field="name">
|
||||||
<span translate>Description</span>
|
<span translate>Description</span>
|
||||||
</th>
|
</th>
|
||||||
<th field="warehouseFk">
|
|
||||||
<span translate>Warehouse</span>
|
|
||||||
</th>
|
|
||||||
<th
|
<th
|
||||||
field="rate2">
|
field="rate2">
|
||||||
<span translate>Grouping price</span>
|
<span translate>Grouping price</span>
|
||||||
|
@ -57,11 +63,21 @@
|
||||||
<th field="ended">
|
<th field="ended">
|
||||||
<span translate>Ended</span>
|
<span translate>Ended</span>
|
||||||
</th>
|
</th>
|
||||||
|
<th field="warehouseFk">
|
||||||
|
<span translate>Warehouse</span>
|
||||||
|
</th>
|
||||||
<th shrink></th>
|
<th shrink></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="price in prices">
|
<tr ng-repeat="price in prices">
|
||||||
|
<td>
|
||||||
|
<vn-check
|
||||||
|
ng-model="price.checked"
|
||||||
|
on-change="$ctrl.saveChecked(price.id)"
|
||||||
|
vn-click-stop>
|
||||||
|
</vn-check>
|
||||||
|
</td>
|
||||||
<td shrink-field>
|
<td shrink-field>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-id="itemFk"
|
vn-id="itemFk"
|
||||||
|
@ -101,18 +117,11 @@
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-fetched-tags>
|
</vn-fetched-tags>
|
||||||
</td>
|
</td>
|
||||||
<td shrink-field-expand>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
ng-model="price.warehouseFk"
|
|
||||||
data="warehouses"
|
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
|
||||||
tabindex="2">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</td>
|
|
||||||
<td shrink-field>
|
<td shrink-field>
|
||||||
<vn-td-editable number>
|
<vn-td-editable number>
|
||||||
<text>{{price.rate2 | currency: 'EUR':2}}</text>
|
<text>
|
||||||
|
<strong>{{price.rate2 | currency: 'EUR':2}}</strong>
|
||||||
|
</text>
|
||||||
<field>
|
<field>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
class="dense"
|
||||||
|
@ -126,7 +135,9 @@
|
||||||
</td>
|
</td>
|
||||||
<td shrink-field>
|
<td shrink-field>
|
||||||
<vn-td-editable number>
|
<vn-td-editable number>
|
||||||
<text>{{price.rate3 | currency: 'EUR':2}}</text>
|
<text>
|
||||||
|
<strong>{{price.rate3 | currency: 'EUR':2}}</strong>
|
||||||
|
</text>
|
||||||
<field>
|
<field>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
class="dense"
|
||||||
|
@ -145,7 +156,7 @@
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
disabled="!price.hasMinPrice"
|
ng-class="{inactive: !price.hasMinPrice}"
|
||||||
ng-model="price.minPrice"
|
ng-model="price.minPrice"
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
step="0.01">
|
step="0.01">
|
||||||
|
@ -169,6 +180,15 @@
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</td>
|
</td>
|
||||||
|
<td expand>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
ng-model="price.warehouseFk"
|
||||||
|
data="warehouses"
|
||||||
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
|
tabindex="2">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</td>
|
||||||
<td shrink>
|
<td shrink>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="delete"
|
icon="delete"
|
||||||
|
@ -191,6 +211,69 @@
|
||||||
</smart-table>
|
</smart-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div fixed-bottom-right>
|
||||||
|
<vn-vertical style="align-items: center;">
|
||||||
|
<vn-button class="round sm vn-mb-sm"
|
||||||
|
icon="edit"
|
||||||
|
ng-show="$ctrl.totalChecked > 0"
|
||||||
|
ng-click="edit.show($event)"
|
||||||
|
vn-tooltip="Edit fixed price(s)"
|
||||||
|
tooltip-position="left">
|
||||||
|
</vn-button>
|
||||||
|
</vn-vertical>
|
||||||
|
</div>
|
||||||
|
<vn-dialog class="edit"
|
||||||
|
vn-id="edit"
|
||||||
|
on-accept="$ctrl.onEditAccept()"
|
||||||
|
on-close="$ctrl.editedColumn = null">
|
||||||
|
<tpl-body style="width: 400px;">
|
||||||
|
<span translate>Edit</span>
|
||||||
|
<span class="countLines">
|
||||||
|
{{::$ctrl.totalChecked}}
|
||||||
|
</span>
|
||||||
|
<span translate>buy(s)</span>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
ng-model="$ctrl.editedColumn.field"
|
||||||
|
data="$ctrl.columns"
|
||||||
|
value-field="field"
|
||||||
|
show-field="displayName"
|
||||||
|
label="Field to edit">
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-input-number
|
||||||
|
vn-one
|
||||||
|
ng-if="$ctrl.editedColumn.field == 'rate2' || $ctrl.editedColumn.field == 'rate3' || $ctrl.editedColumn.field == 'minPrice'"
|
||||||
|
label="Value"
|
||||||
|
ng-model="$ctrl.editedColumn.newValue">
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-check
|
||||||
|
vn-one
|
||||||
|
ng-if="$ctrl.editedColumn.field == 'hasMinPrice'"
|
||||||
|
ng-model="$ctrl.editedColumn.newValue">
|
||||||
|
</vn-check>
|
||||||
|
<vn-date-picker
|
||||||
|
vn-one
|
||||||
|
ng-if="$ctrl.editedColumn.field == 'started' || $ctrl.editedColumn.field == 'ended'"
|
||||||
|
label="Date"
|
||||||
|
ng-model="$ctrl.editedColumn.newValue">
|
||||||
|
</vn-date-picker>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
ng-if="$ctrl.editedColumn.field == 'warehouseFk'"
|
||||||
|
label="Warehouse"
|
||||||
|
ng-model="$ctrl.editedColumn.newValue"
|
||||||
|
data="warehouses">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||||
|
<button response="accept" translate>Save</button>
|
||||||
|
</tpl-buttons>
|
||||||
|
</vn-dialog>
|
||||||
|
|
||||||
<vn-item-descriptor-popover
|
<vn-item-descriptor-popover
|
||||||
vn-id="item-descriptor"
|
vn-id="item-descriptor"
|
||||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||||
|
|
|
@ -5,6 +5,9 @@ import './style.scss';
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
this.editedColumn;
|
||||||
|
this.checkAll = false;
|
||||||
|
this.checkedFixedPrices = [];
|
||||||
|
|
||||||
this.smartTableOptions = {
|
this.smartTableOptions = {
|
||||||
activeButtons: {
|
activeButtons: {
|
||||||
|
@ -30,6 +33,98 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.filterParams = {
|
||||||
|
warehouseFk: this.vnConfig.warehouseFk
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getFilterParams() {
|
||||||
|
return {
|
||||||
|
warehouseFk: this.vnConfig.warehouseFk
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
get columns() {
|
||||||
|
if (this._columns) return this._columns;
|
||||||
|
|
||||||
|
this._columns = [
|
||||||
|
{field: 'rate2', displayName: this.$t('Grouping price')},
|
||||||
|
{field: 'rate3', displayName: this.$t('Packing price')},
|
||||||
|
{field: 'hasMinPrice', displayName: this.$t('Has min price')},
|
||||||
|
{field: 'minPrice', displayName: this.$t('Min price')},
|
||||||
|
{field: 'started', displayName: this.$t('Started')},
|
||||||
|
{field: 'ended', displayName: this.$t('Ended')},
|
||||||
|
{field: 'warehouseFk', displayName: this.$t('Warehouse')}
|
||||||
|
];
|
||||||
|
|
||||||
|
return this._columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
get checked() {
|
||||||
|
const fixedPrices = this.$.model.data || [];
|
||||||
|
const checkedBuys = [];
|
||||||
|
for (let fixedPrice of fixedPrices) {
|
||||||
|
if (fixedPrice.checked)
|
||||||
|
checkedBuys.push(fixedPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkedBuys;
|
||||||
|
}
|
||||||
|
|
||||||
|
uncheck() {
|
||||||
|
this.checkAll = false;
|
||||||
|
this.checkedFixedPrices = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get totalChecked() {
|
||||||
|
if (this.checkedDummyCount)
|
||||||
|
return this.checkedDummyCount;
|
||||||
|
|
||||||
|
return this.checked.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveChecked(fixedPriceId) {
|
||||||
|
const index = this.checkedFixedPrices.indexOf(fixedPriceId);
|
||||||
|
if (index !== -1)
|
||||||
|
return this.checkedFixedPrices.splice(index, 1);
|
||||||
|
return this.checkedFixedPrices.push(fixedPriceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
reCheck() {
|
||||||
|
if (!this.$.model.data) return;
|
||||||
|
if (!this.checkedFixedPrices.length) return;
|
||||||
|
|
||||||
|
this.$.model.data.forEach(fixedPrice => {
|
||||||
|
if (this.checkedFixedPrices.includes(fixedPrice.id))
|
||||||
|
fixedPrice.checked = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditAccept() {
|
||||||
|
for (const fixedPrice of this.checked) {
|
||||||
|
fixedPrice[this.editedColumn.field] = this.editedColumn.newValue;
|
||||||
|
console.log(fixedPrice);
|
||||||
|
|
||||||
|
this.upsertPrice(fixedPrice, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (this.checkedDummyCount && this.checkedDummyCount > 0) {
|
||||||
|
// const params = {};
|
||||||
|
// if (this.$.model.userParams) {
|
||||||
|
// const userParams = this.$.model.userParams;
|
||||||
|
// for (let param in userParams) {
|
||||||
|
// let newParam = this.exprBuilder(param, userParams[param]);
|
||||||
|
// if (!newParam)
|
||||||
|
// newParam = {[param]: userParams[param]};
|
||||||
|
// Object.assign(params, newParam);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (this.$.model.userFilter)
|
||||||
|
// Object.assign(params, this.$.model.userFilter.where);
|
||||||
|
|
||||||
|
// data.filter = params;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
isBigger(date) {
|
isBigger(date) {
|
||||||
|
@ -98,8 +193,8 @@ export default class Controller extends Section {
|
||||||
if (resetMinPrice)
|
if (resetMinPrice)
|
||||||
delete price['minPrice'];
|
delete price['minPrice'];
|
||||||
|
|
||||||
let requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3'];
|
const requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3'];
|
||||||
for (let field of requiredFields)
|
for (const field of requiredFields)
|
||||||
if (price[field] == undefined) return;
|
if (price[field] == undefined) return;
|
||||||
|
|
||||||
const query = 'FixedPrices/upsertFixedPrice';
|
const query = 'FixedPrices/upsertFixedPrice';
|
||||||
|
|
|
@ -3,3 +3,5 @@ Search prices by item ID or code: Buscar por ID de artículo o código
|
||||||
Search fixed prices: Buscar precios fijados
|
Search fixed prices: Buscar precios fijados
|
||||||
Add fixed price: Añadir precio fijado
|
Add fixed price: Añadir precio fijado
|
||||||
This row will be removed: Esta linea se eliminará
|
This row will be removed: Esta linea se eliminará
|
||||||
|
Edit fixed price(s): Editar precio(s) fijado(s)
|
||||||
|
Has min price: Tiene precio mínimo
|
||||||
|
|
|
@ -24,6 +24,12 @@ vn-fixed-price{
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smart-table table tbody > * > td{
|
||||||
|
padding: 0px;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
smart-table table tbody > * > td .chip.warning {
|
smart-table table tbody > * > td .chip.warning {
|
||||||
color: $color-font-bg
|
color: $color-font-bg
|
||||||
}
|
}
|
||||||
|
@ -31,4 +37,10 @@ vn-fixed-price{
|
||||||
.vn-field > .container > .infix > .control > input {
|
.vn-field > .container > .infix > .control > input {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vn-input-number.inactive{
|
||||||
|
input {
|
||||||
|
color: $color-font-light !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue