feat: create new ticket
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-10-03 15:18:07 +02:00
parent c4649352a9
commit 11484edd10
2 changed files with 36 additions and 3 deletions

View File

@ -138,12 +138,28 @@
<vn-menu vn-id="moreOptions">
<vn-item translate
name="sms"
ng-click="$ctrl.showSMSDialog()">
ng-click="$ctrl.createTicket()">
New ticket without route
</vn-item>
<vn-item translate
name="calculatePrice"
ng-click="$ctrl.calculateSalePrice()">
ng-click="selectRoute.show()">
New ticket with route
</vn-item>
</vn-menu>
</vn-menu>
<vn-dialog
vn-id="selectRoute"
on-accept="$ctrl.createTicket($ctrl.ticket.newRoute)">
<tpl-body>
<vn-textfield
vn-one
label="Id route"
ng-model="$ctrl.ticket.newRoute">
</vn-textfield>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Accept</button>
</tpl-buttons>
</vn-dialog>

View File

@ -26,6 +26,23 @@ class Controller extends Section {
get totalChecked() {
return this.checked.length;
}
createTicket(routeFk) {
const tomorrow = new Date();
const params = {
clientId: this.ticket.clientFk,
landed: tomorrow.getDay() + 1,
addressId: this.ticket.addressFk,
agencyModeId: this.ticket.agencyModeFk,
warehouseId: this.ticket.warehouseFk
};
const query = `Tickets/new`;
this.$http.post(query, params).then(res => {
if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk});
this.vnApp.showSuccess(this.$t('Data saved!'));
this.$state.go('ticket.card.summary', {id: res.data.id});
});
}
}
ngModule.vnComponent('vnTicketExpedition', {