This commit is contained in:
2021-06-04 19:13:06 +00:00
parent 8315845d85
commit 1d6f584647
3 changed files with 72 additions and 142 deletions

View File

@@ -379,12 +379,11 @@ export default {
},
methods: {
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;
].requestAmountViz; //set in svc-workorder.vue on save of part with insufficient qty
if (requestQuantity != null && requestQuantity > 0) {
//Get names for UI for request record so user knows it's the right one
let selectedPartWarehouse = this.$refs[
`Items[${this.activeWoItemIndex}].parts[${this.activeItemIndex}].partWarehouseId`
].getFullSelectionValue();
@@ -402,14 +401,14 @@ export default {
selectedPart = selectedPart.name;
}
//change the partquantity
//change the part quantity to the balance in stock
this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
].quantity =
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex]
.quantity - requestQuantity;
//add a request record
//add a request record
this.value.items[this.activeWoItemIndex].partRequests.push({
id: 0,
concurrency: 0,
@@ -426,6 +425,7 @@ export default {
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
uid: Date.now() //used for error tracking / display
});
this.$emit("change");
//clear the error but leave dirty and let user save it

View File

@@ -920,19 +920,18 @@ async function saveUnits(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].units.length; i++) {
if (vm.obj.items[woItemIndex].units[i].isDirty) {
const o = vm.obj.items[woItemIndex].units[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.unitViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].units[i],
["uid", "isDirty"]
);
let res = await window.$gz.api.upsert(`${API_BASE_URL}items/units`, o);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "units",
childUid: uid
childUid: vm.obj.items[woItemIndex].units[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -956,13 +955,12 @@ async function saveScheduledUsers(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].scheduledUsers.length; i++) {
if (vm.obj.items[woItemIndex].scheduledUsers[i].isDirty) {
const o = vm.obj.items[woItemIndex].scheduledUsers[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.serviceRateViz = undefined;
o.userViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].scheduledUsers[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/scheduled-users`,
o
@@ -972,7 +970,7 @@ async function saveScheduledUsers(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "scheduledUsers",
childUid: uid
childUid: vm.obj.items[woItemIndex].scheduledUsers[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1028,13 +1026,11 @@ async function saveTasks(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].tasks.length; i++) {
if (vm.obj.items[woItemIndex].tasks[i].isDirty) {
const o = vm.obj.items[woItemIndex].tasks[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.statusViz = undefined;
o.completedByUserViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].tasks[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/tasks`, o);
if (res.error) {
@@ -1042,7 +1038,7 @@ async function saveTasks(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "tasks",
childUid: uid
childUid: vm.obj.items[woItemIndex].tasks[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1124,11 +1120,10 @@ async function saveParts(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].parts.length; i++) {
if (vm.obj.items[woItemIndex].parts[i].isDirty) {
//clone and skip viz and other fields
let o = window.$gz.util.deepCopySkip(vm.obj.items[woItemIndex].parts[i], [
"uid",
"cost",
"listPrice"
]);
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].parts[i],
["uid", "cost", "listPrice", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/parts`, o);
if (res.error) {
@@ -1202,19 +1197,12 @@ async function savePartRequests(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].partRequests.length; i++) {
if (vm.obj.items[woItemIndex].partRequests[i].isDirty) {
const o = vm.obj.items[woItemIndex].partRequests[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.partViz = undefined;
o.upcViz = undefined;
o.partWarehouseViz = undefined;
o.purchaseOrderViz = undefined;
o.purchaseOrderIdViz = undefined;
o.purchaseOrderDateViz = undefined;
o.purchaseOrderExpectedDateViz = undefined;
o.purchaseOrderOnOrderViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].partRequests[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/part-requests`,
o
@@ -1224,7 +1212,7 @@ async function savePartRequests(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "partRequests",
childUid: uid
childUid: vm.obj.items[woItemIndex].partRequests[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1248,22 +1236,11 @@ async function saveLabors(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].labors.length; i++) {
if (vm.obj.items[woItemIndex].labors[i].isDirty) {
const o = vm.obj.items[woItemIndex].labors[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.userViz = undefined;
o.serviceRateViz = undefined;
o.taxCodeSaleViz = undefined;
o.costViz = undefined;
o.listPriceViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].labors[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/labors`, o);
if (res.error) {
@@ -1271,7 +1248,7 @@ async function saveLabors(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "labors",
childUid: uid
childUid: vm.obj.items[woItemIndex].labors[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1323,22 +1300,11 @@ async function saveTravels(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].travels.length; i++) {
if (vm.obj.items[woItemIndex].travels[i].isDirty) {
const o = vm.obj.items[woItemIndex].travels[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.userViz = undefined;
o.travelRateViz = undefined;
o.taxCodeSaleViz = undefined;
o.costViz = undefined;
o.listPriceViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].travels[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/travels`,
@@ -1349,7 +1315,7 @@ async function saveTravels(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "travels",
childUid: uid
childUid: vm.obj.items[woItemIndex].travels[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1430,16 +1396,11 @@ async function saveExpenses(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].expenses.length; i++) {
if (vm.obj.items[woItemIndex].expenses[i].isDirty) {
const o = vm.obj.items[woItemIndex].expenses[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.chargeTaxCodeViz = undefined;
o.userViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].expenses[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/expenses`,
@@ -1450,7 +1411,7 @@ async function saveExpenses(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "expenses",
childUid: uid
childUid: vm.obj.items[woItemIndex].scheduledUsers[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1503,27 +1464,18 @@ async function saveLoans(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].loans.length; i++) {
if (vm.obj.items[woItemIndex].loans[i].isDirty) {
const o = vm.obj.items[woItemIndex].loans[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.taxCodeViz = undefined;
o.loanUnitViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].loans[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/loans`, o);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "loans",
childUid: uid
childUid: vm.obj.items[woItemIndex].loans[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1579,21 +1531,11 @@ async function saveOutsideServices(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].outsideServices.length; i++) {
if (vm.obj.items[woItemIndex].outsideServices[i].isDirty) {
const o = vm.obj.items[woItemIndex].outsideServices[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.unitViz = undefined;
o.vendorSentToViz = undefined;
o.vendorSentViaViz = undefined;
o.taxCodeViz = undefined;
o.costViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].outsideServices[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/outside-services`,
@@ -1604,7 +1546,7 @@ async function saveOutsideServices(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "outsideServices",
childUid: uid
childUid: vm.obj.items[woItemIndex].outsideServices[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here