rsbi 4 лет назад
Родитель
Сommit
b574ce5dc9

+ 7 - 2
src/view/portal/LayoutView.vue

@@ -84,8 +84,13 @@ export default {
   computed: {},
   methods: {
     renderComp(comp, h, layoutId){
-      
-      let title = h('div', {class:"ibox-title"}, [h('div', {class:"ctit"}, [h('h5', comp.name)])]);
+      let hasLink = false;
+      if(comp.type === 'chart' && comp.chartJson.link && comp.chartJson.link.target){
+        hasLink = true;
+      }else if(comp.type === 'table' && comp.link && comp.link.target){
+        hasLink = true;
+      }
+      let title = h('div', {class:"ibox-title"}, [h('div', {class:"ctit"}, [h('h5', {domProps:{innerHTML:comp.name+(hasLink?" <i class='glyphicon glyphicon-link'></i>":"")}})])]);
       let compctx = [];
       if(comp.type === 'box'){
         compctx.push(h('box-view',{ref:'mv_'+comp.id, attrs:{comp:comp, editor:false}}));

+ 44 - 2
src/view/portal/Utils.js

@@ -195,7 +195,7 @@ export const compFireEvent = (link, ts, paramName, value)=>{
 		let tp = types[a];
 		if(tp === 'chart'){
 		  dt['serviceid'] = "ext.sys.chart.rebuild";
-		}else if(tp ==='table'){
+		}else if(tp ==='cross'){
 		  dt['serviceid'] = "ext.sys.cross.rebuild";
 		}
 		dt['t_from_id'] = "mv_" + ts.$parent.pageInfo.id;
@@ -212,8 +212,50 @@ export const compFireEvent = (link, ts, paramName, value)=>{
 			  let c = ts.$parent.$refs['mv_'+b];
 			  c.data = resp.rows;
 			  c.$nextTick(()=>c.showChart());
-			}else if(tp === 'table'){
+			}else if(tp === 'cross'){
+				//更新交叉表
+				let c = ts.$parent.$refs['mv_'+b];
+				c.data = resp.rows;
+			}
+		  }
+		}, ts, loadingInstance);
+	});
+}
 
+/**
+ * 点击返回按钮触发事件返回
+ * @param {*} link 
+ * @param {*} ts 
+ */
+export const compBackEvent = (link, ts)=>{
+	let target = link.target;
+	let types = link.type.split(",");
+	$(target.split(",")).each((a, b)=>{
+		let loadingInstance = Loading.service({fullscreen:false, target:document.querySelector('#c_'+b+" div.ccctx")});
+		let dt = ts.$parent.$parent.$refs['paramViewForm'].getParamValues(); // 获取参数
+		let tp = types[a];
+		if(tp === 'chart'){
+		  dt['serviceid'] = "ext.sys.chart.rebuild";
+		}else if(tp ==='cross'){
+		  dt['serviceid'] = "ext.sys.cross.rebuild";
+		}
+		dt['t_from_id'] = "mv_" + ts.$parent.pageInfo.id;
+		dt['id'] = b;
+		ajax({
+		  url:"control/extControl",
+		  type:"POST",
+		  data:dt,
+		  success:(resp)=>{
+			loadingInstance.close();
+			if(tp === 'chart'){
+			  //更新图形
+			  let c = ts.$parent.$refs['mv_'+b];
+			  c.data = resp.rows;
+			  c.$nextTick(()=>c.showChart());
+			}else if(tp === 'cross'){
+				//更新交叉表
+				let c = ts.$parent.$refs['mv_'+b];
+				c.data = resp.rows;
 			}
 		  }
 		}, ts, loadingInstance);

+ 24 - 3
src/view/portal/view/Chart.vue

@@ -10,7 +10,8 @@ export default {
   },
   data(){
     return {
-      data:null
+      data:null,
+      islink:false //是否做了事件联动
     }
   },
   props:{
@@ -34,7 +35,14 @@ export default {
     let comp = this.comp;
     if(this.data){
       let height = comp && comp.height?comp.height:250;
-      return h('div', {attrs:{id:"ct_"+comp.id}, style:{width:'100%', height: height + "px"}});
+      let ch = h('div', {attrs:{id:"ct_"+comp.id}, style:{width:'100%', height: height + "px"}});
+      if(this.islink == true){  //添加返回按钮
+        return h('div', [h('span', {class:"eventback"}, [h('span', {class:"label label-success", on:{click:()=>{
+          this.linkBack();
+        }}, domProps:{innerHTML:"<i class=\"fa fa-arrow-left\"></i>返回"}})]), ch]);
+      }else{
+        return h('div', [ch]);
+      }
     }else{
       if(this.editor === true){
         return h('div', {attrs:{align:"center", class:"tipinfo"}, domProps:{innerHTML:"(点击<i class=\"fa fa-wrench\"></i>按钮配置"+utils.getCompTypeDesc(comp.type)+")"}});
@@ -85,6 +93,11 @@ export default {
         }
       }, this, loadingInstance);
     },
+    //事件点击返回按钮
+    linkBack(){
+      this.islink = false;
+      utils.compBackEvent(this.comp.chartJson.link, this);
+    },
     /**
      * 调用echarts渲染图形
      */
@@ -105,6 +118,7 @@ export default {
         if(comp.chartJson.link && comp.chartJson.link.target && comp.chartJson.link.target.length > 0){
           myChart.off("click").on('click', function(params){
               utils.compFireEvent(comp.chartJson.link, ts, comp.chartJson.link.paramName, params.name);
+              ts.islink = true;
           });
         }
       }
@@ -121,5 +135,12 @@ export default {
 </script>
 
 <style lang="less" scoped>
-
+.eventback {
+	position:absolute;
+	width:50px;
+	right:5px;
+  cursor:pointer;
+  display:block;
+	z-index:9999;
+}
 </style>

+ 23 - 3
src/view/portal/view/Table.vue

@@ -9,7 +9,8 @@ export default {
   },
   data(){
     return {
-      data:null
+      data:null,
+      islink:false //是否做了事件联动
     }
   },
   props:{
@@ -73,7 +74,14 @@ export default {
         bodysyl.height = "220px";
       }
       let cld = [h('div', {class:"lock-dg-header"}, [table1]), h('div', {class:"lock-dg-body", style:bodysyl}, [table2])];
-      return h('div', {class:"lock-dg", attrs:{id:comp.id}}, cld);
+      let ret = h('div', {class:"lock-dg", attrs:{id:comp.id}}, cld);
+      if(ts.islink == true){  //添加返回按钮
+        return h('div', [h('span', {class:"eventback"}, [h('span', {class:"label label-success", on:{click:()=>{
+          this.linkBack();
+        }}, domProps:{innerHTML:"<i class=\"fa fa-arrow-left\"></i>返回"}})]), ret]);
+      }else{
+        return h('div', [ret]);
+      }
 
     }else{
       if(this.editor === true){
@@ -101,8 +109,13 @@ export default {
     },
     tableEvent(val){
       let comp = this.comp;
+      this.islink = true;
       utils.compFireEvent(comp.link, this, comp.link.paramName, val);
     },
+    linkBack(){
+      this.islink = false;
+      utils.compBackEvent(this.comp.link, this);
+    },
     tableView(){
       let ts = this;
       let comp = this.comp;
@@ -131,5 +144,12 @@ export default {
 </script>
 
 <style lang="less" scoped>
-
+.eventback {
+	position:absolute;
+	width:50px;
+	right:5px;
+  cursor:pointer;
+  display:block;
+	z-index:9999;
+}
 </style>