1368-ticket_sale_refactor #327

Merged
joan merged 20 commits from 1368-ticket_sale_refactor into dev 2020-07-02 12:58:12 +00:00
3 changed files with 21 additions and 40 deletions
Showing only changes of commit c9d94ca814 - Show all commits

View File

@ -68,6 +68,7 @@ export default class MultiCheck extends FormInput {
this.checkAll = value; this.checkAll = value;
this.toggle(); this.toggle();
this.emit('change', value);
} }
/** /**

View File

@ -52,8 +52,8 @@
<vn-thead> <vn-thead>
<vn-tr> <vn-tr>
<vn-th shrink> <vn-th shrink>
<vn-multi-check <vn-multi-check model="model"
model="model"> on-change="$ctrl.resetChanges()">
</vn-multi-check> </vn-multi-check>
</vn-th> </vn-th>
<vn-th shrink></vn-th> <vn-th shrink></vn-th>
@ -69,7 +69,7 @@
<vn-tbody> <vn-tbody>
<vn-tr ng-repeat="sale in $ctrl.sales"> <vn-tr ng-repeat="sale in $ctrl.sales">
<vn-td shrink> <vn-td shrink>
<vn-check <vn-check tabindex="-1"
ng-model="sale.checked"> ng-model="sale.checked">
</vn-check> </vn-check>
</vn-td> </vn-td>

View File

@ -142,15 +142,17 @@ class Controller extends Section {
return indexList; return indexList;
} }
changeState(value) { resetChanges() {
let params = {ticketFk: this.$params.id, code: value};
this.$http.post('TicketTrackings/changeState', params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.card.reload();
}).finally(() => {
if (this.newInstances().length === 0) if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData(); this.$.watcher.updateOriginalData();
}); }
changeState(value) {
const params = {ticketFk: this.$params.id, code: value};
return this.$http.post('TicketTrackings/changeState', params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.card.reload();
}).finally(() => this.resetChanges());
} }
removeSales() { removeSales() {
@ -159,7 +161,7 @@ class Controller extends Section {
this.$http.post(`Sales/removes`, params).then(() => { this.$http.post(`Sales/removes`, params).then(() => {
this.removeSelectedSales(); this.removeSelectedSales();
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}); }).finally(() => this.resetChanges());
} }
removeSelectedSales() { removeSelectedSales() {
@ -169,9 +171,6 @@ class Controller extends Section {
this.sales.splice(index, 1); this.sales.splice(index, 1);
}); });
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
this.refreshTotal(); this.refreshTotal();
} }
@ -251,10 +250,7 @@ class Controller extends Section {
sale.price = res.data.price; sale.price = res.data.price;
this.edit = null; this.edit = null;
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}).finally(() => { }).finally(() => this.resetChanges());
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
});
} }
this.$.editPricePopover.hide(); this.$.editPricePopover.hide();
@ -318,9 +314,7 @@ class Controller extends Section {
sale.discount = this.edit.discount; sale.discount = this.edit.discount;
this.edit = null; this.edit = null;
}).catch(e => { }).finally(() => this.resetChanges());
this.vnApp.showError(e.message);
});
} }
getNewPrice() { getNewPrice() {
@ -381,10 +375,7 @@ class Controller extends Section {
if (reservedSale) if (reservedSale)
sale.reserved = reservedSale.reserved; sale.reserved = reservedSale.reserved;
}); });
}).finally(() => { }).finally(() => this.resetChanges());
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
});
} }
newOrderFromTicket() { newOrderFromTicket() {
@ -444,16 +435,12 @@ class Controller extends Section {
*/ */
updateQuantity(sale) { updateQuantity(sale) {
const data = {quantity: sale.quantity}; const data = {quantity: sale.quantity};
const query = `Sales/${sale.id}/updateQuantity`; this.$http.post(`Sales/${sale.id}/updateQuantity`, data).then(() => {
this.$http.post(query, data).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}).catch(e => { }).catch(e => {
this.$.model.refresh(); this.$.model.refresh();
throw e; throw e;
}).finally(() => { }).finally(() => this.resetChanges());
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
});
} }
/* /*
@ -461,16 +448,12 @@ class Controller extends Section {
*/ */
changeConcept(sale) { changeConcept(sale) {
const data = {newConcept: sale.concept}; const data = {newConcept: sale.concept};
const query = `Sales/${sale.id}/updateConcept`; this.$http.post(`Sales/${sale.id}/updateConcept`, data).then(() => {
this.$http.post(query, data).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}).catch(e => { }).catch(e => {
this.$.model.refresh(); this.$.model.refresh();
throw e; throw e;
}).finally(() => { }).finally(() => this.resetChanges());
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
});
} }
/* /*
@ -496,10 +479,7 @@ class Controller extends Section {
sale.item = newSale.item; sale.item = newSale.item;
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}).finally(() => { }).finally(() => this.resetChanges());
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
});
} }
isTicketEditable() { isTicketEditable() {