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