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/updateClaimAction')(Self);
|
||||
require('../methods/claim/isEditable')(Self);
|
||||
require('../methods/claim/updateClaimDestination')(Self);
|
||||
};
|
||||
|
|
|
@ -19,65 +19,88 @@
|
|||
</vn-label-value>
|
||||
</vn-card>
|
||||
<vn-card class="vn-pa-lg vn-w-lg">
|
||||
<section class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button
|
||||
label="Import claim"
|
||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||
vn-http-click="$ctrl.importToNewRefundTicket()"
|
||||
translate-attr="{title: 'Imports claim details'}">
|
||||
</vn-button>
|
||||
<vn-range
|
||||
label="Responsability"
|
||||
min-label="Company"
|
||||
max-label="Sales/Client"
|
||||
ng-model="$ctrl.claim.responsibility"
|
||||
max="$ctrl.maxResponsibility"
|
||||
min="1"
|
||||
step="1"
|
||||
on-change="$ctrl.save({responsibility: value})">
|
||||
</vn-range>
|
||||
</vn-tool-bar>
|
||||
<vn-check vn-one
|
||||
label="Is paid with mana"
|
||||
ng-model="$ctrl.claim.isChargedToMana"
|
||||
on-change="$ctrl.save({isChargedToMana: value})">
|
||||
</vn-check>
|
||||
</section>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th number>Id</vn-th>
|
||||
<vn-th number>Ticket</vn-th>
|
||||
<vn-th>Destination</vn-th>
|
||||
<vn-th expand>Landed</vn-th>
|
||||
<vn-th number>Quantity</vn-th>
|
||||
<vn-th>Description</vn-th>
|
||||
<vn-th number>Price</vn-th>
|
||||
<vn-th number>Disc.</vn-th>
|
||||
<vn-th number>Total</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-actions>
|
||||
<section class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button
|
||||
label="Import claim"
|
||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||
vn-http-click="$ctrl.importToNewRefundTicket()"
|
||||
translate-attr="{title: 'Imports claim details'}">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Change destination"
|
||||
ng-show="$ctrl.checked.length > 0"
|
||||
ng-click="changeDestination.show()">
|
||||
</vn-button>
|
||||
<vn-range
|
||||
label="Responsability"
|
||||
min-label="Company"
|
||||
max-label="Sales/Client"
|
||||
ng-model="$ctrl.claim.responsibility"
|
||||
max="$ctrl.maxResponsibility"
|
||||
min="1"
|
||||
step="1"
|
||||
on-change="$ctrl.save({responsibility: value})">
|
||||
</vn-range>
|
||||
</vn-tool-bar>
|
||||
<vn-check vn-one
|
||||
label="Is paid with mana"
|
||||
ng-model="$ctrl.claim.isChargedToMana"
|
||||
on-change="$ctrl.save({isChargedToMana: value})">
|
||||
</vn-check>
|
||||
</section>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table model="model">
|
||||
<thead>
|
||||
<tr>
|
||||
<th shrink>
|
||||
<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"
|
||||
vn-repeat-last on-last="$ctrl.focusLastInput()">
|
||||
<vn-td number>
|
||||
<span
|
||||
<td>
|
||||
<vn-check
|
||||
ng-model="saleClaimed.$checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</td>
|
||||
<td number>
|
||||
<vn-span
|
||||
ng-click="itemDescriptor.show($event, saleClaimed.sale.itemFk)"
|
||||
class="link">
|
||||
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
</vn-span>
|
||||
</td>
|
||||
<td number>
|
||||
<vn-span
|
||||
class="link"
|
||||
ng-click="ticketDescriptor.show($event, saleClaimed.sale.ticketFk)">
|
||||
{{::saleClaimed.sale.ticketFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td expand>
|
||||
</vn-span>
|
||||
</td>
|
||||
<td expand>
|
||||
<vn-autocomplete vn-one id="claimDestinationFk"
|
||||
ng-model="saleClaimed.claimDestinationFk"
|
||||
data="claimDestinations"
|
||||
|
@ -85,35 +108,35 @@
|
|||
value-field="id"
|
||||
show-field="description">
|
||||
</vn-autocomplete>
|
||||
</vn-td>
|
||||
<vn-td expand>{{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td number>{{::saleClaimed.sale.quantity}}</vn-td>
|
||||
<vn-td expand>{{::saleClaimed.sale.concept}}</vn-td>
|
||||
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td number>{{::saleClaimed.sale.discount}} %</vn-td>
|
||||
<vn-td number>
|
||||
</td>
|
||||
<td expand>{{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}</td>
|
||||
<td number>{{::saleClaimed.sale.quantity}}</td>
|
||||
<td expand>{{::saleClaimed.sale.concept}}</td>
|
||||
<td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</td>
|
||||
<td number>{{::saleClaimed.sale.discount}} %</td>
|
||||
<td number>
|
||||
{{saleClaimed.sale.quantity * saleClaimed.sale.price *
|
||||
((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}}
|
||||
</vn-td>
|
||||
<vn-td shrink>
|
||||
</td>
|
||||
<td shrink>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove line"
|
||||
icon="delete"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-data-viewer>
|
||||
<vn-button-bar>
|
||||
<vn-button
|
||||
label="Regularize"
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- <button-bar>
|
||||
<button
|
||||
label="Regularize"
|
||||
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedStateId"
|
||||
vn-http-click="$ctrl.regularize()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</button>
|
||||
</button-bar> -->
|
||||
</smart-table>
|
||||
</vn-card>
|
||||
<vn-item-descriptor-popover
|
||||
vn-id="item-descriptor"
|
||||
|
@ -127,4 +150,29 @@
|
|||
question="Insert greuges on client card"
|
||||
message="Do you want to insert greuges?"
|
||||
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 {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.newDestination;
|
||||
this.filter = {
|
||||
include: [
|
||||
{relation: 'sale',
|
||||
|
@ -21,6 +22,55 @@ export default class Controller extends Section {
|
|||
};
|
||||
this.getResolvedState();
|
||||
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() {
|
||||
|
@ -125,6 +175,24 @@ export default class Controller extends Section {
|
|||
onSave() {
|
||||
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', {
|
||||
|
|
|
@ -7,4 +7,7 @@ Regularize: Regularizar
|
|||
Do you want to insert greuges?: Desea insertar greuges?
|
||||
Insert greuges on client card: Insertar greuges en la ficha del cliente
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue