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
67
68
69
70
71
72
73
74
75
<script lang="ts" setup>
import { onMounted, reactive } from 'vue';
 
import { useGlobSetting } from '@jnpf/hooks';
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
 
import { useAccessStore } from '@vben/stores';
 
import { getDataReportInfo } from '#/api/onlineDev/dataReport';
import { getRealJnpfAppEnCode } from '#/utils/jnpf';
 
interface State {
  url: string;
}
 
defineEmits(['register']);
const { dataReportPre } = useGlobSetting();
const accessStore = useAccessStore();
const [registerPopup, { closePopup }] = usePopupInner(init);
const state = reactive<State>({
  url: '',
});
 
function init(data) {
  let targetUrl = `${dataReportPre}/preview.html?id=${data.id}&token=${accessStore.accessToken}&appCode=${getRealJnpfAppEnCode()}&page=1`;
  getDataReportInfo(data.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);
  }
}
function handleMessage(e) {
  const data = e.data;
  if (data !== 'closeDialog') return;
  state.url = '';
  closePopup();
}
 
onMounted(() => {
  window.addEventListener('message', handleMessage);
});
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" class="full-popup report-popup">
    <iframe :src="state.url" width="100%" height="100%" frameborder="0"></iframe>
  </BasicPopup>
</template>
<style lang="scss">
.report-popup {
  .jnpf-basic-popup-header {
    display: none !important;
  }
}
</style>