Authored by 鲁尚清

树结构右侧更改为iframe引入已配置好的容量分析页

@@ -32,6 +32,14 @@ export const monitorTreeShape = { @@ -32,6 +32,14 @@ export const monitorTreeShape = {
32 }, 32 },
33 { 33 {
34 type: 'el-switch', 34 type: 'el-switch',
  35 + label: '右边内容',
  36 + name: 'isFrame',
  37 + required: false,
  38 + placeholder: '',
  39 + value: true
  40 + },
  41 + {
  42 + type: 'el-switch',
35 label: '加边框', 43 label: '加边框',
36 name: 'isBorder', 44 name: 'isBorder',
37 required: false, 45 required: false,
1 <template> 1 <template>
2 <div :style="styleObj" class="treeContainer"> 2 <div :style="styleObj" class="treeContainer">
3 - <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" v-if="optionsSetup.isType">  
4 - <el-tab-pane label="业务" name="first"></el-tab-pane>  
5 - <el-tab-pane label="资源" name="second"></el-tab-pane>  
6 - </el-tabs>  
7 - <el-tree :style="textStyle" class="tree-div" ref="roleTree" :data="treeData" :props="defaultProps" @node-click="handleNodeClick"  
8 - node-key="id" :default-checked-keys="checkedKeys"  
9 - /> 3 + <div class="tree-left" :style="treeLeftStyle">
  4 + <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" v-if="optionsSetup.isType">
  5 + <el-tab-pane label="业务" name="first"></el-tab-pane>
  6 + <el-tab-pane label="资源" name="second"></el-tab-pane>
  7 + </el-tabs>
  8 + <el-tree :style="textStyle" class="tree-div" ref="roleTree" :data="treeData" :props="defaultProps" @node-click="handleNodeClick"
  9 + node-key="id" :default-checked-keys="checkedKeys"
  10 + />
  11 + </div>
  12 + <div class="tree-content" v-if="optionsSetup.isFrame">
  13 + <iframe :src="iframeSrc" style="width:100%;height:100%;" frameborder="0"></iframe>
  14 + </div>
10 </div> 15 </div>
11 </template> 16 </template>
12 17
13 <script> 18 <script>
14 -var per = 60;  
15 export default { 19 export default {
16 name: "progressInformation", 20 name: "progressInformation",
17 components: {}, 21 components: {},
@@ -21,6 +25,7 @@ export default { @@ -21,6 +25,7 @@ export default {
21 }, 25 },
22 data() { 26 data() {
23 return { 27 return {
  28 + iframeSrc:'',
24 activeName:'first', 29 activeName:'first',
25 defaultProps : { 30 defaultProps : {
26 children: 'children', 31 children: 'children',
@@ -44,9 +49,14 @@ export default { @@ -44,9 +49,14 @@ export default {
44 left: this.optionsStyle.left + "px", 49 left: this.optionsStyle.left + "px",
45 top: this.optionsStyle.top + "px", 50 top: this.optionsStyle.top + "px",
46 background: this.optionsSetup.background, 51 background: this.optionsSetup.background,
  52 +
  53 + };
  54 + },
  55 + treeLeftStyle(){
  56 + return{
47 'border':this.optionsSetup.isBorder?'0.5px solid '+this.optionsSetup.borderColor:'none', 57 'border':this.optionsSetup.isBorder?'0.5px solid '+this.optionsSetup.borderColor:'none',
48 'box-shadow':this.optionsSetup.isShadow?'0px 3px 12px '+this.optionsSetup.borderColor:'none' 58 'box-shadow':this.optionsSetup.isShadow?'0px 3px 12px '+this.optionsSetup.borderColor:'none'
49 - }; 59 + }
50 }, 60 },
51 //文字样式设置 61 //文字样式设置
52 textStyle(){ 62 textStyle(){
@@ -76,6 +86,7 @@ export default { @@ -76,6 +86,7 @@ export default {
76 this.optionsCollapse = this.value.collapse; 86 this.optionsCollapse = this.value.collapse;
77 this.optionsSetup = this.value.setup; 87 this.optionsSetup = this.value.setup;
78 this.editorOptions(); 88 this.editorOptions();
  89 + this.setSrc({id:1})
79 }, 90 },
80 mounted() { 91 mounted() {
81 92
@@ -86,8 +97,19 @@ export default { @@ -86,8 +97,19 @@ export default {
86 }, 97 },
87 handleNodeClick(data){ 98 handleNodeClick(data){
88 console.log(data); 99 console.log(data);
  100 + this.setSrc(data);
89 this.$store.commit('CHANGE_TREE',data) 101 this.$store.commit('CHANGE_TREE',data)
90 }, 102 },
  103 + setSrc(data){
  104 + let origin=window.location.origin;//当前域名
  105 + let srcName=origin+'/#/bigscreen/viewer?reportCode=';
  106 + if(data.id==1){
  107 + srcName+='service_capacity_analysis';
  108 + }else{
  109 + srcName+='capacity_analysis_second';
  110 + }
  111 + this.iframeSrc=srcName;
  112 + },
91 editorOptions() { 113 editorOptions() {
92 this.setOptionsData(); 114 this.setOptionsData();
93 }, 115 },
@@ -140,6 +162,14 @@ export default { @@ -140,6 +162,14 @@ export default {
140 <style scoped lang="scss"> 162 <style scoped lang="scss">
141 .treeContainer{ 163 .treeContainer{
142 padding:10px; 164 padding:10px;
  165 + display: flex;
  166 +}
  167 +.tree-left{
  168 + width:20%;
  169 + padding:10px;
  170 +}
  171 +.tree-content{
  172 + flex:1;
143 } 173 }
144 .tree-div{ 174 .tree-div{
145 height:100%; 175 height:100%;
  1 +<template>
  2 + <div :style="styleObj" class="treeContainer">
  3 + <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" v-if="optionsSetup.isType">
  4 + <el-tab-pane label="业务" name="first"></el-tab-pane>
  5 + <el-tab-pane label="资源" name="second"></el-tab-pane>
  6 + </el-tabs>
  7 + <el-tree :style="textStyle" class="tree-div" ref="roleTree" :data="treeData" :props="defaultProps" @node-click="handleNodeClick"
  8 + node-key="id" :default-checked-keys="checkedKeys"
  9 + />
  10 + </div>
  11 +</template>
  12 +
  13 +<script>
  14 +var per = 60;
  15 +export default {
  16 + name: "progressInformation",
  17 + components: {},
  18 + props: {
  19 + value: Object,
  20 + ispreview: Boolean
  21 + },
  22 + data() {
  23 + return {
  24 + activeName:'first',
  25 + defaultProps : {
  26 + children: 'children',
  27 + label: 'label',
  28 + },
  29 + treeData: [], // 所有的树结点
  30 + checkedKeys: [], // 当前选中的keys
  31 +
  32 + optionsStyle: {}, // 样式
  33 + optionsData: {}, // 数据
  34 + optionsCollapse: {}, // 图标属性
  35 + optionsSetup: {}
  36 + };
  37 + },
  38 + computed: {
  39 + styleObj() {
  40 + return {
  41 + position: this.ispreview ? "absolute" : "static",
  42 + width: this.optionsStyle.width + "px",
  43 + height: this.optionsStyle.height + "px",
  44 + left: this.optionsStyle.left + "px",
  45 + top: this.optionsStyle.top + "px",
  46 + background: this.optionsSetup.background,
  47 + 'border':this.optionsSetup.isBorder?'0.5px solid '+this.optionsSetup.borderColor:'none',
  48 + 'box-shadow':this.optionsSetup.isShadow?'0px 3px 12px '+this.optionsSetup.borderColor:'none'
  49 + };
  50 + },
  51 + //文字样式设置
  52 + textStyle(){
  53 + return{
  54 + 'text-align':this.optionsSetup.textAlign,
  55 + 'font-size':this.optionsSetup.titleFontSize+'px',
  56 + color: this.optionsSetup.titleColor,
  57 + 'font-weight': this.optionsSetup.titleFontWeight
  58 + }
  59 + }
  60 + },
  61 + watch: {
  62 + value: {
  63 + handler(val) {
  64 + this.optionsStyle = val.position;
  65 + this.optionsData = val.data;
  66 + this.optionsCollapse = val.collapse;
  67 + this.optionsSetup = val.setup;
  68 + this.editorOptions();
  69 + },
  70 + deep: true
  71 + }
  72 + },
  73 + created() {
  74 + this.optionsStyle = this.value.position;
  75 + this.optionsData = this.value.data;
  76 + this.optionsCollapse = this.value.collapse;
  77 + this.optionsSetup = this.value.setup;
  78 + this.editorOptions();
  79 + },
  80 + mounted() {
  81 +
  82 + },
  83 + methods: {
  84 + handleClick(tab,event){
  85 + this.handleTableData();
  86 + },
  87 + handleNodeClick(data){
  88 + console.log(data);
  89 + this.$store.commit('CHANGE_TREE',data)
  90 + },
  91 + editorOptions() {
  92 + this.setOptionsData();
  93 + },
  94 + //切换类型获取树结构数据
  95 + handleTableData() {
  96 + if (this.optionsData.dataType == "dynamicData" && this.optionsSetUp.isType) {
  97 + //改变参数值-类型
  98 + this.optionsData.dynamicData.contextData.type = this.activeName;
  99 + }
  100 + },
  101 + // 数据解析
  102 + setOptionsData() {
  103 + const optionsData = this.optionsData; // 数据类型 静态 or 动态
  104 + optionsData.dataType == "staticData"
  105 + ? this.staticDataFn(optionsData.staticData)
  106 + : this.dynamicDataFn(
  107 + optionsData.dynamicData,
  108 + optionsData.refreshTime
  109 + );
  110 + },
  111 + staticDataFn(val) {
  112 + if(val && val.length>0) {
  113 + this.treeData=val;
  114 + }
  115 +
  116 + },
  117 + dynamicDataFn(val, refreshTime) {
  118 + if (!val) return;
  119 + if (this.ispreview) {
  120 + this.getEchartData(val);
  121 + this.flagInter = setInterval(() => {
  122 + this.getEchartData(val);
  123 + }, refreshTime);
  124 + } else {
  125 + this.getEchartData(val);
  126 + }
  127 + },
  128 + getEchartData(val) {
  129 + const data = this.queryEchartsData(val);
  130 + data.then(res => {
  131 + if(res && res.length>0){
  132 + this.treeData=res;
  133 + }
  134 + });
  135 + },
  136 + }
  137 +};
  138 +</script>
  139 +
  140 +<style scoped lang="scss">
  141 +.treeContainer{
  142 + padding:10px;
  143 +}
  144 +.tree-div{
  145 + height:100%;
  146 + width:100%;
  147 +}
  148 +</style>