瀏覽代碼

报表推送

rsbi 4 年之前
父節點
當前提交
f4d18ac9c6

+ 6 - 0
src/router/index.js

@@ -15,6 +15,7 @@ import PortalView from '@/view/portal/PortalView'
 import ReportDesign from '@/view/bireport/ReportDesign'
 import BireportPrint from '@/view/bireport/Print'
 import PortalPrint from '@/view/portal/Print'
+import PortalPushView from '@/view/portal/PortalPushView'
 import NotFind from '@/view/NoFind'
 
 Vue.use(Router)
@@ -90,6 +91,11 @@ let router = new Router({
           path:'/bireport/ReportDesign',
           name:'bireport',
           component:ReportDesign
+        },
+        {
+          path:'/portal/PushView',
+          name:'portalPushView',
+          component:PortalPushView
         }
       ]
     },

+ 4 - 0
src/style/common.less

@@ -156,6 +156,10 @@ html,body{
     height: 50vh;
     overflow: auto;
  }
+ /** 弹框 body padding */
+ .nopadding .el-dialog__body{
+    padding: 5px;
+  }
  .icon_kpi {
     color: #e07900;
  }

+ 1 - 3
src/view/model/DsourceAdd.vue

@@ -246,7 +246,5 @@ export default {
 </script>
 
 <style lang="css">
-.nopadding .el-dialog__body{
-  padding: 5px;
-}
+
 </style>

+ 14 - 2
src/view/portal/PortalIndex.vue

@@ -58,14 +58,18 @@
         </div>
       </div>
     </div>
+    <portalShare ref="portalShareForm"></portalShare>
   </div>
 </template>
 <script>
 import {baseUrl, ajax} from '@/common/biConfig'
+import portalShare from "./PortalShare.vue"
 
 export default {
   name: "portalMain",
-  components: {},
+  components: {
+    portalShare
+  },
   props: {
 
   },
@@ -92,7 +96,15 @@ export default {
 				this.checked = a.pageId;
     },
     shareReport(){
-      
+      let ts = this;
+      if(!ts.checked){
+        ts.$notify.error({
+                title: '未勾选数据',
+                offset: 50
+              });
+        return false;
+      }
+      this.$refs['portalShareForm'].share(ts.checked);
     },
     loadDatas(){
       let ts = this;

+ 147 - 0
src/view/portal/PortalPushView.vue

@@ -0,0 +1,147 @@
+<template>
+  <div class="wrapper-content-nomargin">
+    <el-menu @select="handleSelect" class="el-menu-demo" background-color="#f6f8f8" text-color="#777" mode="horizontal">
+			<el-submenu index="3">
+				<template slot="title"><i class="fa fa-file-excel-o"></i> 导出</template>
+				<el-menu-item index="html">HTML</el-menu-item>
+				<el-menu-item index="csv">CSV</el-menu-item>
+				<el-menu-item index="excel">EXCEL</el-menu-item>
+				<el-menu-item index="word">WORD</el-menu-item>
+				<el-menu-item index="pdf">PDF</el-menu-item>
+			</el-submenu>
+			<el-menu-item index="4"><i class="fa fa-print"></i> 打印</el-menu-item>
+		</el-menu>
+    <!-- 参数区域 -->
+    <portal-param-view ref="paramViewForm" :showSearchBtn="true" :pms="pms"></portal-param-view>
+    <!-- 组件区域 -->
+    <layout-view ref="optarea" :pageInfo="pageInfo"></layout-view>
+   
+  </div>
+</template>
+<script>
+import {baseUrl, ajax} from '@/common/biConfig'
+import { Loading } from 'element-ui'
+import LayoutView from './LayoutView.vue'
+import PortalParamView from './PortalParamView.vue'
+import $ from 'jquery'
+import * as utils from '@/view/portal/Utils'
+
+export default {
+  name: "portalMain",
+  components: {
+    LayoutView,
+    PortalParamView
+  },
+  props: {
+
+  },
+  data() {
+    return {
+      reportId:null,
+      pageInfo:{},
+      pms:[]
+    }
+  },
+
+  methods: {
+    handleSelect(key, keyPath){
+      if(key === '4'){  //打印
+          let p = this.$refs['paramViewForm'].getParamValues();
+          p.id = this.reportId;  //参数
+          let routeData = this.$router.resolve({path:"/portal/Print", query:p});
+          window.open(routeData.href, '_blank');
+      }else if(key === 'html' || key === 'csv' || key === 'excel' || key === 'pdf' || key === 'word'){  //导出
+        this.exportReport(key);
+      }
+    },
+    getCfg(){
+      ajax({
+        url:"portal/get.action",
+        data:{pageId:this.reportId},
+        type:"get",
+        success:(resp)=>{
+          this.pageInfo = JSON.parse(resp.rows);
+          this.getReport();
+        }
+      });
+    },
+    getReport(){
+      let loadingInstance = Loading.service({fullscreen:false, target:document.querySelector('.wrapper-content-nomargin')});
+      ajax({
+        url:"portal/view.action",
+        type:"GET",
+        data:{pageId:this.reportId},
+        success:(resp)=>{
+          //渲染组件
+          this.$refs['optarea'].setCompData(resp.rows);
+          this.pms = resp.rows.pms;
+        }
+      }, this, loadingInstance);
+    },
+    exportReport(tp){
+      let pageId = this.reportId;
+      let burl = baseUrl;
+      var ctx = `
+      <form name='expff' method='post' action="${burl}/portal/export.action" id='expff'>
+      <input type='hidden' name='type' id='type' value='${tp}'>
+      <input type='hidden' name='pageId' id='pageId' value='${pageId}'>
+      <input type='hidden' name='picinfo' id='picinfo'>
+      `;
+      let pms = this.$refs['paramViewForm'].getParamValues();
+      $(this.pageInfo.params).each((a, b)=>{
+        let v = pms[b.id];
+        ctx += `<input type='hidden' name='${b.id}' value="${v}">`;
+      });
+      ctx += `</form>`;
+      if($("#expff").length == 0 ){
+        $(ctx).appendTo("body");
+      }
+      //把图形转换成图片
+      var strs = "";
+      if(tp == "pdf" || tp == "excel" || tp == "word"){
+        let comps = utils.findAllComps(this.pageInfo).filter(m=>m.type ==='chart');
+        $(comps).each(function(index, element) {
+          var id = element.id;
+          var chart = echarts.getInstanceByDom(document.getElementById("ct_"+id));
+          var str = chart.getDataURL({type:'png', pixelRatio:1, backgroundColor: '#fff'});
+          str = str.split(",")[1]; //去除base64标记
+          str = element.id + "," + str+","+$("#ct_"+id).width(); //加上label标记,由于宽度是100%,需要加上宽度
+          strs = strs  +  str;
+          if(index != comps.length - 1){
+            strs = strs + "@";
+          }
+        });
+      }
+      $("#expff #picinfo").val(strs);
+      $("#expff").submit().remove();
+    }
+  },
+  mounted(){
+    this.reportId = this.$route.query.id;
+    this.getCfg();
+  },
+  computed:{
+    getReportId:function(){
+      return this.$route.query.id;
+    }
+  },
+  watch: {
+    getReportId:{  //监控参数变化
+      handler(val){
+        this.reportId = val;
+        this.getCfg();
+      },
+      immediate: true
+    }
+  },
+  /**
+  beforeRouteLeave: function(to, from, next) {
+    this.$destroy();
+    next();
+  }
+   */
+}
+</script>
+<style lang="less" scoped>
+
+</style>

+ 140 - 0
src/view/portal/PortalShare.vue

@@ -0,0 +1,140 @@
+<template>
+    <el-dialog title="报表分享" :visible.sync="show" :close-on-click-modal="false" custom-class="nopadding">
+      <el-form :model="form" label-width="100px">
+
+      <div class="el-dialog-div">
+        <el-tabs v-model="activeName" type="card">
+          <el-tab-pane label="直接生成URL" name="url">
+            <el-form-item label="有效期">
+              <el-radio v-model="form.yxq" label="1" border>一小时</el-radio>
+              <el-radio v-model="form.yxq" label="2" border>一天</el-radio>
+              <el-radio v-model="form.yxq" label="-1" border>永久有效</el-radio>
+            </el-form-item>
+          </el-tab-pane>
+          <el-tab-pane label="推送到菜单" name="menu">
+            <el-form-item label="名称">
+              <el-input v-model="form.menuName" placeholder="请输入名称"></el-input>
+            </el-form-item>
+            <el-form-item label="排序">
+              <el-input-number size="mini" v-model="form.menuOrder" :min="1" :max="10000" label="描述文字"></el-input-number>
+            </el-form-item>
+             <el-form-item label="上级菜单">
+              <div id="menuTree" class="treestyle"></div>
+            </el-form-item>
+          </el-tab-pane>
+          
+        </el-tabs>
+      </div>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="save()">确 定</el-button>
+        <el-button @click="show = false">取 消</el-button>
+      </div>
+    </el-dialog>
+</template>
+
+<script>
+import {baseUrl, ajax} from '@/common/biConfig'
+import $ from 'jquery'
+import "jstree";
+import "jstree/dist/themes/default/style.min.css";
+
+export default {
+  components:{
+
+  },
+  data(){
+    return {
+        show:false,
+        reportId:null,
+        activeName:"url",
+        form:{
+          yxq:"1",
+          menuName:null,
+          menuOrder:1,
+          pid:null
+        }
+    }
+  },
+  mounted(){
+
+  },
+  computed: {
+     
+  },
+  methods: {
+    share(reportId){
+      this.show = true;
+      this.reportId = reportId;
+      this.$nextTick(()=>{
+        this.initMenuTree();
+      });
+    },
+    save(){
+      let v = this.form;
+      if(this.activeName==='menu'){  //推送到菜单
+        if(!v.menuName){
+          this.$notify.error({ title: '未填写菜单名称', offset: 50});
+          return;
+        }
+        const ref = $("#menuTree").jstree(true);
+        let nodes = ref.get_selected(true);
+        if(nodes.length === 0){
+          this.$notify.error({ title: '未选择上级菜单', offset: 50});
+          return;
+        }
+        ajax({
+          type:"POST",
+          data: {menuPid:nodes[0].id, menuName:v.menuName,menuOrder:v.menuOrder, menuUrl:'/portal/PushView?id='+this.reportId},
+          postJSON:false,
+          url:"frame/menu/save.action",
+          success:(resp)=>{
+             this.$notify.success({ title: '推送成功。', offset: 50});
+          }
+        }, this);
+        this.show = false;
+      }else if(this.activeName==='url'){  //推送URL
+        this.show = false;
+      }
+      
+    },
+    initMenuTree(){
+      let ts = this;
+      let ref = $("#menuTree").jstree(true);
+      if(ref){
+        ref.destroy();
+      }
+      $("#menuTree").jstree({
+        core: {
+            check_callback: true,
+            data: function (obj, callback) {
+              let id = obj.id;
+              if(obj.id === '#'){
+                id = '0';
+              }
+              ajax({
+                type: "GET",
+                data: {id: id},
+                postJSON: false,
+                url: 'frame/menu/loadData.action',
+                success: function (resp) {
+                  callback.call(this, resp.rows);
+                },
+              }, ts);
+            },
+          },
+          plugins: ["wholerow"],
+      });
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+ .treestyle{
+    height: 160px;
+    overflow: auto;
+    border: 1px solid #cfdadd;
+    border-radius: 5px;
+ }
+</style>

+ 1 - 1
src/view/portal/Print.vue

@@ -65,7 +65,7 @@
 						//渲染组件
 						this.$refs['optarea'].setCompData(resp.rows);
 						this.$nextTick(()=>{
-							//window.print();
+							window.print();
 						});
 					}
 				}, this, loadingInstance);