This commit is contained in:
@@ -84,76 +84,83 @@ export default {
|
||||
} else {
|
||||
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
|
||||
//check for copy wo item on route params
|
||||
let cp = this.$route.params.copyItem;
|
||||
if (cp) {
|
||||
cp.id = 0;
|
||||
cp.concurrency = 0;
|
||||
cp.uid = Date.now();
|
||||
cp.workOrderId = this.obj.id;
|
||||
cp.isDirty = true;
|
||||
cp.sequence = this.obj.items.length + 1;
|
||||
cp.expenses.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.labors.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.loans.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
x.cost = 0;
|
||||
x.listPrice = 0;
|
||||
});
|
||||
cp.parts.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
x.cost = 0;
|
||||
x.listPrice = 0;
|
||||
});
|
||||
|
||||
cp.scheduledUsers.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.tasks.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.travels.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.units.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
cp.outsideServices.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
vm.obj.items.push(cp);
|
||||
let wi = this.$route.params.copyItem;
|
||||
if (wi) {
|
||||
washWorkOrderItem(wi);
|
||||
wi.workOrderId = vm.obj.id;
|
||||
wi.sequence = vm.obj.items.length + 1;
|
||||
vm.obj.items.push(wi);
|
||||
setDirty = true;
|
||||
}
|
||||
// if (cp) {
|
||||
// cp.id = 0;
|
||||
// cp.concurrency = 0;
|
||||
// cp.uid = Date.now();
|
||||
// cp.workOrderId = this.obj.id;
|
||||
// cp.isDirty = true;
|
||||
// cp.sequence = this.obj.items.length + 1;
|
||||
// cp.expenses.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.labors.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.loans.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// x.cost = 0;
|
||||
// x.listPrice = 0;
|
||||
// });
|
||||
// cp.parts.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// x.cost = 0;
|
||||
// x.listPrice = 0;
|
||||
// });
|
||||
|
||||
// cp.scheduledUsers.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.tasks.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.travels.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.units.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// cp.outsideServices.forEach(x => {
|
||||
// x.id = 0;
|
||||
// x.workOrderItemId = 0;
|
||||
// x.concurrency = undefined;
|
||||
// x.isDirty = true;
|
||||
// });
|
||||
// vm.obj.items.push(cp);
|
||||
// setDirty = true;
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
//new path
|
||||
@@ -1988,6 +1995,80 @@ function generateMenu(vm) {
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Clean woitem and children so it's
|
||||
// savable as a new record
|
||||
// (used by duplicate and copy wo item functions)
|
||||
//
|
||||
function washWorkOrderItem(wi, vm) {
|
||||
if (wi) {
|
||||
wi.id = 0;
|
||||
wi.concurrency = 0;
|
||||
wi.uid = Date.now();
|
||||
wi.isDirty = true;
|
||||
wi.expenses.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.labors.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.loans.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
x.cost = 0;
|
||||
x.listPrice = 0;
|
||||
});
|
||||
wi.parts.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
x.cost = 0;
|
||||
x.listPrice = 0;
|
||||
});
|
||||
|
||||
wi.scheduledUsers.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.tasks.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.travels.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.units.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
wi.outsideServices.forEach(x => {
|
||||
x.id = 0;
|
||||
x.workOrderItemId = 0;
|
||||
x.concurrency = undefined;
|
||||
x.isDirty = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
//####################################################
|
||||
|
||||
let JUST_DELETED = false;
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user