This commit is contained in:
2021-04-12 18:49:36 +00:00
parent 07336466a2
commit 3a62c5cd26
2 changed files with 25 additions and 26 deletions

View File

@@ -409,30 +409,26 @@ export default {
window.$gz.form.deleteAllErrorBoxErrors(vm);
//#######################################################
// ███████╗ █████╗ ██╗ ██╗███████╗
// ██╔════╝██╔══██╗██║ ██║██╔════╝
// ███████╗███████║██║ ██║█████╗
// ╚════██║██╔══██║╚██╗ ██╔╝██╔══╝
// ███████║██║ ██║ ╚████╔╝ ███████╗
// ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝
//walk the tree and save dirty
//items in order
//individual save will throw on
//exception short circuiting here
//Delete flagged items first upwards from bottom of graph
//one by one individually
//then save all items downwards from top of graph
//mostly via workorderitem
//items in correct order
//########################################################
let noProblem = true;
//HEADER MUST BE SAVED FIRST IF IT's NEW
//UNSAVED HEADER MUST BE FIRST
//(otherwise there's nothing to hang the other things off of)
let headerSaved = false;
if (this.obj.concurrency == 0) {
console.log("concurrency 0, saving header");
noProblem = await saveHeader(vm);
headerSaved = true;
}
//### STATE first if unlocking only
//if moving to another locked state this will block further updates below but we're accepting that
//and user can unlock first to finish updating
//LOCKED? State must be saved first then (assuming it unlocks)
let stateSaved = false;
if (this.obj.isLockedAtServer) {
noProblem = await saveState(vm);
@@ -619,7 +615,6 @@ async function saveHeader(vm) {
}
let isPost = o.id == 0;
let res = await window.$gz.api.upsert(`${API_BASE_URL}`, o);
console.log("result of saving header is ", res);
if (res.error) {
displayResError(vm, res);
return false;
@@ -630,6 +625,9 @@ async function saveHeader(vm) {
if (isPost) {
vm.obj.id = res.data.id;
vm.obj.serial = res.data.serial;
//walk all unsaved direct children and set the workorder id so they can save
o.states.forEach(z => (z.workOrderId = o.id));
o.items.forEach(z => (z.workOrderId = o.id));
}
return true;
}