From d8dfaaa5f329250bdcea736b779064a1e258619b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 31 Aug 2020 21:57:08 +0000 Subject: [PATCH] --- .../components/report-selector-control.vue | 24 +++++++++- ayanova/src/views/ay-report-edit.vue | 44 +++++++++++++++++-- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/ayanova/src/components/report-selector-control.vue b/ayanova/src/components/report-selector-control.vue index 9b57b21d..bbf20f55 100644 --- a/ayanova/src/components/report-selector-control.vue +++ b/ayanova/src/components/report-selector-control.vue @@ -11,7 +11,7 @@ {{ $ay.t("Report") }} - TYPE: {{ ayaType }}, idList:{{ idList }} + TYPE: {{ ayaType }}, idList:{{ idList }} rights: {{ rights }} @@ -31,6 +31,14 @@ + {{ $ay.t("New") }} export default { data: () => ({ + rights: window.$gz.role.getRights(window.$gz.type.Report), ayaType: null, idList: [], isVisible: false, @@ -74,10 +83,13 @@ export default { } this.ayaType = ayaType; this.idList = idList; + + //rights + //get report list from server let res = await window.$gz.api.get(`report/list/${ayaType}`); - console.log("report-selectr report list from server is: ", res); + //console.log("report-selectr report list from server is: ", res); if (res.error) { throw res.error; } else { @@ -97,6 +109,14 @@ export default { cancel() { this.isVisible = false; this.resolve(null); + }, + newReport() { + this.isVisible = false; + this.resolve(null); + this.$router.push({ + name: "ay-report-edit", + params: { recordid: 0, ayaType: this.ayaType, idList: this.idList } + }); } } }; diff --git a/ayanova/src/views/ay-report-edit.vue b/ayanova/src/views/ay-report-edit.vue index 6a12a6ea..9bdbed43 100644 --- a/ayanova/src/views/ay-report-edit.vue +++ b/ayanova/src/views/ay-report-edit.vue @@ -123,12 +123,18 @@ export default { vm.formState.readOnly = !vm.rights.change; window.$gz.eventBus.$on("menu-click", clickHandler); + //route params MUST have ID LIST + if (!vm.$route.params.idList) { + } + + vm.idList = vm.$route.params.idList; + //id 0 means create a new record don't load one if (vm.$route.params.recordid != 0) { //is there already an obj from a prior operation? - if (this.$route.params.obj) { + if (vm.$route.params.obj) { //yes, no need to fetch it - this.obj = this.$route.params.obj; + vm.obj = vm.$route.params.obj; window.$gz.form.setFormState({ vm: vm, loading: false @@ -137,6 +143,8 @@ export default { await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading } } else { + //New record so there *MUST* be an ayType on the route params + window.$gz.form.setFormState({ vm: vm, loading: false @@ -188,7 +196,7 @@ export default { data() { return { - //editor: null, + reportData: [], editAreaHeight: 300, activeTab: "properties", lastTab: "properties", @@ -677,7 +685,7 @@ function generateMenu(vm) { // async function initForm(vm) { await fetchTranslatedText(vm); - // await populateSelectionLists(vm); + await fetchReportData(vm); } ////////////////////////////////////////////////////////// @@ -693,4 +701,32 @@ async function fetchTranslatedText(vm) { "ReportTemplate" ]); } + +//////////////////// +// +async function fetchReportData(vm) { + let idList = vm.$route.params.idList; + vm.obj.objectType = vm.$route.params.ayaType; + if (!idList || idList.length == 0) { + throw "ay-report-edit:fetchReportData - route parameter idList is missing or empty, unable to init report designer"; + } + if (vm.obj.objectType == null) { + throw "ay-report-edit:fetchReportData - route parameter ayaType is missing or empty, unable to init report designer"; + } + /* public class ObjectReportDataParameter + { + public AyaType ObjectType { get; set; } + public long[] ObjectIdArray { get; set; } + } */ + let res = await window.$gz.api.upsert("report/object-report-data", { + ObjectType: vm.obj.objectType, + ObjectIdArray: idList + }); + //We never expect there to be no data here + if (!res.hasOwnProperty("data")) { + throw res; + } else { + vm.reportData = res.data; + } +}