ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<script lang="ts" setup>
import { onMounted, reactive } from 'vue';
import { useRoute } from 'vue-router';
 
import { useGlobSetting } from '@jnpf/hooks';
 
import { useAccessStore } from '@vben/stores';
 
import { getDataReportInfo } from '#/api/onlineDev/dataReport';
import { getRealJnpfAppEnCode } from '#/utils/jnpf';
 
interface State {
  url: string;
}
 
defineOptions({ name: 'DynamicDataReport' });
 
defineEmits(['register']);
const { dataReportPre } = useGlobSetting();
const accessStore = useAccessStore();
const state = reactive<State>({
  url: '',
});
 
function init() {
  const route = useRoute();
  const id = route.meta.relationId;
  if (!id) return;
  let targetUrl = `${dataReportPre}/preview.html?id=${id}&token=${accessStore.accessToken}&appCode=${getRealJnpfAppEnCode()}&page=1&from=menu`;
  getDataReportInfo(id).then((res) => {
    const item = {};
    if (res.data?.searchForm?.components && Array.isArray(res.data.searchForm.components)) {
      listQuery(res.data.searchForm.components, item);
      for (const key in item) {
        const item1 = `&${key}=${item[key]}`;
        targetUrl += item1;
      }
    }
    state.url = targetUrl;
  });
}
function listQuery(list, callback) {
  for (const item of list) {
    let arrayList: any[] = [];
    if (item.cols && Array.isArray(item.cols)) {
      arrayList = [...arrayList, ...item.cols];
    }
    if (item.children && Array.isArray(item.children)) {
      arrayList = [...arrayList, ...item.children];
    }
    if (item.bindParameter && item.defaultValue) {
      callback[item.bindParameter] = item.defaultValue;
    }
    listQuery(arrayList, callback);
  }
}
 
onMounted(() => {
  init();
});
</script>
<template>
  <div class="jnpf-content-wrapper bg-white">
    <iframe :src="state.url" width="100%" height="100%" frameborder="0"></iframe>
  </div>
</template>