feat(claim_action): add smart-table and 'change destinantion' to all rows
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
43fcd0c473
commit
df26a40e63
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('updateClaimDestination', {
|
||||||
|
description: 'Update a claim with privileges',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'rows',
|
||||||
|
type: ['object'],
|
||||||
|
required: true,
|
||||||
|
description: `the sales which will be modified the claimDestinationFk`
|
||||||
|
}, {
|
||||||
|
arg: 'claimDestinationFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/updateClaimDestination`,
|
||||||
|
verb: 'post'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.updateClaimDestination = async(rows, claimDestinationFk, options) => {
|
||||||
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const models = Self.app.models;
|
||||||
|
for (let row of rows) {
|
||||||
|
const claimEnd = await models.ClaimEnd.findById(row.id, null, myOptions);
|
||||||
|
await claimEnd.updateAttribute('claimDestinationFk', claimDestinationFk, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
return {};
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -7,4 +7,5 @@ module.exports = Self => {
|
||||||
require('../methods/claim/uploadFile')(Self);
|
require('../methods/claim/uploadFile')(Self);
|
||||||
require('../methods/claim/updateClaimAction')(Self);
|
require('../methods/claim/updateClaimAction')(Self);
|
||||||
require('../methods/claim/isEditable')(Self);
|
require('../methods/claim/isEditable')(Self);
|
||||||
|
require('../methods/claim/updateClaimDestination')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,65 +19,88 @@
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-card class="vn-pa-lg vn-w-lg">
|
<vn-card class="vn-pa-lg vn-w-lg">
|
||||||
<section class="header">
|
<smart-table
|
||||||
<vn-tool-bar class="vn-mb-md">
|
model="model"
|
||||||
<vn-button
|
options="$ctrl.smartTableOptions"
|
||||||
label="Import claim"
|
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
<slot-actions>
|
||||||
vn-http-click="$ctrl.importToNewRefundTicket()"
|
<section class="header">
|
||||||
translate-attr="{title: 'Imports claim details'}">
|
<vn-tool-bar class="vn-mb-md">
|
||||||
</vn-button>
|
<vn-button
|
||||||
<vn-range
|
label="Import claim"
|
||||||
label="Responsability"
|
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||||
min-label="Company"
|
vn-http-click="$ctrl.importToNewRefundTicket()"
|
||||||
max-label="Sales/Client"
|
translate-attr="{title: 'Imports claim details'}">
|
||||||
ng-model="$ctrl.claim.responsibility"
|
</vn-button>
|
||||||
max="$ctrl.maxResponsibility"
|
<vn-button
|
||||||
min="1"
|
label="Change destination"
|
||||||
step="1"
|
ng-show="$ctrl.checked.length > 0"
|
||||||
on-change="$ctrl.save({responsibility: value})">
|
ng-click="changeDestination.show()">
|
||||||
</vn-range>
|
</vn-button>
|
||||||
</vn-tool-bar>
|
<vn-range
|
||||||
<vn-check vn-one
|
label="Responsability"
|
||||||
label="Is paid with mana"
|
min-label="Company"
|
||||||
ng-model="$ctrl.claim.isChargedToMana"
|
max-label="Sales/Client"
|
||||||
on-change="$ctrl.save({isChargedToMana: value})">
|
ng-model="$ctrl.claim.responsibility"
|
||||||
</vn-check>
|
max="$ctrl.maxResponsibility"
|
||||||
</section>
|
min="1"
|
||||||
<vn-data-viewer model="model">
|
step="1"
|
||||||
<vn-table model="model">
|
on-change="$ctrl.save({responsibility: value})">
|
||||||
<vn-thead>
|
</vn-range>
|
||||||
<vn-tr>
|
</vn-tool-bar>
|
||||||
<vn-th number>Id</vn-th>
|
<vn-check vn-one
|
||||||
<vn-th number>Ticket</vn-th>
|
label="Is paid with mana"
|
||||||
<vn-th>Destination</vn-th>
|
ng-model="$ctrl.claim.isChargedToMana"
|
||||||
<vn-th expand>Landed</vn-th>
|
on-change="$ctrl.save({isChargedToMana: value})">
|
||||||
<vn-th number>Quantity</vn-th>
|
</vn-check>
|
||||||
<vn-th>Description</vn-th>
|
</section>
|
||||||
<vn-th number>Price</vn-th>
|
</slot-actions>
|
||||||
<vn-th number>Disc.</vn-th>
|
<slot-table>
|
||||||
<vn-th number>Total</vn-th>
|
<table model="model">
|
||||||
</vn-tr>
|
<thead>
|
||||||
</vn-thead>
|
<tr>
|
||||||
<vn-tbody>
|
<th shrink>
|
||||||
<vn-tr
|
<vn-multi-check
|
||||||
|
model="model"
|
||||||
|
check-field="$checked">
|
||||||
|
</vn-multi-check>
|
||||||
|
</th>
|
||||||
|
<th number field="itemFk">Id</th>
|
||||||
|
<th number field="ticketFk">Ticket</th>
|
||||||
|
<th field="claimDestinationFk">Destination</th>
|
||||||
|
<th expand field="landed">Landed</th>
|
||||||
|
<th number field="quantity">Quantity</th>
|
||||||
|
<th field="description">Description</th>
|
||||||
|
<th number field="price">Price</th>
|
||||||
|
<th number field="discount">Disc.</th>
|
||||||
|
<th number field="total">Total</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
ng-repeat="saleClaimed in $ctrl.salesClaimed"
|
ng-repeat="saleClaimed in $ctrl.salesClaimed"
|
||||||
vn-repeat-last on-last="$ctrl.focusLastInput()">
|
vn-repeat-last on-last="$ctrl.focusLastInput()">
|
||||||
<vn-td number>
|
<td>
|
||||||
<span
|
<vn-check
|
||||||
|
ng-model="saleClaimed.$checked"
|
||||||
|
vn-click-stop>
|
||||||
|
</vn-check>
|
||||||
|
</td>
|
||||||
|
<td number>
|
||||||
|
<vn-span
|
||||||
ng-click="itemDescriptor.show($event, saleClaimed.sale.itemFk)"
|
ng-click="itemDescriptor.show($event, saleClaimed.sale.itemFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
||||||
</span>
|
</vn-span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td number>
|
<td number>
|
||||||
<span
|
<vn-span
|
||||||
class="link"
|
class="link"
|
||||||
ng-click="ticketDescriptor.show($event, saleClaimed.sale.ticketFk)">
|
ng-click="ticketDescriptor.show($event, saleClaimed.sale.ticketFk)">
|
||||||
{{::saleClaimed.sale.ticketFk}}
|
{{::saleClaimed.sale.ticketFk}}
|
||||||
</span>
|
</vn-span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td expand>
|
<td expand>
|
||||||
<vn-autocomplete vn-one id="claimDestinationFk"
|
<vn-autocomplete vn-one id="claimDestinationFk"
|
||||||
ng-model="saleClaimed.claimDestinationFk"
|
ng-model="saleClaimed.claimDestinationFk"
|
||||||
data="claimDestinations"
|
data="claimDestinations"
|
||||||
|
@ -85,35 +108,35 @@
|
||||||
value-field="id"
|
value-field="id"
|
||||||
show-field="description">
|
show-field="description">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td expand>{{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}</vn-td>
|
<td expand>{{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}</td>
|
||||||
<vn-td number>{{::saleClaimed.sale.quantity}}</vn-td>
|
<td number>{{::saleClaimed.sale.quantity}}</td>
|
||||||
<vn-td expand>{{::saleClaimed.sale.concept}}</vn-td>
|
<td expand>{{::saleClaimed.sale.concept}}</td>
|
||||||
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
<td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</td>
|
||||||
<vn-td number>{{::saleClaimed.sale.discount}} %</vn-td>
|
<td number>{{::saleClaimed.sale.discount}} %</td>
|
||||||
<vn-td number>
|
<td number>
|
||||||
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
|
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
|
||||||
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
|
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td shrink>
|
<td shrink>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
vn-tooltip="Remove line"
|
vn-tooltip="Remove line"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
ng-click="model.remove($index)"
|
ng-click="model.remove($index)"
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</td>
|
||||||
</vn-tr>
|
</tr>
|
||||||
</vn-tbody>
|
</tbody>
|
||||||
</vn-table>
|
</table>
|
||||||
</vn-data-viewer>
|
<!-- <button-bar>
|
||||||
<vn-button-bar>
|
<button
|
||||||
<vn-button
|
label="Regularize"
|
||||||
label="Regularize"
|
|
||||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||||
vn-http-click="$ctrl.regularize()">
|
vn-http-click="$ctrl.regularize()">
|
||||||
</vn-button>
|
</button>
|
||||||
</vn-button-bar>
|
</button-bar> -->
|
||||||
|
</smart-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-item-descriptor-popover
|
<vn-item-descriptor-popover
|
||||||
vn-id="item-descriptor"
|
vn-id="item-descriptor"
|
||||||
|
@ -127,4 +150,29 @@
|
||||||
question="Insert greuges on client card"
|
question="Insert greuges on client card"
|
||||||
message="Do you want to insert greuges?"
|
message="Do you want to insert greuges?"
|
||||||
on-accept="$ctrl.onUpdateGreugeAccept()">
|
on-accept="$ctrl.onUpdateGreugeAccept()">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
||||||
|
|
||||||
|
<!-- Dialog of change destionation -->
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="changeDestination"
|
||||||
|
on-accept="$ctrl.onResponse()">
|
||||||
|
<tpl-body>
|
||||||
|
<section class="SMSDialog">
|
||||||
|
<h5 class="vn-py-sm">{{$ctrl.$t('Change destination to all selected rows', {total: $ctrl.checked.length})}}</h5>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete vn-one id="claimDestinationFk"
|
||||||
|
ng-model="$ctrl.newDestination"
|
||||||
|
data="claimDestinations"
|
||||||
|
fields="['id','description']"
|
||||||
|
value-field="id"
|
||||||
|
show-field="description"
|
||||||
|
vn-focus>
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
</section>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||||
|
<button response="accept" translate>Save</button>
|
||||||
|
</tpl-buttons>
|
||||||
|
</vn-dialog>
|
|
@ -5,6 +5,7 @@ import './style.scss';
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
this.newDestination;
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'sale',
|
{relation: 'sale',
|
||||||
|
@ -21,6 +22,55 @@ export default class Controller extends Section {
|
||||||
};
|
};
|
||||||
this.getResolvedState();
|
this.getResolvedState();
|
||||||
this.maxResponsibility = 5;
|
this.maxResponsibility = 5;
|
||||||
|
this.smartTableOptions = {
|
||||||
|
activeButtons: {
|
||||||
|
search: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'claimDestinationFk',
|
||||||
|
autocomplete: {
|
||||||
|
url: 'ClaimDestinations',
|
||||||
|
showField: 'description',
|
||||||
|
valueField: 'id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exprBuilder(param, value) {
|
||||||
|
console.log(param, value);
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return {saleFk: value};
|
||||||
|
case 'itemFk':
|
||||||
|
return {'sale.itemFk': value};
|
||||||
|
case 'ticketFk':
|
||||||
|
return {'sale.ticketFk': value};
|
||||||
|
case 'claimDestinationFk':
|
||||||
|
case 'landed':
|
||||||
|
case 'quantity':
|
||||||
|
case 'description':
|
||||||
|
case 'price':
|
||||||
|
case 'discount':
|
||||||
|
case 'total':
|
||||||
|
case 'id':
|
||||||
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get checked() {
|
||||||
|
const salesClaimed = this.$.model.data || [];
|
||||||
|
console.log(salesClaimed);
|
||||||
|
|
||||||
|
const checkedSalesClaimed = [];
|
||||||
|
for (let saleClaimed of salesClaimed) {
|
||||||
|
if (saleClaimed.$checked)
|
||||||
|
checkedSalesClaimed.push(saleClaimed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkedSalesClaimed;
|
||||||
}
|
}
|
||||||
|
|
||||||
getResolvedState() {
|
getResolvedState() {
|
||||||
|
@ -125,6 +175,24 @@ export default class Controller extends Section {
|
||||||
onSave() {
|
onSave() {
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onResponse() {
|
||||||
|
const rowsToEdit = [];
|
||||||
|
for (let row of this.checked)
|
||||||
|
rowsToEdit.push({id: row.id});
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
rows: rowsToEdit,
|
||||||
|
claimDestinationFk: this.newDestination
|
||||||
|
};
|
||||||
|
|
||||||
|
const query = `Claims/updateClaimDestination`;
|
||||||
|
this.$http.post(query, data)
|
||||||
|
.then(() => {
|
||||||
|
this.$.model.refresh();
|
||||||
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnClaimAction', {
|
ngModule.vnComponent('vnClaimAction', {
|
||||||
|
|
|
@ -7,4 +7,7 @@ Regularize: Regularizar
|
||||||
Do you want to insert greuges?: Desea insertar greuges?
|
Do you want to insert greuges?: Desea insertar greuges?
|
||||||
Insert greuges on client card: Insertar greuges en la ficha del cliente
|
Insert greuges on client card: Insertar greuges en la ficha del cliente
|
||||||
Greuge added: Greuge añadido
|
Greuge added: Greuge añadido
|
||||||
ClaimGreugeDescription: Reclamación id {{claimId}}
|
ClaimGreugeDescription: Reclamación id {{claimId}}
|
||||||
|
Change destination: Cambiar destino
|
||||||
|
Change destination to all selected rows: Cambiar destino a {{total}} fila(s) seleccionada(s)
|
||||||
|
Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s)
|
||||||
|
|
|
@ -39,4 +39,8 @@ vn-claim-action {
|
||||||
max-height: 350px;
|
max-height: 350px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue