PortalView.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="wrapper-content-nomargin">
  3. <el-menu @select="handleSelect" class="el-menu-demo" background-color="#f6f8f8" text-color="#777" mode="horizontal">
  4. <el-menu-item index="1"><i class="fa fa-arrow-left"></i> 返回</el-menu-item>
  5. <el-menu-item index="2"><i class="fa fa-edit"></i> 定制</el-menu-item>
  6. <el-submenu index="3">
  7. <template slot="title"><i class="fa fa-file-excel-o"></i> 导出</template>
  8. <!--
  9. <el-menu-item index="html">HTML</el-menu-item>
  10. -->
  11. <el-menu-item index="csv">CSV</el-menu-item>
  12. <el-menu-item index="excel">EXCEL</el-menu-item>
  13. <el-menu-item index="word">WORD</el-menu-item>
  14. <el-menu-item index="pdf">PDF</el-menu-item>
  15. </el-submenu>
  16. <el-menu-item index="4"><i class="fa fa-print"></i> 打印</el-menu-item>
  17. </el-menu>
  18. <!-- 参数区域 -->
  19. <portal-param-view ref="paramViewForm" :showSearchBtn="true" :pms="pms"></portal-param-view>
  20. <!-- 组件区域 -->
  21. <layout-view ref="optarea" :pageInfo="pageInfo"></layout-view>
  22. </div>
  23. </template>
  24. <script>
  25. import {baseUrl, ajax} from '@/common/biConfig'
  26. import { Loading } from 'element-ui'
  27. import LayoutView from './LayoutView.vue'
  28. import PortalParamView from './PortalParamView.vue'
  29. import $ from 'jquery'
  30. import * as utils from '@/view/portal/Utils'
  31. export default {
  32. name: "portalMain",
  33. components: {
  34. LayoutView,
  35. PortalParamView
  36. },
  37. props: {
  38. },
  39. data() {
  40. return {
  41. reportId:null,
  42. pageInfo:{},
  43. pms:[]
  44. }
  45. },
  46. methods: {
  47. handleSelect(key, keyPath){
  48. if(key === '1'){
  49. this.$router.push("/portal/Index");
  50. }else if(key === '2'){ //定制
  51. this.$router.push({path:"/portal/Customiz", query:{id:this.reportId}});
  52. }else if(key === '4'){ //打印
  53. let p = this.$refs['paramViewForm'].getParamValues();
  54. p.id = this.reportId; //参数
  55. let routeData = this.$router.resolve({path:"/portal/Print", query:p});
  56. window.open(routeData.href, '_blank');
  57. }else if(key === 'html' || key === 'csv' || key === 'excel' || key === 'pdf' || key === 'word'){ //导出
  58. this.exportReport(key);
  59. }
  60. },
  61. getCfg(){
  62. ajax({
  63. url:"portal/get.action",
  64. data:{pageId:this.reportId},
  65. type:"get",
  66. success:(resp)=>{
  67. this.pageInfo = JSON.parse(resp.rows);
  68. this.getReport();
  69. }
  70. }, this);
  71. },
  72. getReport(){
  73. let loadingInstance = Loading.service({fullscreen:false, target:document.querySelector('.wrapper-content-nomargin')});
  74. ajax({
  75. url:"portal/view.action",
  76. type:"GET",
  77. data:{pageId:this.reportId},
  78. success:(resp)=>{
  79. //渲染组件
  80. this.$refs['optarea'].setCompData(resp.rows);
  81. this.pms = resp.rows.pms;
  82. let urlParam = JSON.parse(JSON.stringify(this.$route.query));
  83. delete urlParam.id;
  84. this.$refs['paramViewForm'].initReportParam(urlParam, this.pms);
  85. }
  86. }, this, loadingInstance);
  87. },
  88. exportReport(tp){
  89. let paramViewForm = this.$refs['paramViewForm'];;
  90. utils.exportReport(tp, this.reportId, paramViewForm, this.pageInfo);
  91. }
  92. },
  93. mounted(){
  94. this.reportId = this.$route.query.id;
  95. this.getCfg();
  96. },
  97. watch: {
  98. },
  99. beforeRouteLeave: function(to, from, next) {
  100. this.$destroy();
  101. next();
  102. }
  103. }
  104. </script>
  105. <style lang="less" scoped>
  106. </style>