refs #5275 feat: modificar masivamente
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
b4e04fcdad
commit
c53c54b6cd
|
@ -31,15 +31,21 @@
|
|||
<table>
|
||||
<thead>
|
||||
<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">
|
||||
<span translate>Item ID</span>
|
||||
</th>
|
||||
<th field="name">
|
||||
<span translate>Description</span>
|
||||
</th>
|
||||
<th field="warehouseFk">
|
||||
<span translate>Warehouse</span>
|
||||
</th>
|
||||
<th
|
||||
field="rate2">
|
||||
<span translate>Grouping price</span>
|
||||
|
@ -57,11 +63,21 @@
|
|||
<th field="ended">
|
||||
<span translate>Ended</span>
|
||||
</th>
|
||||
<th field="warehouseFk">
|
||||
<span translate>Warehouse</span>
|
||||
</th>
|
||||
<th shrink></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<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>
|
||||
<vn-autocomplete
|
||||
vn-id="itemFk"
|
||||
|
@ -101,18 +117,11 @@
|
|||
tabindex="-1">
|
||||
</vn-fetched-tags>
|
||||
</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>
|
||||
<vn-td-editable number>
|
||||
<text>{{price.rate2 | currency: 'EUR':2}}</text>
|
||||
<text>
|
||||
<strong>{{price.rate2 | currency: 'EUR':2}}</strong>
|
||||
</text>
|
||||
<field>
|
||||
<vn-input-number
|
||||
class="dense"
|
||||
|
@ -126,7 +135,9 @@
|
|||
</td>
|
||||
<td shrink-field>
|
||||
<vn-td-editable number>
|
||||
<text>{{price.rate3 | currency: 'EUR':2}}</text>
|
||||
<text>
|
||||
<strong>{{price.rate3 | currency: 'EUR':2}}</strong>
|
||||
</text>
|
||||
<field>
|
||||
<vn-input-number
|
||||
class="dense"
|
||||
|
@ -145,7 +156,7 @@
|
|||
on-change="$ctrl.upsertPrice(price)">
|
||||
</vn-check>
|
||||
<vn-input-number
|
||||
disabled="!price.hasMinPrice"
|
||||
ng-class="{inactive: !price.hasMinPrice}"
|
||||
ng-model="price.minPrice"
|
||||
on-change="$ctrl.upsertPrice(price)"
|
||||
step="0.01">
|
||||
|
@ -169,6 +180,15 @@
|
|||
</vn-date-picker>
|
||||
</vn-chip>
|
||||
</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>
|
||||
<vn-icon-button
|
||||
icon="delete"
|
||||
|
@ -191,6 +211,69 @@
|
|||
</smart-table>
|
||||
</vn-card>
|
||||
</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-id="item-descriptor"
|
||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||
|
|
|
@ -5,6 +5,9 @@ import './style.scss';
|
|||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.editedColumn;
|
||||
this.checkAll = false;
|
||||
this.checkedFixedPrices = [];
|
||||
|
||||
this.smartTableOptions = {
|
||||
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) {
|
||||
|
@ -98,8 +193,8 @@ export default class Controller extends Section {
|
|||
if (resetMinPrice)
|
||||
delete price['minPrice'];
|
||||
|
||||
let requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3'];
|
||||
for (let field of requiredFields)
|
||||
const requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3'];
|
||||
for (const field of requiredFields)
|
||||
if (price[field] == undefined) return;
|
||||
|
||||
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
|
||||
Add fixed price: Añadir precio fijado
|
||||
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;
|
||||
}
|
||||
|
||||
smart-table table tbody > * > td{
|
||||
padding: 0px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
smart-table table tbody > * > td .chip.warning {
|
||||
color: $color-font-bg
|
||||
}
|
||||
|
@ -31,4 +37,10 @@ vn-fixed-price{
|
|||
.vn-field > .container > .infix > .control > input {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
vn-input-number.inactive{
|
||||
input {
|
||||
color: $color-font-light !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue