rsbi před 4 roky
rodič
revize
76eedd540c

+ 34 - 0
src/common/biConfig.js

@@ -5,6 +5,7 @@
  * 
  */
 import $ from 'jquery'
+import { Message } from 'element-ui'
 
 const baseUrl = 'http://localhost:8080/';
 //const baseUrl = "http://112.124.13.251:8081/";
@@ -33,12 +34,21 @@ export const ajax = (cfg, ts, loadingObj) => {
 			}
 			if(resp.result === 1){
 				cfg.success(resp);
+			}else if(resp.result === 2){
+				ts.$notify.error({
+					title: '登录信息失效',
+					message:resp.msg,
+					offset: 50
+				});
 			}else{
+				/** 
 				ts.$notify.error({
 					title: '系统出错',
 					message:resp.msg,
 					offset: 50
 				});
+				*/
+				Message.error({message:resp.msg, type:"error",showClose: true});
 			}
 		},
 		error: function(){
@@ -98,4 +108,28 @@ export const list2string = (ls)=>{
 		return "";
 	}
 	return ls.join(",");
+}
+
+/**
+ * 解析图形JSON中的f$标志为字符串
+ * @param json 
+ */
+export const loopChartJson = (json)=>{
+	const exec = (jsons)=>{
+		for(let key in jsons) {
+			let o = jsons[key];
+			if(typeof o  === 'object'){
+				exec(o);  //如果是Object则递归
+			}else if(typeof o === 'string'){
+				if(o.indexOf&&o.indexOf('f$')>-1){  //吧f$字符串解析成函数
+					jsons[key] = eval("("+o.replace("f$", "")+")");
+				}
+			}
+			//else if(typeof o === 'number'){
+
+			//}
+		}
+	}
+	exec(json);
+	return json;
 }

+ 6 - 0
src/router/index.js

@@ -11,6 +11,7 @@ import UserMenu from '@/view/frame/UserMenu'
 import Model from '@/view/model/Index'
 import Portal from '@/view/portal/Index'
 import ReportDesign from '@/view/bireport/ReportDesign'
+import BireportPrint from '@/view/bireport/Print'
 
 Vue.use(Router)
 
@@ -73,6 +74,11 @@ let router = new Router({
           component:ReportDesign
         }
       ]
+    },
+    {
+      path: '/bireport/Print',
+      name: 'bireportPrint',
+      component: BireportPrint
     }
   ]
 })

+ 51 - 0
src/view/bireport/KpiDesc.vue

@@ -0,0 +1,51 @@
+<template>
+  	<el-dialog title="度量解释" :visible.sync="show" :close-on-click-modal="false" custom-class="nopadding">
+		
+		<div class="el-dialog-div">
+			<el-table :data="tableData" border style="width: 100%" header-row-class-name="tableHeadbg">
+				<el-table-column align="center" prop="kpiName" label="度量"></el-table-column>
+				<el-table-column min-width="200" align="center" prop="kpiDesc" label="解释"></el-table-column>
+			</el-table>
+		</div>
+    <div slot="footer" class="dialog-footer">
+      <el-button @click="show = false">关 闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+	import {ajax} from '@/common/biConfig'
+	import $ from 'jquery'
+
+	export default {
+	    data(){
+			return {
+				show:false,
+				tableData:[]
+			}
+		},
+		mounted(){
+			
+		},
+		computed: {
+		},
+		methods: {	
+			openDailog(cubeId){
+				this.show = true;
+				ajax({
+					url:"bireport/kpidesc.action",
+					data:{cubeId},
+					success:(resp)=>{
+						this.tableData = resp.rows;
+					}
+				});
+			}
+		},
+		watch: {
+		}
+	}
+</script>
+
+<style lang="css">
+
+</style>

+ 84 - 0
src/view/bireport/Print.vue

@@ -0,0 +1,84 @@
+<template>
+  <div>
+	  <el-button mini round v-show="back" @click="backpage()"><i class="fa fa-arrow-left"></i></el-button>
+	  <reportTablePrint ref="tableForm"></reportTablePrint>
+	  <div id="printChart2"></div>
+  </div>
+</template>
+
+<script>
+	import {ajax, loopChartJson} from '@/common/biConfig'
+	import $ from 'jquery'
+	import { Loading } from "element-ui";
+	import reportTablePrint from "@/view/bireport/ReportTablePrint";
+	import * as echartsUtils from '@/common/echartsUtils'
+
+	export default {
+	    data(){
+			return {
+				back:false,
+				type:null,
+				chartId:2
+			}
+		},
+		components: {
+			reportTablePrint
+		},
+		mounted(){
+			this.pageInfo = this.$route.params.json;
+			this.type = this.$route.params.type;
+			this.printReport();
+			//图形对象
+			window.echartsUtils = echartsUtils;
+			var echarts = require('echarts');
+			window.echarts = echarts;
+		},
+		beforeDestroy(){
+			delete window.echartsUtils;
+			delete window.echarts;
+		},
+		computed: {
+		},
+		methods: {	
+			printReport(){
+				window.document.title = "多维分析表格打印";
+				if(this.type === 'table'){ 
+					this.$refs['tableForm'].tableView(this.pageInfo, ()=>{
+						setTimeout(()=>{
+							window.print();
+							this.back = true;
+						}, 2000);
+					});
+				}else{  //打印图形
+					let load = Loading.service({ fullscreen: true });
+					ajax({
+						url:"bireport/print.action",
+						data:{pageInfo:JSON.stringify(this.pageInfo)},
+						type:"POST",
+						success:(resp)=>{
+							let option = loopChartJson(resp.rows);
+							let myChart = echarts.getInstanceByDom(document.getElementById('printChart'+this.chartId));
+							if(!myChart){
+								myChart = echarts.init(document.getElementById('printChart'+this.chartId), "default", {width:640, height:320});
+							}
+							myChart.setOption(option, true);
+							setTimeout(()=>{
+								window.print();
+								this.back = true;
+							}, 2000);
+						}
+					},this, load);
+				}
+			},
+			backpage(){
+				this.$router.go(-1);
+			}
+		},
+		watch: {
+		}
+	}
+</script>
+
+<style lang="less" scoped>
+
+</style>

+ 2 - 9
src/view/bireport/ReportChart.vue

@@ -1,6 +1,6 @@
 <!-- 图形渲染类 -->
 <script>
-	import {ajax} from '@/common/biConfig'
+	import {ajax,loopChartJson} from '@/common/biConfig'
 	import $ from 'jquery'
 	import { Loading } from "element-ui";
 	import * as tools from '@/view/bireport/bireportUtils'
@@ -235,14 +235,7 @@
 					postJSON:true,
 					data: JSON.stringify(json),
 					success: (resp)=>{							
-						let option = JSON.parse(resp.rows,function(k,v){
-							if(!v){
-								return v;
-							}else if(v.indexOf&&v.indexOf('f$')>-1){
-								return eval("("+v.replace("f$", "")+")");
-							}
-							return v;
-						});
+						let option = loopChartJson(resp.rows);
 						let myChart = echarts.getInstanceByDom(document.getElementById('chart'+this.chartId));
 						if(!myChart){
 							myChart = echarts.init(document.getElementById('chart'+this.chartId));

+ 36 - 2
src/view/bireport/ReportDesign.vue

@@ -1,6 +1,6 @@
 <template>
   	<div class="wrapper-content-nomargin">
-		<el-menu :default-active="activeIndex" class="el-menu-demo" background-color="#f6f8f8" text-color="#777" mode="horizontal">
+		<el-menu :default-active="activeIndex" @select="handleSelect" class="el-menu-demo" background-color="#f6f8f8" text-color="#777" mode="horizontal">
 			<el-submenu index="1">
 				<template slot="title"><i class="fa fa-file"></i> 文件</template>
 				<el-menu-item index="1-1">打开</el-menu-item>
@@ -52,6 +52,7 @@
 		</div>
 		<selectCube ref="selectCubeForm"></selectCube>
 		<paramFilter :pageInfo="pageInfo" ref="paramFilterForm"></paramFilter>
+		<kpi-desc ref="kpiDescForm"></kpi-desc>
   	</div>
 </template>
 
@@ -69,6 +70,8 @@
 	import 'jquery-ui-dist/jquery-ui'
 	import "jquery-contextmenu";
 	import "jquery-contextmenu/dist/jquery.contextMenu.min.css";
+	import kpiDesc from './KpiDesc.vue';
+	import * as tools from '@/view/bireport/bireportUtils'
 
 	export default {
 		name:"reportDesign",
@@ -87,7 +90,7 @@
 			}
 		},
 		components: {
-			selectCube,reportParam,reportTable,reportChart,paramFilter
+			selectCube,reportParam,reportTable,reportChart,paramFilter, kpiDesc
     	},
 		mounted(){
 			this.initdataset();
@@ -170,6 +173,37 @@
 			},
 			setIsUpdate(){
 				this.isupdate = true;
+			},
+			handleSelect(key, keyPath){
+				if(key === '4'){
+					this.$refs['kpiDescForm'].openDailog(this.pageInfo.selectDs);
+				}else if(key === '3'){  //打印
+					var comp = this.showtype === 'table' ? tools.findCompById(1, this.pageInfo) : tools.findCompById(2, this.pageInfo)
+					if(this.showtype === 'table'){
+						if(!comp.kpiJson){
+							tools.msginfo("无数据");
+							return;
+						}
+					}
+					if(this.showtype ==='chart'){
+						if(!comp.kpiJson || comp.kpiJson.length == 0){
+							tools.msginfo("无数据");
+							return;
+						}
+						if(comp.chartJson.type == "scatter" && (comp.kpiJson.length < 2 || comp.kpiJson[1] == null)  ){
+							tools.msginfo("无数据");
+							return;
+						}
+						if(comp.chartJson.type == "bubble" && (comp.kpiJson.length < 3 || comp.kpiJson[2] == null ) ){
+							tools.msginfo("无数据");
+							return;
+						}
+					}
+					var info = JSON.parse(JSON.stringify(this.pageInfo));  //复制对象
+					delete comp.dims;
+					info.comps = [comp];
+					this.$router.push({path:"/bireport/Print", name:"bireportPrint", params:{json:info,type:this.showtype}});
+				}
 			}
 		},
 		watch: {

+ 3 - 1
src/view/bireport/ReportParam.vue

@@ -19,7 +19,9 @@
 
 	export default {
 	    data(){
-			
+			return {
+
+			}
 		},
 		props:{
 			pageInfo:{

+ 2 - 6
src/view/bireport/ReportTable.vue

@@ -333,12 +333,8 @@ export default {
 			 postJSON:true,
 			 type:"POST",
 			 success:(resp)=>{
-				 try{
-					this.datas = JSON.parse(resp.rows);
-					this.$forceUpdate();
-				 }catch(ex){
-					 tools.msginfo(resp.rows);
-				 }
+				this.datas = resp.rows;
+				this.$forceUpdate();
 			 }
 		 },this, load);
 	 },

+ 86 - 0
src/view/bireport/ReportTablePrint.vue

@@ -0,0 +1,86 @@
+<!-- 表格打印渲染类 -->
+<script>
+import { ajax } from "@/common/biConfig";
+import $ from "jquery";
+import { Loading } from "element-ui";
+
+export default {
+  name:"reportTablePrint",
+  data() {
+	  return {
+		  datas:null	//数据
+		} 
+  },
+  components:{
+	
+  },
+  render(h){
+	  if(this.datas == null){
+		  return h;
+	  }else{
+		    let trs = [];
+			$(this.datas.header).each((a, b)=>{
+				let ths = [];
+				$(b).each((c, d)=>{
+					ths.push(h('th', {attrs:{colspan:d.colSpan, rowspan:d.rowSpan,align:"center"}}, d.desc));
+				});
+				trs.push(h('tr', ths));
+			});
+			let tbodytrs = [];
+			$(this.datas.datas).each((a, b)=>{
+				let tds = [];
+				$(b).each((c, d)=>{
+					tds.push(h('td', {attrs:{class:"grid3-td",align:(d.isRow==true?"left":"right"),colspan:d.colSpan, rowspan:d.rowSpan,valign:"top"}}, d.value));
+				});
+				tbodytrs.push(h('tr', tds));
+			});
+			return h('table',{class:"grid3"}, [h('thead', trs), tbodytrs]);
+	  }
+  },
+  mounted() {
+	  
+  },
+  computed: {},
+  methods: {
+	   tableView(pageInfo, cb){
+			let load = Loading.service({ fullscreen: true });
+			ajax({
+				url:"bireport/print.action",
+				data:{pageInfo:JSON.stringify(pageInfo)},
+				type:"POST",
+				success:(resp)=>{
+					this.datas = resp.rows;
+					if(cb){
+						cb();
+					}
+				}
+			},this, load);
+	   }
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+TABLE.grid3 {
+	width: 100%;
+	border-collapse:collapse;
+	table-layout:fixed;
+}
+TABLE.grid3 TH {
+	text-align: center;
+    border: 1px solid #CACACA;
+	font-size: 13px;
+    height:26px;
+    background-color: #EEEEEE;
+	font-weight:normal;
+	word-wrap: break-word;
+}
+TABLE.grid3 TD.grid3-td {
+	border: 1px solid #CACACA;
+    padding: 3px 2px 3px 2px;
+    font-size: 12px;
+    height:20px;
+	word-wrap: break-word;
+}
+</style>

+ 1 - 1
src/view/model/Index.vue

@@ -59,7 +59,7 @@ export default {
     return {
       dsetOperTitle:"",
       cubeOperTitle:""
-    };
+    }
   },
   components: {
     cube,