This commit is contained in:
2020-08-31 21:57:08 +00:00
parent ddac23546f
commit d8dfaaa5f3
2 changed files with 62 additions and 6 deletions

View File

@@ -11,7 +11,7 @@
<v-card elevation="24">
<v-card-title class="headline lighten-2" primary-title>
<span> {{ $ay.t("Report") }} </span>
TYPE: {{ ayaType }}, idList:{{ idList }}
TYPE: {{ ayaType }}, idList:{{ idList }} rights: {{ rights }}
</v-card-title>
<v-card-text style="height: 500px;">
@@ -31,6 +31,14 @@
<!-- <v-divider></v-divider> v-bind:class="options.type" -->
<v-card-actions>
<v-btn
v-if="rights.change"
color="primary darken-1"
text
@click.native="newReport"
:data-cy="!!$ay.dev ? 'reportselector:ok' : false"
>{{ $ay.t("New") }}</v-btn
>
<v-spacer></v-spacer>
<v-btn
color="primary darken-1"
@@ -54,6 +62,7 @@
<script>
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 }
});
}
}
};

View File

@@ -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;
}
}
</script>