This commit is contained in:
@@ -1,23 +1,5 @@
|
||||
<template>
|
||||
<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>
|
||||
<!-- Title and menu -->
|
||||
<v-col cols="12">
|
||||
@@ -545,7 +527,7 @@
|
||||
############################################################################ -->
|
||||
|
||||
<v-col cols="12" v-show="showUnits">
|
||||
<GzWoItemUnits
|
||||
<GzQuoteItemUnits
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -556,7 +538,7 @@
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" v-show="showScheduledUsers">
|
||||
<GzWoItemScheduledUsers
|
||||
<GzQuoteItemScheduledUsers
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -566,7 +548,7 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" v-show="showTasks">
|
||||
<GzWoItemTasks
|
||||
<GzQuoteItemTasks
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -577,7 +559,7 @@
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" v-show="showParts">
|
||||
<GzWoItemParts
|
||||
<GzQuoteItemParts
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -587,19 +569,8 @@
|
||||
/>
|
||||
</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">
|
||||
<GzWoItemLabors
|
||||
<GzQuoteItemLabors
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -609,7 +580,7 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" v-show="showTravels">
|
||||
<GzWoItemTravels
|
||||
<GzQuoteItemTravels
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -619,7 +590,7 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" v-show="showExpenses">
|
||||
<GzWoItemExpenses
|
||||
<GzQuoteItemExpenses
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -630,7 +601,7 @@
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" v-show="showLoans">
|
||||
<GzWoItemLoans
|
||||
<GzQuoteItemLoans
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -640,7 +611,7 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" v-show="showOutsideServices">
|
||||
<GzWoItemOutsideServices
|
||||
<GzQuoteItemOutsideServices
|
||||
v-model="value"
|
||||
:pvm="pvm"
|
||||
:active-wo-item-index="activeItemIndex"
|
||||
@@ -697,29 +668,27 @@
|
||||
/* XXXeslint-disable */
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import GzWoItemUnits from "../components/work-order-item-units.vue";
|
||||
import GzWoItemScheduledUsers from "../components/work-order-item-scheduled-users.vue";
|
||||
import GzWoItemLabors from "../components/work-order-item-labors.vue";
|
||||
import GzWoItemTravels from "../components/work-order-item-travels.vue";
|
||||
import GzWoItemExpenses from "../components/work-order-item-expenses.vue";
|
||||
import GzWoItemTasks from "../components/work-order-item-tasks.vue";
|
||||
import GzWoItemParts from "../components/work-order-item-parts.vue";
|
||||
import GzWoItemPartRequests from "../components/work-order-item-part-requests.vue";
|
||||
import GzWoItemLoans from "../components/work-order-item-loans.vue";
|
||||
import GzWoItemOutsideServices from "../components/work-order-item-outside-services.vue";
|
||||
import GzQuoteItemUnits from "../components/quote-item-units.vue";
|
||||
import GzQuoteItemScheduledUsers from "../components/quote-item-scheduled-users.vue";
|
||||
import GzQuoteItemLabors from "../components/quote-item-labors.vue";
|
||||
import GzQuoteItemTravels from "../components/quote-item-travels.vue";
|
||||
import GzQuoteItemExpenses from "../components/quote-item-expenses.vue";
|
||||
import GzQuoteItemTasks from "../components/quote-item-tasks.vue";
|
||||
import GzQuoteItemParts from "../components/quote-item-parts.vue";
|
||||
import GzQuoteItemLoans from "../components/quote-item-loans.vue";
|
||||
import GzQuoteItemOutsideServices from "../components/quote-item-outside-services.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GzWoItemUnits,
|
||||
GzWoItemScheduledUsers,
|
||||
GzWoItemExpenses,
|
||||
GzWoItemLabors,
|
||||
GzWoItemTravels,
|
||||
GzWoItemTasks,
|
||||
GzWoItemParts,
|
||||
GzWoItemPartRequests,
|
||||
GzWoItemLoans,
|
||||
GzWoItemOutsideServices
|
||||
GzQuoteItemUnits,
|
||||
GzQuoteItemScheduledUsers,
|
||||
GzQuoteItemExpenses,
|
||||
GzQuoteItemLabors,
|
||||
GzQuoteItemTravels,
|
||||
GzQuoteItemTasks,
|
||||
GzQuoteItemParts,
|
||||
GzQuoteItemLoans,
|
||||
GzQuoteItemOutsideServices
|
||||
},
|
||||
created() {
|
||||
this.setDefaultView();
|
||||
@@ -733,7 +702,6 @@ export default {
|
||||
gotoLaborIndex: null,
|
||||
gotoLoanIndex: null,
|
||||
gotoPartIndex: null,
|
||||
gotoPartRequestIndex: null,
|
||||
gotoTaskIndex: null,
|
||||
gotoScheduledUserIndex: null,
|
||||
gotoTravelIndex: null,
|
||||
@@ -816,15 +784,6 @@ export default {
|
||||
}
|
||||
});
|
||||
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:
|
||||
z.scheduledUsers.forEach((x, childindex) => {
|
||||
if (x.id == val.id) {
|
||||
@@ -894,9 +853,7 @@ export default {
|
||||
case window.$gz.type.WorkOrderItemPart:
|
||||
this.gotoPartIndex = navto.childindex;
|
||||
break;
|
||||
case window.$gz.type.WorkOrderItemPartRequest:
|
||||
this.gotoPartRequestIndex = navto.childindex;
|
||||
break;
|
||||
|
||||
case window.$gz.type.WorkOrderItemTask:
|
||||
this.gotoTaskIndex = navto.childindex;
|
||||
break;
|
||||
@@ -986,7 +943,6 @@ export default {
|
||||
labors: [],
|
||||
loans: [],
|
||||
parts: [],
|
||||
partRequests: [],
|
||||
scheduledUsers: [],
|
||||
tasks: [],
|
||||
travels: [],
|
||||
@@ -1335,15 +1291,6 @@ and it's probably not a big list to fill anyway
|
||||
!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() {
|
||||
return this.form().showMe(this, "WorkOrderItemLaborList");
|
||||
},
|
||||
|
||||
@@ -379,10 +379,7 @@ export default {
|
||||
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;
|
||||
@@ -625,9 +622,7 @@ export default {
|
||||
wi.concurrency = 0;
|
||||
wi.uid = Date.now();
|
||||
wi.isDirty = true;
|
||||
if (wi.partRequests) {
|
||||
wi.partRequests.splice(0);
|
||||
}
|
||||
|
||||
wi.expenses.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
@@ -805,7 +800,6 @@ async function saveItems(vm) {
|
||||
labors: removedKey2,
|
||||
loans: removedKey3,
|
||||
parts: removedKey4,
|
||||
partRequests: removedKey5,
|
||||
scheduledUsers: removedKey6,
|
||||
tasks: removedKey7,
|
||||
travels: removedKey8,
|
||||
@@ -852,10 +846,6 @@ async function saveItems(vm) {
|
||||
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(
|
||||
z => (z.workorderItemId = vm.obj.items[i].id)
|
||||
);
|
||||
@@ -892,9 +882,7 @@ async function saveItems(vm) {
|
||||
if (!vm.saveResult.fatal) {
|
||||
await saveParts(vm, i);
|
||||
}
|
||||
if (!vm.saveResult.fatal) {
|
||||
await savePartRequests(vm, i);
|
||||
}
|
||||
|
||||
if (!vm.saveResult.fatal) {
|
||||
await saveLabors(vm, i);
|
||||
}
|
||||
@@ -1195,73 +1183,6 @@ async function saveParts(vm, woItemIndex) {
|
||||
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
|
||||
//
|
||||
@@ -2085,16 +2006,9 @@ async function fetchTranslatedText(vm) {
|
||||
"WorkOrderItemPartQuantity",
|
||||
"WorkOrderItemPartTaxPartSaleID",
|
||||
"WorkOrderItemPartPartID",
|
||||
"WorkOrderItemPartRequestList",
|
||||
"WorkOrderItemPartRequestPartID",
|
||||
"WorkOrderItemPartRequestPartWarehouseID",
|
||||
"WorkOrderItemPartRequestQuantity",
|
||||
"WorkOrderItemPartRequestMore",
|
||||
"PurchaseOrder",
|
||||
"PurchaseOrderExpectedReceiveDate",
|
||||
"PurchaseOrderOrderedDate",
|
||||
"WorkOrderItemPartRequestOnOrder",
|
||||
"WorkOrderItemPartRequestReceived",
|
||||
"WorkOrderItemOutsideServiceList",
|
||||
"WorkOrderItemOutsideServiceNotes",
|
||||
"WorkOrderItemOutsideServiceVendorSentToID",
|
||||
|
||||
Reference in New Issue
Block a user