Authored by 鲁尚清

详情表格组件功能完善-列支持将内容转成图标或图片

@@ -361,3 +361,17 @@ a:hover { @@ -361,3 +361,17 @@ a:hover {
361 border-color: rgba(249, 32, 32, 0.2); 361 border-color: rgba(249, 32, 32, 0.2);
362 color: rgb(249, 32, 32); 362 color: rgb(249, 32, 32);
363 } 363 }
  364 +/*列将内容转换成图标*/
  365 +.small-icon {
  366 + width: 22px;
  367 + height: 22px;
  368 + display: block;
  369 +}
  370 +.small-icon.small-icon-msg {
  371 + background: url('../images/monitor/icon-msg.png') no-repeat center;
  372 + background-size: contain;
  373 +}
  374 +.small-icon.small-icon-wechat {
  375 + background: url('../images/monitor/icon-wechat.png') no-repeat center;
  376 + background-size: contain;
  377 +}
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 width="30%" 36 width="30%"
37 :before-close="handleClose" 37 :before-close="handleClose"
38 > 38 >
39 - <el-form :model="rowFormData" label-width="60px"> 39 + <el-form :model="rowFormData" label-width="70px">
40 <el-form-item label="名称:"> 40 <el-form-item label="名称:">
41 <el-input 41 <el-input
42 v-model.trim="rowFormData['name']" 42 v-model.trim="rowFormData['name']"
@@ -76,6 +76,17 @@ @@ -76,6 +76,17 @@
76 controls-position="right" 76 controls-position="right"
77 /> 77 />
78 </el-form-item> 78 </el-form-item>
  79 + <el-form-item label="关联组件:">
  80 + <el-select v-model.trim="rowFormData['componentName']" size="small">
  81 + <el-option
  82 + v-for="item in componentNameData"
  83 + :key="item.value"
  84 + :label="item.label"
  85 + :value="item.value"
  86 + >
  87 + </el-option>
  88 + </el-select>
  89 + </el-form-item>
79 </el-form> 90 </el-form>
80 <span slot="footer" class="dialog-footer"> 91 <span slot="footer" class="dialog-footer">
81 <el-button size="mini" @click="editDialogVisible = false">取 消</el-button> 92 <el-button size="mini" @click="editDialogVisible = false">取 消</el-button>
@@ -160,12 +171,27 @@ export default { @@ -160,12 +171,27 @@ export default {
160 width: "", 171 width: "",
161 sort:false, 172 sort:false,
162 columnSort:0, 173 columnSort:0,
  174 + componentName:1
163 }, 175 },
164 flag: true, // true 新增, false 编辑 176 flag: true, // true 新增, false 编辑
165 indexEditor: -1, // 编辑第几个数据 177 indexEditor: -1, // 编辑第几个数据
166 tableData: [], 178 tableData: [],
167 multipleSelection:[], 179 multipleSelection:[],
168 editDialogVisible:false,//编辑列 180 editDialogVisible:false,//编辑列
  181 + componentNameData:[
  182 + {
  183 + label:'正常内容',
  184 + value:1
  185 + },
  186 + {
  187 + label:'微信图标',
  188 + value:'textToImage'
  189 + },
  190 + {
  191 + label: '级别背景',
  192 + value:'textToBg'
  193 + }
  194 + ],//关联组件
169 }; 195 };
170 }, 196 },
171 methods: { 197 methods: {
@@ -257,7 +283,7 @@ export default { @@ -257,7 +283,7 @@ export default {
257 // this.formData.push(this.rowFormData); 283 // this.formData.push(this.rowFormData);
258 let arr=[] 284 let arr=[]
259 this.multipleSelection.map((item,index)=>{ 285 this.multipleSelection.map((item,index)=>{
260 - arr.push({name:item.kpiName,key:item.kpiId,width:'50%',sort:false,columnSort:index}) 286 + arr.push({name:item.kpiName,key:item.kpiId,width:'50%',sort:false,columnSort:index,componentName:1})
261 }) 287 })
262 this.formData=arr; 288 this.formData=arr;
263 this.dialogVisible = false; 289 this.dialogVisible = false;
  1 +<template>
  2 + <div class="text-bg-div">
  3 + <div :class="['table-level-normal',{'table-level-worse':alarmLevel=='2','table-level-worst':alarmLevel=='3'}]">
  4 + {{levelName}}
  5 + </div>
  6 +
  7 + </div>
  8 +</template>
  9 +
  10 +<script>
  11 +export default {
  12 + name: "textToBg",
  13 + data() {
  14 + return {
  15 + levelName:'一般'
  16 + }
  17 + },
  18 + components: {},
  19 + props: {
  20 + alarmLevel: String,
  21 + },
  22 + computed: {},
  23 + mounted() {
  24 + this.getLeveName();
  25 + },
  26 + methods: {
  27 + getLeveName(){
  28 + if(this.alarmLevel=='1'){
  29 + this.levelName='一般'
  30 + }else if(this.alarmLevel=='2'){
  31 + this.levelName='重要'
  32 + }else if(this.alarmLevel=='3'){
  33 + this.levelName='严重'
  34 + }else{
  35 + this.levelName='一般'
  36 + }
  37 + }
  38 + }
  39 +}
  40 +</script>
  41 +
  42 +<style lang="scss" scoped>
  43 +.text-bg-div{
  44 + width:80%;
  45 +}
  46 +.table-level-normal {
  47 + min-width: 28px;
  48 + line-height: 28px;
  49 + width:100%;
  50 + display: inline-block;
  51 + padding: 0 3px;
  52 + color: #fff;
  53 + background-color: #1e9fff
  54 +}
  55 +.table-level-worse {
  56 + background-color: #FF7E00;
  57 +}
  58 +.table-level-worst {
  59 + background-color: #D81E06;
  60 +}
  61 +</style>
  1 +<template>
  2 + <div>
  3 + <div :class="['small-icon',{'small-icon-wechat':way=='','small-icon-msg':way=='message'}]"></div>
  4 +
  5 + </div>
  6 +</template>
  7 +
  8 +<script>
  9 +export default {
  10 + name: "textToImage",
  11 + data() {
  12 + return {
  13 + }
  14 + },
  15 + components: {},
  16 + props: {
  17 + way: String,
  18 + },
  19 + computed: {},
  20 + mounted() {},
  21 + methods: {}
  22 +}
  23 +</script>
  24 +
  25 +<style lang="scss" scoped>
  26 +
  27 +</style>
@@ -399,11 +399,11 @@ export const monitorDetailTable = { @@ -399,11 +399,11 @@ export const monitorDetailTable = {
399 chartType:'detail-table', 399 chartType:'detail-table',
400 placeholder: '', 400 placeholder: '',
401 value: [ 401 value: [
402 - {name: '文件系统挂载', key: 'KPI7AC1664E', width: '50%',isStatic:true,columnSort:0},  
403 - {name: '文件系统使用率', key: 'KPI449F5365', width: '50%',isStatic:true,columnSort:1},  
404 - {name: '文件系统总大小', key: 'KPIA91F44E7', width: '50%',isStatic:true,columnSort:2},  
405 - {name: '文件系统已使用大小', key: 'KPI98306224', width: '50%',isStatic:true,columnSort:3},  
406 - {name: '卷名称', key: 'KPI77C28BBA', width: '50%',isStatic:true,columnSort:4}, 402 + {name: '文件系统挂载', key: 'KPI7AC1664E', width: '50%',isStatic:true,columnSort:0,componentName:1},
  403 + {name: '文件系统使用率', key: 'KPI449F5365', width: '50%',isStatic:true,columnSort:1,componentName:1},
  404 + {name: '文件系统总大小', key: 'KPIA91F44E7', width: '50%',isStatic:true,columnSort:2,componentName:1},
  405 + {name: '文件系统已使用大小', key: 'KPI98306224', width: '50%',isStatic:true,columnSort:3,componentName:1},
  406 + {name: '卷名称', key: 'KPI77C28BBA', width: '50%',isStatic:true,columnSort:4,componentName:1},
407 ] 407 ]
408 } 408 }
409 ], 409 ],
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 :ref="'headerRef'+index+'-'+idx" 39 :ref="'headerRef'+index+'-'+idx"
40 :data-tip="tableFiledMaxWidth('isOverflow'+index+'-'+idx,index,idx)" 40 :data-tip="tableFiledMaxWidth('isOverflow'+index+'-'+idx,index,idx)"
41 > 41 >
42 - <el-tooltip :disabled="isEllipsis[index+'-'+idx]" ref="elTooltip" trigger="hover" > 42 + <el-tooltip v-if="!itemChild.componentName || itemChild.componentName==1" :disabled="isEllipsis[index+'-'+idx]" ref="elTooltip" trigger="hover" >
43 <template #content> 43 <template #content>
44 <span>{{ item[itemChild.key].kpiValue}}</span> 44 <span>{{ item[itemChild.key].kpiValue}}</span>
45 </template> 45 </template>
@@ -48,6 +48,7 @@ @@ -48,6 +48,7 @@
48 {{ item[itemChild.key].kpiValue}} 48 {{ item[itemChild.key].kpiValue}}
49 </span> 49 </span>
50 </el-tooltip> 50 </el-tooltip>
  51 + <component v-if="itemChild.componentName && itemChild.componentName!=1" :is="itemChild.componentName" :alarmLevel="item[itemChild.key].alarmLevel?item[itemChild.key].alarmLevel:'2'" :way="item[itemChild.key].way?item[itemChild.key].way:'message'" />
51 52
52 <customMenuBox ref="customMenu" v-if="pressingVisible==index+'-'+idx && item[itemChild.key] && (item[itemChild.key].kpiIdent==1 || item[itemChild.key].isWarning==1)" 53 <customMenuBox ref="customMenu" v-if="pressingVisible==index+'-'+idx && item[itemChild.key] && (item[itemChild.key].kpiIdent==1 || item[itemChild.key].isWarning==1)"
53 :detailMenubox="calcDetailMenubox" 54 :detailMenubox="calcDetailMenubox"
@@ -176,6 +177,8 @@ import VueSuperSlide from "vue-superslide"; @@ -176,6 +177,8 @@ import VueSuperSlide from "vue-superslide";
176 import {getDetailTableData,getDetailTableDataNoPage} from "@/api/platform"; 177 import {getDetailTableData,getDetailTableDataNoPage} from "@/api/platform";
177 import customDialog from "../../designerComponents/customDialog"; 178 import customDialog from "../../designerComponents/customDialog";
178 import customMenuBox from "../../designerComponents/customMenuBox";//下探组件 179 import customMenuBox from "../../designerComponents/customMenuBox";//下探组件
  180 +import textToImage from "../../designerComponents/textToImage";//文字转图片
  181 +import textToBg from "../../designerComponents/textToBg";//文字转背景
179 182
180 vue.use(VueSuperSlide); 183 vue.use(VueSuperSlide);
181 export default { 184 export default {
@@ -184,7 +187,7 @@ export default { @@ -184,7 +187,7 @@ export default {
184 ispreview: Boolean 187 ispreview: Boolean
185 }, 188 },
186 components:{ 189 components:{
187 - customDialog,customMenuBox 190 + customDialog,customMenuBox,textToImage,textToBg
188 }, 191 },
189 data() { 192 data() {
190 return { 193 return {
@@ -258,6 +261,7 @@ export default { @@ -258,6 +261,7 @@ export default {
258 sortBy:'',//排序参数 261 sortBy:'',//排序参数
259 sortCaret:'',//正序倒序 262 sortCaret:'',//正序倒序
260 isEllipsis:[],//是否文字超出 263 isEllipsis:[],//是否文字超出
  264 + componentName:'',//组件名称
261 }; 265 };
262 }, 266 },
263 computed: { 267 computed: {
@@ -652,9 +656,12 @@ export default { @@ -652,9 +656,12 @@ export default {
652 let that=this; 656 let that=this;
653 this.$nextTick(() => { 657 this.$nextTick(() => {
654 let isOverflow=that.$refs[obj]; 658 let isOverflow=that.$refs[obj];
655 - let cWidth = isOverflow[0].parentElement.scrollWidth;//.scrollWidth; 659 + if(isOverflow && isOverflow[0]){
  660 + let cWidth = isOverflow[0].parentElement.scrollWidth;
656 let sWidth = isOverflow[0].scrollWidth; 661 let sWidth = isOverflow[0].scrollWidth;
657 that.isEllipsis[index+'-'+idx]=!((sWidth+10) > cWidth); 662 that.isEllipsis[index+'-'+idx]=!((sWidth+10) > cWidth);
  663 + }
  664 +
658 }) 665 })
659 }, 666 },
660 //列是否排序 667 //列是否排序
@@ -673,6 +680,7 @@ export default { @@ -673,6 +680,7 @@ export default {
673 if(item.key==v.key){ 680 if(item.key==v.key){
674 v.columnSort=item.columnSort; 681 v.columnSort=item.columnSort;
675 v.sort=item.sort?item.sort:false; 682 v.sort=item.sort?item.sort:false;
  683 + v.componentName=item.componentName?item.componentName:1;
676 } 684 }
677 }) 685 })
678 if(this.headerAll && this.headerAll.length>0){ 686 if(this.headerAll && this.headerAll.length>0){
@@ -680,6 +688,7 @@ export default { @@ -680,6 +688,7 @@ export default {
680 if(item.key==v.key){ 688 if(item.key==v.key){
681 v.columnSort=item.columnSort; 689 v.columnSort=item.columnSort;
682 v.sort=item.sort?item.sort:false; 690 v.sort=item.sort?item.sort:false;
  691 + v.componentName=item.componentName?item.componentName:1;
683 } 692 }
684 }) 693 })
685 } 694 }
@@ -821,6 +830,9 @@ export default { @@ -821,6 +830,9 @@ export default {
821 //下载 830 //下载
822 downloadTableList(title, resId, kpiId, flagPrifix, sortBy, order){ 831 downloadTableList(title, resId, kpiId, flagPrifix, sortBy, order){
823 let kpiIdArr=[]; 832 let kpiIdArr=[];
  833 + let param={
  834 + sortBy:this.sortBy
  835 + }
824 this.header.map(item=>{ 836 this.header.map(item=>{
825 if(item.sort){ 837 if(item.sort){
826 kpiIdArr.push(item.key) 838 kpiIdArr.push(item.key)