This commit is contained in:
2021-07-26 21:31:37 +00:00
parent db4d8badfe
commit 29cd9e8541
2 changed files with 31 additions and 170 deletions

View File

@@ -1,23 +1,5 @@
<template> <template>
<div v-if="value != null" class="mt-8"> <div v-if="value != null" class="mt-8">
<!-- {{
{
isRestrictedType: value.userIsRestrictedType,
isTechRestricted: value.userIsTechRestricted,
subfull: value.userIsSubContractorFull,
subRestricted: value.userIsSubContractorRestricted,
showLabors: showLabors,
showTravels: showTravels,
showExpenses: showExpenses,
showLoans: showLoans,
showOutsideServices: showOutsideServices,
showParts: showParts,
showPartRequests: showPartRequests,
showScheduledUsers: showScheduledUsers,
showTasks: showTasks,
showUnits: showUnits
}
}} -->
<v-row> <v-row>
<!-- Title and menu --> <!-- Title and menu -->
<v-col cols="12"> <v-col cols="12">
@@ -545,7 +527,7 @@
############################################################################ --> ############################################################################ -->
<v-col cols="12" v-show="showUnits"> <v-col cols="12" v-show="showUnits">
<GzWoItemUnits <GzQuoteItemUnits
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -556,7 +538,7 @@
</v-col> </v-col>
<v-col cols="12" v-show="showScheduledUsers"> <v-col cols="12" v-show="showScheduledUsers">
<GzWoItemScheduledUsers <GzQuoteItemScheduledUsers
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -566,7 +548,7 @@
/> />
</v-col> </v-col>
<v-col cols="12" v-show="showTasks"> <v-col cols="12" v-show="showTasks">
<GzWoItemTasks <GzQuoteItemTasks
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -577,7 +559,7 @@
</v-col> </v-col>
<v-col cols="12" v-show="showParts"> <v-col cols="12" v-show="showParts">
<GzWoItemParts <GzQuoteItemParts
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -587,19 +569,8 @@
/> />
</v-col> </v-col>
<v-col cols="12" v-if="showPartRequests">
<GzWoItemPartRequests
v-model="value"
:pvm="pvm"
:active-wo-item-index="activeItemIndex"
:goto-index="gotoPartRequestIndex"
data-cy="woItemPartRequests"
@change="$emit('change')"
/>
</v-col>
<v-col cols="12" v-show="showLabors"> <v-col cols="12" v-show="showLabors">
<GzWoItemLabors <GzQuoteItemLabors
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -609,7 +580,7 @@
/> />
</v-col> </v-col>
<v-col cols="12" v-show="showTravels"> <v-col cols="12" v-show="showTravels">
<GzWoItemTravels <GzQuoteItemTravels
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -619,7 +590,7 @@
/> />
</v-col> </v-col>
<v-col cols="12" v-show="showExpenses"> <v-col cols="12" v-show="showExpenses">
<GzWoItemExpenses <GzQuoteItemExpenses
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -630,7 +601,7 @@
</v-col> </v-col>
<v-col cols="12" v-show="showLoans"> <v-col cols="12" v-show="showLoans">
<GzWoItemLoans <GzQuoteItemLoans
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -640,7 +611,7 @@
/> />
</v-col> </v-col>
<v-col cols="12" v-show="showOutsideServices"> <v-col cols="12" v-show="showOutsideServices">
<GzWoItemOutsideServices <GzQuoteItemOutsideServices
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
@@ -697,29 +668,27 @@
/* XXXeslint-disable */ /* XXXeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
import GzWoItemUnits from "../components/work-order-item-units.vue"; import GzQuoteItemUnits from "../components/quote-item-units.vue";
import GzWoItemScheduledUsers from "../components/work-order-item-scheduled-users.vue"; import GzQuoteItemScheduledUsers from "../components/quote-item-scheduled-users.vue";
import GzWoItemLabors from "../components/work-order-item-labors.vue"; import GzQuoteItemLabors from "../components/quote-item-labors.vue";
import GzWoItemTravels from "../components/work-order-item-travels.vue"; import GzQuoteItemTravels from "../components/quote-item-travels.vue";
import GzWoItemExpenses from "../components/work-order-item-expenses.vue"; import GzQuoteItemExpenses from "../components/quote-item-expenses.vue";
import GzWoItemTasks from "../components/work-order-item-tasks.vue"; import GzQuoteItemTasks from "../components/quote-item-tasks.vue";
import GzWoItemParts from "../components/work-order-item-parts.vue"; import GzQuoteItemParts from "../components/quote-item-parts.vue";
import GzWoItemPartRequests from "../components/work-order-item-part-requests.vue"; import GzQuoteItemLoans from "../components/quote-item-loans.vue";
import GzWoItemLoans from "../components/work-order-item-loans.vue"; import GzQuoteItemOutsideServices from "../components/quote-item-outside-services.vue";
import GzWoItemOutsideServices from "../components/work-order-item-outside-services.vue";
export default { export default {
components: { components: {
GzWoItemUnits, GzQuoteItemUnits,
GzWoItemScheduledUsers, GzQuoteItemScheduledUsers,
GzWoItemExpenses, GzQuoteItemExpenses,
GzWoItemLabors, GzQuoteItemLabors,
GzWoItemTravels, GzQuoteItemTravels,
GzWoItemTasks, GzQuoteItemTasks,
GzWoItemParts, GzQuoteItemParts,
GzWoItemPartRequests, GzQuoteItemLoans,
GzWoItemLoans, GzQuoteItemOutsideServices
GzWoItemOutsideServices
}, },
created() { created() {
this.setDefaultView(); this.setDefaultView();
@@ -733,7 +702,6 @@ export default {
gotoLaborIndex: null, gotoLaborIndex: null,
gotoLoanIndex: null, gotoLoanIndex: null,
gotoPartIndex: null, gotoPartIndex: null,
gotoPartRequestIndex: null,
gotoTaskIndex: null, gotoTaskIndex: null,
gotoScheduledUserIndex: null, gotoScheduledUserIndex: null,
gotoTravelIndex: null, gotoTravelIndex: null,
@@ -816,15 +784,6 @@ export default {
} }
}); });
break; break;
case window.$gz.type.WorkOrderItemPartRequest:
z.partRequests.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.WorkOrderItemScheduledUser: case window.$gz.type.WorkOrderItemScheduledUser:
z.scheduledUsers.forEach((x, childindex) => { z.scheduledUsers.forEach((x, childindex) => {
if (x.id == val.id) { if (x.id == val.id) {
@@ -894,9 +853,7 @@ export default {
case window.$gz.type.WorkOrderItemPart: case window.$gz.type.WorkOrderItemPart:
this.gotoPartIndex = navto.childindex; this.gotoPartIndex = navto.childindex;
break; break;
case window.$gz.type.WorkOrderItemPartRequest:
this.gotoPartRequestIndex = navto.childindex;
break;
case window.$gz.type.WorkOrderItemTask: case window.$gz.type.WorkOrderItemTask:
this.gotoTaskIndex = navto.childindex; this.gotoTaskIndex = navto.childindex;
break; break;
@@ -986,7 +943,6 @@ export default {
labors: [], labors: [],
loans: [], loans: [],
parts: [], parts: [],
partRequests: [],
scheduledUsers: [], scheduledUsers: [],
tasks: [], tasks: [],
travels: [], travels: [],
@@ -1335,15 +1291,6 @@ and it's probably not a big list to fill anyway
!this.value.userIsSubContractorRestricted !this.value.userIsSubContractorRestricted
); );
}, },
showPartRequests: function() {
return (
this.pvm.useInventory &&
this.value.items[this.activeItemIndex].partRequests.length > 0 &&
this.form().showMe(this, "WorkOrderItemPartRequestList") &&
!this.value.userIsSubContractorRestricted
);
},
canAddLabor: function() { canAddLabor: function() {
return this.form().showMe(this, "WorkOrderItemLaborList"); return this.form().showMe(this, "WorkOrderItemLaborList");
}, },

View File

@@ -379,10 +379,7 @@ export default {
x.uid = index; x.uid = index;
x.isDirty = false; x.isDirty = false;
}); });
z.partRequests.forEach((x, index) => {
x.uid = index;
x.isDirty = false;
});
z.scheduledUsers.forEach((x, index) => { z.scheduledUsers.forEach((x, index) => {
x.uid = index; x.uid = index;
x.isDirty = false; x.isDirty = false;
@@ -625,9 +622,7 @@ export default {
wi.concurrency = 0; wi.concurrency = 0;
wi.uid = Date.now(); wi.uid = Date.now();
wi.isDirty = true; wi.isDirty = true;
if (wi.partRequests) {
wi.partRequests.splice(0);
}
wi.expenses.forEach(x => { wi.expenses.forEach(x => {
x.id = 0; x.id = 0;
x.workOrderItemId = 0; x.workOrderItemId = 0;
@@ -805,7 +800,6 @@ async function saveItems(vm) {
labors: removedKey2, labors: removedKey2,
loans: removedKey3, loans: removedKey3,
parts: removedKey4, parts: removedKey4,
partRequests: removedKey5,
scheduledUsers: removedKey6, scheduledUsers: removedKey6,
tasks: removedKey7, tasks: removedKey7,
travels: removedKey8, travels: removedKey8,
@@ -852,10 +846,6 @@ async function saveItems(vm) {
z => (z.workorderItemId = vm.obj.items[i].id) z => (z.workorderItemId = vm.obj.items[i].id)
); );
vm.obj.items[i].partRequests.forEach(
z => (z.workorderItemId = vm.obj.items[i].id)
);
vm.obj.items[i].labors.forEach( vm.obj.items[i].labors.forEach(
z => (z.workorderItemId = vm.obj.items[i].id) z => (z.workorderItemId = vm.obj.items[i].id)
); );
@@ -892,9 +882,7 @@ async function saveItems(vm) {
if (!vm.saveResult.fatal) { if (!vm.saveResult.fatal) {
await saveParts(vm, i); await saveParts(vm, i);
} }
if (!vm.saveResult.fatal) {
await savePartRequests(vm, i);
}
if (!vm.saveResult.fatal) { if (!vm.saveResult.fatal) {
await saveLabors(vm, i); await saveLabors(vm, i);
} }
@@ -1195,73 +1183,6 @@ async function saveParts(vm, woItemIndex) {
return; //made it return; //made it
} }
/////////////////////////////
// PART REQUESTS
//
async function deletePartRequests(vm, woItemIndex) {
//walk the array backwards as items may be spliced out
for (var i = vm.obj.items[woItemIndex].partRequests.length - 1; i >= 0; i--) {
const d = vm.obj.items[woItemIndex].partRequests[i];
if (!d.deleted) {
continue;
}
if (d.id != 0) {
let res = await window.$gz.api.remove(
`${API_BASE_URL}items/part-requests/${d.id}`
);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "partRequests",
childUid: d.uid
});
return;
}
}
vm.obj.items[woItemIndex].partRequests.splice(i, 1);
}
//----
return;
}
async function savePartRequests(vm, woItemIndex) {
//DELETE FLAGGED ITEMS FIRST
await deletePartRequests(vm, woItemIndex);
if (vm.saveResult.fatal) {
return;
}
for (let i = 0; i < vm.obj.items[woItemIndex].partRequests.length; i++) {
if (vm.obj.items[woItemIndex].partRequests[i].isDirty) {
//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
);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "partRequests",
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
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
}
}
}
return; //made it
}
///////////////////////////// /////////////////////////////
// LABOR // LABOR
// //
@@ -2085,16 +2006,9 @@ async function fetchTranslatedText(vm) {
"WorkOrderItemPartQuantity", "WorkOrderItemPartQuantity",
"WorkOrderItemPartTaxPartSaleID", "WorkOrderItemPartTaxPartSaleID",
"WorkOrderItemPartPartID", "WorkOrderItemPartPartID",
"WorkOrderItemPartRequestList",
"WorkOrderItemPartRequestPartID",
"WorkOrderItemPartRequestPartWarehouseID",
"WorkOrderItemPartRequestQuantity",
"WorkOrderItemPartRequestMore",
"PurchaseOrder", "PurchaseOrder",
"PurchaseOrderExpectedReceiveDate", "PurchaseOrderExpectedReceiveDate",
"PurchaseOrderOrderedDate", "PurchaseOrderOrderedDate",
"WorkOrderItemPartRequestOnOrder",
"WorkOrderItemPartRequestReceived",
"WorkOrderItemOutsideServiceList", "WorkOrderItemOutsideServiceList",
"WorkOrderItemOutsideServiceNotes", "WorkOrderItemOutsideServiceNotes",
"WorkOrderItemOutsideServiceVendorSentToID", "WorkOrderItemOutsideServiceVendorSentToID",