From 0ddd0a1c1369f3c8a38f245a41cc466b70e508e1 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 4 Jun 2021 17:04:03 +0000 Subject: [PATCH] --- .../src/components/work-order-item-parts.vue | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/ayanova/src/components/work-order-item-parts.vue b/ayanova/src/components/work-order-item-parts.vue index c2810904..be9ba116 100644 --- a/ayanova/src/components/work-order-item-parts.vue +++ b/ayanova/src/components/work-order-item-parts.vue @@ -378,10 +378,53 @@ export default { } }, methods: { - doRequest(){ + doRequest() { + //todo: remove the requestAmountViz and error on edit of partid, warehouse or quantity to prevent ordering the wrong part here if they click on the button after editing those things + const requestQuantity = this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].requestAmountViz; + if (requestQuantity != null && requestQuantity > 0) { + //change the partquantity + this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].quantity = + this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex] + .quantity - requestQuantity; + //add a request record + this.value.items[this.activeWoItemIndex].partRequests.push({ + id: 0, + concurrency: 0, + partId: this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].partId, + partViz: this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].partViz, + partWarehouseId: this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].partWarehouseId, + partWarehouseViz: this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].partWarehouseViz, + quantity: requestQuantity, + isDirty: true, + workOrderItemId: this.value.items[this.activeWoItemIndex].id, + uid: Date.now() //used for error tracking / display + }); + this.$emit("change"); + //clear the error but leave dirty + this.value.items[this.activeWoItemIndex].parts[ + this.activeItemIndex + ].requestAmountViz = null; + + this.fieldValueChanged(`Items[${this.activeWoItemIndex}].parts[ + ${this.activeItemIndex} + ].quantity`); + //let user save it + } }, warehouseChange(newName) {