This commit is contained in:
2021-12-27 20:11:58 +00:00
parent b264e40d36
commit 4067bb6355

View File

@@ -139,6 +139,76 @@ export default {
this.resolve(null);
}
},
async requestRender(reportId, reportName) {
if (this.$route.params.recordid == 0) {
return;
}
const reportDataOptions = this.reportDataOptions;
if (!reportDataOptions) {
this.reject("Missing report data unable to render report");
}
reportDataOptions.ReportId = reportId;
//Meta data from client for use by report script
reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData();
this.rendering = true;
try {
let jobId = await window.$gz.api.upsert(
"report/render-job",
reportDataOptions
);
if (jobId.error) {
throw new Error(window.$gz.errorHandler.errorToString(jobId, this));
}
jobId = jobId.jobId;
this.jobActive = true;
let jobStatus = 1;
while (this.jobActive == true) {
await window.$gz.util.sleepAsync(500);
jobStatus = await window.$gz.api.get(
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw new Error(
window.$gz.errorHandler.errorToString(jobStatus, this)
);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {
throw new Error("Job failed");
}
if (jobStatus == 3) {
//success, get the report url name
const jobLogRes = await window.$gz.api.get(
`job-operations/logs/${jobId}`
);
console.log(jobLogRes);
//todo:look for reportfilename property in job log here and then put in reportUrl
this.jobActive = false;
}
}
//job ran to completion, get the report file name and fetch it
if (window.open(reportUrl, "Report") == null) {
this.reject(
"Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting"
);
}
this.isVisible = false;
if (reportName != null) {
this.resolve({ name: reportName, id: reportId });
} else {
this.resolve(null);
}
} catch (error) {
this.jobActive = false;
this.reject(res);
//window.$gz.errorHandler.handleFormError(error, this);
//window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed"));
}
},
async open(reportDataOptions, preSelectReportId) {
const vm = this;
if (reportDataOptions == null) {