This commit is contained in:
2021-09-08 17:24:20 +00:00
parent 9582cbff48
commit aa8224b6df

View File

@@ -387,10 +387,7 @@ export default {
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":acceptnew"
);
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":reject");
} else {
window.$gz.eventBus.$emit(
@@ -398,11 +395,19 @@ export default {
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":reject");
}
if (!val.dirty && val.valid) {
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":acceptnew"
);
} else {
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":acceptnew"
);
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":reject");
}
},
deep: true
@@ -595,28 +600,13 @@ export default {
if (vm.obj.status != 0 || vm.$route.params.recordid == 0) {
return;
}
window.$gz.form.setFormState({
vm: vm,
loading: true
});
let url = API_BASE_URL + "reject/" + vm.$route.params.recordid;
//change status to rejected and save
vm.obj.status = 2; //declined=2, accepted=1
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.upsert(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Navigate to record
this.$router.push({
name: "csr-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
}
await this.submit();
// navigate backwards
vm.$router.go(-1);
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
@@ -630,42 +620,113 @@ export default {
//generate work order from this csr
//flag this csr as accepted
let vm = this;
if (vm.obj.status != 0 || vm.$route.params.recordid == 0) {
if (vm.$route.params.recordid == 0) {
return;
}
window.$gz.form.setFormState({
vm: vm,
loading: true
});
//get workorder if to existing
//create new workorder for this csr
//navigate to the new workorder so it can be edited and or saved
//workorder is responsible for flagging as fromcsr so that server can update the csr when it sees the wo is new and the fromcsrid is set
let url = `${API_BASE_URL}accept/${vm.$route.params.recordid}/${toExistingId}`;
let w = {
id: 0,
concurrency: 0,
serial: 0,
notes: this.obj.name,
wiki: null,
customFields: "{}",
tags: [],
customerId: this.obj.customerId,
projectId: null,
contractId: null,
internalReferenceNumber: null,
customerReferenceNumber: this.obj.customerReferenceNumber,
customerContactName: this.obj.requestedByUserViz,
fromQuoteId: null,
fromPMId: null,
fromCSRId: this.obj.id,
serviceDate: null,
completeByDate: null,
durationToCompleted: "00:00:00",
invoiceNumber: null,
onsite: true,
customerSignature: null,
customerSignatureName: null,
customerSignatureCaptured: null,
techSignature: null,
techSignatureName: null,
techSignatureCaptured: null,
postAddress: null,
postCity: null,
postRegion: null,
postCountry: null,
postCode: null,
address: null,
city: null,
region: null,
country: null,
latitude: null,
longitude: null,
items: [],
states: [],
isDirty: true,
isLockedAtServer: false,
alertViz: null
};
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.upsert(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Navigate to record
this.$router.push({
name: "csr-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
let wi = {
id: 0,
concurrency: 0,
notes: this.obj.name,
wiki: null,
customFields: "{}",
tags: [],
workOrderId: 0,
techNotes: this.obj.notes,
workOrderItemStatusId: null,
workOrderItemPriorityId: null,
requestDate: this.obj.dateRequested,
warrantyService: false,
sequence: 1,
isDirty: true,
expenses: [],
labors: [],
loans: [],
parts: [],
partRequests: [],
scheduledUsers: [],
tasks: [],
travels: [],
units: [],
outsideServices: []
};
if (this.obj.unitId != null) {
wi.units.push({
id: 0,
concurrency: 0,
wiki: null,
customFields: "{}",
tags: [],
notes: null,
unitId: this.obj.unitId,
isDirty: true,
workOrderItemId: 0,
unitViz: null,
warrantyViz: null
});
}
w.items.push(wi);
//Navigate to new record
this.$router.push({
name: "workorder-edit",
params: {
recordid: 0,
obj: w
}
});
}
//end methods
}
@@ -805,24 +866,27 @@ function generateMenu(vm) {
menuOptions.menuItems.push({ divider: true, inset: false });
if (vm.obj.status == 0) {
menuOptions.menuItems.push({
title: "CustomerServiceRequestAcceptToNew",
icon: null,
key: FORM_KEY + ":acceptnew",
vm: vm
});
if (vm.rights.change) {
if (vm.obj.status != 1) {
//if not already accepted, this allows to accept even if rejected earlier
menuOptions.menuItems.push({
title: "CustomerServiceRequestAcceptToNew",
icon: null,
key: FORM_KEY + ":acceptnew",
vm: vm
});
}
if (vm.obj.status == 0) {
menuOptions.menuItems.push({
title: "CustomerServiceRequestReject",
icon: null,
key: FORM_KEY + ":reject",
vm: vm
});
}
menuOptions.menuItems.push({
title: "CustomerServiceRequestReject",
icon: null,
key: FORM_KEY + ":reject",
vm: vm
});
menuOptions.menuItems.push({ divider: true, inset: false });
}
menuOptions.menuItems.push({ divider: true, inset: false });
window.$gz.eventBus.$emit("menu-change", menuOptions);
}