This commit is contained in:
2021-06-02 19:18:23 +00:00
parent 7ba0f901d0
commit 9fdb04fcd9
2 changed files with 57 additions and 35 deletions

View File

@@ -378,19 +378,51 @@ export default {
vm.lastGetContractId = vm.obj.contractId; //preserve for triggering full update if something changes it later
vm.lastGetCustomerId = vm.obj.customerId; //preserve for triggering full update if something changes it later
//assign opening UID's
//assign opening values
vm.obj.isDirty = false;
vm.obj.items.forEach((z, index) => {
z.uid = index;
z.expenses.forEach((x, index) => (x.uid = index));
z.labors.forEach((x, index) => (x.uid = index));
z.loans.forEach((x, index) => (x.uid = index));
z.parts.forEach((x, index) => (x.uid = index));
z.partRequests.forEach((x, index) => (x.uid = index));
z.scheduledUsers.forEach((x, index) => (x.uid = index));
z.tasks.forEach((x, index) => (x.uid = index));
z.travels.forEach((x, index) => (x.uid = index));
z.units.forEach((x, index) => (x.uid = index));
z.outsideServices.forEach((x, index) => (x.uid = index));
z.isDirty = false;
z.expenses.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.labors.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.loans.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.parts.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.partRequests.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.scheduledUsers.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.tasks.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.travels.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.units.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.outsideServices.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
});
//modify the menu as necessary
@@ -415,24 +447,6 @@ export default {
});
}
},
// async submitNewContract() {
// //save new contract route, this only ever gets called from a clean wo with no dirty edits so just save the contract and reset the wo from the result
// let res = await window.$gz.api.post(
// `${API_BASE_URL}set-contract/${this.obj.id}`,
// { newContractId: this.obj.contractId }
// );
// if (res.error) {
// this.formState.serverError = res.error;
// window.$gz.form.setErrorBoxErrors(this);
// } else {
// this.obj = res.data;
// window.$gz.form.setFormState({
// vm: this,
// dirty: false,
// valid: true
// });
// }
// },
async submit() {
const vm = this;
if (vm.canSave == false) {
@@ -782,8 +796,8 @@ async function saveItems(vm) {
if (isPost) {
vm.obj.items[i].id = res.data.id;
vm.obj.items[i].workorderId = res.data.workorderId;
//walk all unsaved children and set the workorder id so they can save
//walk all unsaved children and set the workorder item id so they can save
vm.obj.items[i].units.forEach(
z => (z.workorderItemId = vm.obj.items[i].id)
);
@@ -919,6 +933,7 @@ async function saveUnits(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].units.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -958,6 +973,7 @@ async function saveScheduledUsers(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].scheduledUsers.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1027,6 +1043,7 @@ async function saveTasks(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].tasks.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1132,6 +1149,7 @@ async function saveParts(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].parts.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1205,6 +1223,7 @@ async function savePartRequests(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].partRequests.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1251,6 +1270,7 @@ async function saveLabors(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].labors.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1328,6 +1348,7 @@ async function saveTravels(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].travels.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1428,6 +1449,7 @@ async function saveExpenses(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].expenses.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1500,6 +1522,7 @@ async function saveLoans(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].loans.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}
@@ -1580,6 +1603,7 @@ async function saveOutsideServices(vm, woItemIndex) {
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].outsideServices.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
}
}