refs #5410 fix: se mantenien los checkbox marcados al paginar
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-03-15 08:40:53 +01:00
parent 4e0567eb0c
commit 38bf49c0b6
2 changed files with 31 additions and 15 deletions

View File

@ -5,6 +5,7 @@
limit="20"
order="amount DESC"
data="defaulters"
on-data-change="$ctrl.reCheck()"
auto-load="true">
</vn-crud-model>
<vn-portal slot="topbar">
@ -17,22 +18,22 @@
</vn-searchbar>
</vn-portal>
<vn-card>
<smart-table
<smart-table
model="model"
options="$ctrl.smartTableOptions"
options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-actions>
<div>
<div class="totalBox" style="text-align: center;">
<h6 translate>Total</h6>
<vn-label-value
label="Balance due"
<vn-label-value
label="Balance due"
value="{{$ctrl.balanceDueTotal | currency: 'EUR': 2}}">
</vn-label-value>
</div>
</div>
<div class="vn-pa-md">
<vn-button
<vn-button
ng-show="$ctrl.checked.length > 0"
ng-click="notesDialog.show()"
name="notesDialog"
@ -46,7 +47,7 @@
<thead>
<tr>
<th shrink>
<vn-multi-check
<vn-multi-check
model="model">
</vn-multi-check>
</th>
@ -56,25 +57,25 @@
<th field="salesPersonFk">
<span translate>Comercial</span>
</th>
<th
field="amount"
<th
field="amount"
vn-tooltip="Balance due">
<span translate>Balance D.</span>
</th>
<th
field="workerFk"
<th
field="workerFk"
vn-tooltip="Worker who made the last observation">
<span translate>Author</span>
</th>
<th field="observation" expand>
<span translate>Last observation</span>
</th>
<th
<th
vn-tooltip="Last observation date"
field="created">
<span translate>L. O. Date</span>
</th>
<th
<th
vn-tooltip="Credit insurance"
field="creditInsurance"
shrink>
@ -88,8 +89,9 @@
<tbody>
<tr ng-repeat="defaulter in defaulters">
<td shrink>
<vn-check
<vn-check
ng-model="defaulter.checked"
on-change="$ctrl.saveChecked(defaulter.clientFk)"
vn-click-stop>
</vn-check>
</td>
@ -150,7 +152,7 @@
</vn-client-summary>
</vn-popup>
<!-- Dialog of add notes button -->
<!-- Dialog of add notes button -->
<vn-dialog
vn-id="notesDialog"
on-accept="$ctrl.onResponse()">
@ -160,7 +162,7 @@
<vn-horizontal>
<vn-textarea vn-one
vn-id="message"
label="Message"
label="Message"
ng-model="$ctrl.defaulter.observation"
rows="3"
required="true"

View File

@ -6,6 +6,7 @@ export default class Controller extends Section {
constructor($element, $) {
super($element, $);
this.defaulter = {};
this.checkedDefaulers = [];
this.smartTableOptions = {
activeButtons: {
@ -68,6 +69,19 @@ export default class Controller extends Section {
return checkedLines;
}
saveChecked(clientId) {
this.checkedDefaulers = this.checkedDefaulers.includes(clientId) ?
this.checkedDefaulers.filter(id => id !== clientId) : [...this.checkedDefaulers, clientId];
}
reCheck() {
if (!this.$.model.data || !this.checkedDefaulers.length) return;
this.$.model.data.forEach(defaulter => {
defaulter.checked = this.checkedDefaulers.includes(defaulter.clientFk);
});
}
getBalanceDueTotal() {
this.$http.get('Defaulters/filter')
.then(res => {