This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
<v-data-table
|
||||
:headers="headerList"
|
||||
:items="itemList"
|
||||
item-key="id"
|
||||
item-key="index"
|
||||
v-model="selectedRow"
|
||||
class="elevation-1"
|
||||
disable-pagination
|
||||
@@ -122,7 +122,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
newItem() {
|
||||
this.pvm.selectedItemIndex =
|
||||
this.pvm.selectItem(
|
||||
this.value.items.push({
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
@@ -147,18 +147,21 @@ export default {
|
||||
travels: [],
|
||||
units: [],
|
||||
outsideServices: []
|
||||
}) - 1;
|
||||
}) - 1
|
||||
);
|
||||
},
|
||||
async deleteItem() {
|
||||
if ((await window.$gz.dialog.confirmDelete()) != true) {
|
||||
return;
|
||||
}
|
||||
this.value.items.splice(this.pvm.selectedItemIndex, 1);
|
||||
if (this.value.items.length > 0) {
|
||||
this.pvm.selectedItemIndex = this.value.items.length - 1;
|
||||
} else {
|
||||
this.pvm.selectedItemIndex = null;
|
||||
}
|
||||
this.pvm.selectIndex(null); //select nothing in essence resetting a child selects and this one too clearing form
|
||||
|
||||
// if (this.value.items.length > 0) {
|
||||
// this.pvm.selectedItemIndex = this.value.items.length - 1;
|
||||
// } else {
|
||||
// this.pvm.selectedItemIndex = null;
|
||||
// }
|
||||
},
|
||||
selectItem: function(item) {
|
||||
this.selectedRow = [item];
|
||||
|
||||
@@ -364,6 +364,16 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectItem: function(itemIndex) {
|
||||
if (itemIndex == this.selectedItemIndex) {
|
||||
return;
|
||||
}
|
||||
this.selectedItemIndex = itemIndex;
|
||||
//reset all children
|
||||
this.selectedScheduledUserItemIndex = null;
|
||||
//todo: all children here
|
||||
//this.selectedLaborIndex...blahblah etc
|
||||
},
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
},
|
||||
@@ -648,11 +658,12 @@ async function saveItems(vm) {
|
||||
if (totalItems == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("saveItems processing this many items: ", totalItems);
|
||||
for (let i = 0; i < totalItems; i++) {
|
||||
let o = vm.obj.items[i];
|
||||
|
||||
console.log("checking for save item: ", { item: o, index: i });
|
||||
if (o.isDirty) {
|
||||
console.log("Is dirty, saving now");
|
||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o);
|
||||
if (res.error) {
|
||||
displayResError(vm, res);
|
||||
@@ -664,29 +675,39 @@ async function saveItems(vm) {
|
||||
o.workorderId = res.workorderId;
|
||||
o.isDirty = false;
|
||||
}
|
||||
} else {
|
||||
console.log("Item not dirty skipping save");
|
||||
}
|
||||
//------
|
||||
//save grandchildren
|
||||
if (!(await saveScheduledUsers(vm, o.id))) {
|
||||
if (!(await saveScheduledUsers(vm, i))) {
|
||||
return false;
|
||||
}
|
||||
//------
|
||||
console.log("Bottom of items loop", { totalItems: totalItems, i: i });
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// SCHEDULED USERS
|
||||
//
|
||||
async function saveScheduledUsers(vm, woitemid) {
|
||||
let woitemindex = vm.obj.items.findIndex(z => z.id == woitemid);
|
||||
async function saveScheduledUsers(vm, woitemindex) {
|
||||
console.log("SaveSchedUsersProcessing for woitemindex:", woitemindex);
|
||||
let totalItems = vm.obj.items[woitemindex].scheduledUsers.length;
|
||||
if (totalItems == 0) {
|
||||
console.log("saveschedusers no items to save bailing");
|
||||
return;
|
||||
}
|
||||
console.log("saveschedusers processing this many items: ", totalItems);
|
||||
for (let i = 0; i < totalItems; i++) {
|
||||
let o = vm.obj.items[woitemindex].scheduledUsers[i];
|
||||
console.log("checking for save item: ", { item: o, index: i });
|
||||
if (o.isDirty) {
|
||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}scheduledusers`, o);
|
||||
console.log("sched user Is dirty, saving now");
|
||||
let res = await window.$gz.api.upsert(
|
||||
`${API_BASE_URL}items/scheduledusers`,
|
||||
o
|
||||
);
|
||||
if (res.error) {
|
||||
displayResError(vm, res);
|
||||
return false;
|
||||
@@ -697,6 +718,8 @@ async function saveScheduledUsers(vm, woitemid) {
|
||||
o.workOrderItemId = res.workOrderItemId;
|
||||
o.isDirty = false;
|
||||
}
|
||||
} else {
|
||||
console.log("schedUserItem not dirty skipping save");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -731,6 +754,7 @@ async function saveState(vm) {
|
||||
// Error display
|
||||
//
|
||||
function displayResError(vm, res) {
|
||||
console.log("DISPLAY RES ERROR: ", res);
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user