Authored by 王涛

Merge branch 'master-ajreport-lushangqing' into 'master'

详情表格组件功能完善-序号,排序,列宽,顺序调整,更多分页



See merge request !12
... ... @@ -7,24 +7,83 @@
@click="handleAddClick"
>配置表头</el-button
>
<!-- <el-table :data="formData" style="width: 100%">
<el-table :data="formData" style="width: 100%">
<el-table-column prop="name" label="名称" width="60" />
<el-table-column prop="key" label="key值" width="70" />
<el-table-column prop="width" label="宽度" width="50" />
<el-table-column label="操作" width="100">
<template slot-scope="scope">
<div class="button-group">
<el-button
<el-button
@click="handleEditorClick(scope.$index, scope.row)"
type="text"
size="small"
>编辑</el-button
>
<!-- <el-button
type="text"
size="small"
@click="handleDeleteClick(scope.$index, scope.row)"
>删除</el-button
>
>-->
</div>
</template>
</el-table-column>
</el-table>-->
</el-table>
<el-dialog
title="编辑列"
:visible.sync="editDialogVisible"
width="30%"
:before-close="handleClose"
>
<el-form :model="rowFormData" label-width="60px">
<el-form-item label="名称:">
<el-input
v-model.trim="rowFormData['name']"
placeholder="请输入名称"
size="mini"
disabled
>
</el-input>
</el-form-item>
<el-form-item label="key值:">
<el-input
v-model.trim="rowFormData['key']"
placeholder="请输入key值"
size="mini"
disabled
>
</el-input>
</el-form-item>
<el-form-item label="宽度:">
<el-input
v-model.trim="rowFormData['width']"
placeholder="请输入宽度"
size="mini"
>
</el-input>
</el-form-item>
<el-form-item label="排序:">
<el-switch size="mini" v-model.trim="rowFormData['sort']" />
</el-form-item>
<el-form-item label="列排序:">
<el-input-number
v-model.trim="rowFormData['columnSort']"
:min="0"
:max="50"
size="small"
controls-position="right"
/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="editDialogVisible = false">取 消</el-button>
<el-button size="mini" type="primary" @click="handleSaveClick"
>确 定</el-button
>
</span>
</el-dialog>
<el-dialog
title="性能指标"
:visible.sync="dialogVisible"
... ... @@ -98,12 +157,15 @@ export default {
rowFormData: {
name: "",
key: "",
width: ""
width: "",
sort:false,
columnSort:0,
},
flag: true, // true 新增, false 编辑
indexEditor: -1, // 编辑第几个数据
tableData: [],
multipleSelection:[]
multipleSelection:[],
editDialogVisible:false,//编辑列
};
},
methods: {
... ... @@ -182,7 +244,7 @@ export default {
this.flag = false;
this.rowFormData = this.deepClone(row);
this.indexEditor = index;
this.dialogVisible = true;
this.editDialogVisible = true;
},
// 关闭
handleClose() {
... ... @@ -194,8 +256,8 @@ export default {
// 新增
// this.formData.push(this.rowFormData);
let arr=[]
this.multipleSelection.map(item=>{
arr.push({name:item.kpiName,key:item.kpiId,width:'50%'})
this.multipleSelection.map((item,index)=>{
arr.push({name:item.kpiName,key:item.kpiId,width:'50%',sort:false,columnSort:index})
})
this.formData=arr;
console.log("formadata",this.formData)
... ... @@ -204,7 +266,7 @@ export default {
// 编辑
this.formData[this.indexEditor] = this.rowFormData;
this.$set(this.formData, this.indexEditor, this.rowFormData);
this.dialogVisible = false;
this.editDialogVisible = false;
}
this.$emit("input", this.formData);
this.$emit("change", this.formData);
... ...
... ... @@ -104,7 +104,7 @@ export default {
width:100%;
padding: 10px;
margin-bottom:50px;
min-height: 500px;
min-height: 600px;
max-height: 700px;
overflow: auto;
iframe{
... ...
... ... @@ -265,6 +265,14 @@ export const monitorDetailTable = {
value: true,
},
{
type: 'el-switch',
label: '序号',
name: 'isSerialNumber',
required: false,
placeholder: '',
value: false,
},
{
type: 'vue-color',
label: '表头颜色',
name: 'headColor',
... ... @@ -328,11 +336,11 @@ export const monitorDetailTable = {
chartType:'detail-table',
placeholder: '',
value: [
{name: '文件系统挂载', key: 'KPI7AC1664E', width: '50%',isStatic:true},
{name: '文件系统使用率', key: 'KPI449F5365', width: '50%',isStatic:true},
{name: '文件系统总大小', key: 'KPIA91F44E7', width: '50%',isStatic:true},
{name: '文件系统已使用大小', key: 'KPI98306224', width: '50%',isStatic:true},
{name: '卷名称', key: 'KPI77C28BBA', width: '50%',isStatic:true},
{name: '文件系统挂载', key: 'KPI7AC1664E', width: '50%',isStatic:true,columnSort:0},
{name: '文件系统使用率', key: 'KPI449F5365', width: '50%',isStatic:true,columnSort:1},
{name: '文件系统总大小', key: 'KPIA91F44E7', width: '50%',isStatic:true,columnSort:2},
{name: '文件系统已使用大小', key: 'KPI98306224', width: '50%',isStatic:true,columnSort:3},
{name: '卷名称', key: 'KPI77C28BBA', width: '50%',isStatic:true,columnSort:4},
]
}
],
... ...
... ... @@ -10,18 +10,27 @@
<superslide v-if="hackReset" :options="options" class="txtScroll-top" :style="borderStyle">
<!--表头-->
<div class="title">
<div :style="[headerTableStlye,tableRowHeight(),serialNumber]">序号</div>
<div
v-for="(item, index) in header"
:style="[headerTableStlye,tableFiledWidth(index),tableRowHeight()]"
:key="index"
:class="{'ascending':(sortBy==item.key && sortCaret=='ascending'),'descending':(sortBy==item.key && sortCaret=='descending')}"
>
{{ item.name }}
<!-- <i v-if="tableFiledSort(index)" :class="['cursorClass',{'el-icon-caret-bottom':(sortBy==item.key && sortVal=='bottom'),'el-icon-caret-top':(sortBy==item.key && sortVal=='top')}]" @click="changeSort(item)"></i>-->
<span v-if="tableFiledSort(index)" class="caret-wrapper">
<i class="sort-caret ascending" @click="changeSort(item,'ascending')"></i>
<i class="sort-caret descending" @click="changeSort(item,'descending')"></i>
</span>
</div>
</div>
<!--数据-->
<div class="bd">
<ul class="infoList">
<li v-for="(item, index) in list" :key="index" :style="tableRowHeight()" @mouseenter="isHover=true" @mouseleave="isHover=false" >
<div class="infoList-flex" :style="[bodyTableStyle, bodyTable(index),tableFiledWidth(index),tableRowHeight(),serialNumber]">
{{ index+1 }}</div>
<div class="infoList-flex"
v-for="(itemChild, idx) in header"
:key="idx"
... ... @@ -40,7 +49,7 @@
<customMenuBox v-if="pressingVisible==index+'-'+idx && item[itemChild.key] && (item[itemChild.key].kpiIdent==1 || item[itemChild.key].isWarning==1)"
:detailMenubox="calcDetailMenubox"
:tableDataValue="item[itemChild.key].kpiValue" :flg="''" :trendSrc="trendSrc"
:heightStyle="heightStyle" :marginStyle="marginStyle" :tableName="tableStyle.tableName"
:heightStyle="heightStyle" :marginStyle="marginStyle" :tableName="dialogNameStyle(item[itemChild.key])"
></customMenuBox>
<!-- <div class="info-ul" style="width:140px;" >
... ... @@ -63,18 +72,27 @@
<div v-if="hackReset" class="txtScroll-top" >
<!--表头-->
<div class="title" :style="borderStyle">
<div :style="[headerTableStlye,tableRowHeight(),serialNumber]">序号</div>
<div
v-for="(item, index) in headerAll"
:style="[headerTableStlye,tableFiledWidth(index),tableRowHeight()]"
:key="index"
:class="{'ascending':(sortBy==item.key && sortCaret=='ascending'),'descending':(sortBy==item.key && sortCaret=='descending')}"
>
{{ item.name }}
<!-- <i v-if="tableFiledSort(index)" :class="['cursorClass',{'el-icon-caret-bottom':sortVal=='bottom','el-icon-caret-top':sortVal=='top'}]" @click="changeSort(item)"></i>-->
<span v-if="tableFiledSort(index)" class="caret-wrapper">
<i class="sort-caret ascending" @click="changeSort(item,'ascending')"></i>
<i class="sort-caret descending" @click="changeSort(item,'descending')"></i>
</span>
</div>
</div>
<!--数据-->
<div class="bd">
<ul class="infoList" :style="borderStyle">
<li v-for="(item, index) in listAll" :key="index" :style="tableRowHeight()" @mouseenter="isHover=true" @mouseleave="isHover=false" >
<div class="infoList-flex" :style="[bodyTableStyle, bodyTable(index),tableFiledWidth(index),tableRowHeight(),serialNumber]">
{{ index+1 }}</div>
<div class="infoList-flex"
v-for="(itemChild, idx) in headerAll"
:key="idx"
... ... @@ -87,32 +105,32 @@
<customMenuBox v-if="pressingVisible==index+'-'+idx && item[itemChild.key] && (item[itemChild.key].kpiIdent==1 || item[itemChild.key].isWarning==1)"
:detailMenubox="calcDetailMenubox"
:tableDataValue="item[itemChild.key].kpiValue" :flg="''" :trendSrc="trendSrc"
:heightStyle="heightStyle" :marginStyle="marginStyle" :tableName="tableStyle.tableName"
:heightStyle="heightStyle" :marginStyle="marginStyle" :tableName="dialogNameStyle(item[itemChild.key])"
></customMenuBox>
<!-- <div class="basic-img" v-if="item[itemChild.key] && (item[itemChild.key].kpiIdent==1 || item[itemChild.key].isWarning==1)">
<el-popover ref="popoverMenu" placement="right" trigger="click" :auto-close="200">
<template #reference>
<img class="info-img" src="@/assets/images/healthStatus/icon_row_menu.png" alt="" @click.stop="pressingTimes(index,idx)">
</template>
<div class="info-ul" style="width:140px;" >
<div class="basic-pressing-times" @click="pressingDialog(itemMenu,item[itemChild.key].kpiValue,'dialog')" v-for="itemMenu in calcDetailMenubox">
<i class="el-icon-link icon-div"></i>{{itemMenu.name}}
</div>
</div>
</el-popover>
</div>-->
</div>
</li>
</ul>
</div>
<!-- 分页 -->
<div class="pageClass" style='text-align: left;background-color: white'>
<el-pagination
v-if="currentPage"
@size-change="handleSizeChange"
@prev-click="prePage"
@next-click="nextPage"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="pageSize"
:total="total">
</el-pagination>
</div>
</div>
</template>
</customDialog>
<!-- 直接点击表格数据展示 性能趋势弹框-->
<customDialog :dialogVisible="trendVisible" :heightStyle="heightStyle" :marginStyle="marginStyle" :widthStyle="widthStyle" :title-name="tableStyle.tableName"
<customDialog :dialogVisible="trendVisible" :heightStyle="heightStyle" :marginStyle="marginStyle" :widthStyle="widthStyle" :title-name="dialogName"
:showFooter="true" :showCancelBtn="true" :showOkBtn="true" @hideDialog="hideDialog" @okFunc="okFunc"
>
<template v-slot>
... ... @@ -174,6 +192,10 @@ export default {
},
data() {
return {
currentPage:1,
pageSize:10,
pageSizes:[10,50,100, 200, 300, 400],
total:0,
trendVisible:false,//性能趋势弹框
headerAll:[],
listAll:[],
... ... @@ -236,7 +258,9 @@ export default {
marginStyle:'',//弹框距离顶部距离
heightStyle:'',//弹框遮罩层高度
widthStyle:';',//弹框宽度样式
sortVal:'bottom',//排序方式
sortBy:'',//排序参数
sortCaret:'',//正序倒序
};
},
computed: {
... ... @@ -281,6 +305,13 @@ export default {
"border-bottom":'none',
};
},
serialNumber(){
const headStyle = this.optionsSetUp;
return{
width:'30%',
display:headStyle.isSerialNumber?"block":"none",
}
},
borderStyle(){
const bodyStyle = this.optionsSetUp;
return{
... ... @@ -485,8 +516,9 @@ export default {
this.list=datas;
this.header=colArr;
}
this.tableFiledColumnSort();
},
handlerDetailData(valData){
handlerDetailData(valData,sortBy){
let kpiArr=[]
let kpiIdStr='';
if(this.header && this.header.length>0){
... ... @@ -504,6 +536,10 @@ export default {
let param={
kpiId:kpiIdStr
}
let sort=sortBy;
if(sort){
param.sort=sort;
}
let headTable = valData;
if(kpiIdStr){
//根据kpiId集合获取表格数据
... ... @@ -522,19 +558,13 @@ export default {
// this.setDialog('table');
this.tableVisible=true;
},
//打开弹框
/*//打开弹框
setDialog(name,flg){
/* if(flg=='dialog'){
this.tableVisible=true;
}else{
}*/
this.dialogVisible=true;
this.dialogName=name;
},
},*/
//点击表格内容名称事件
clickListName(obj){
if(obj.kpiIdent==1 || obj.isWarning==1){
... ... @@ -544,6 +574,8 @@ export default {
this.widthStyle='';
// this.setDialog('performance_trends')
this.pressingValue=obj.kpiValue;
this.dialogNameStyle(obj)
this.trendVisible=true;
}
... ... @@ -616,11 +648,48 @@ export default {
tableFiledWidth(index){
var styleJson = {};
if(this.optionsSetUp.dynamicAddTable[index] && this.optionsSetUp.dynamicAddTable[index].width ){
styleJson["width"] = this.optionsSetUp.dynamicAddTable[index].width
styleJson["width"] = this.optionsSetUp.dynamicAddTable[index].width;
}
return styleJson
},
//表格下探
//列是否排序
tableFiledSort(index){
let isSort=false;
if(this.optionsSetUp.dynamicAddTable[index] && this.optionsSetUp.dynamicAddTable[index].sort ){
isSort = this.optionsSetUp.dynamicAddTable[index].sort;
}
return isSort;
},
//列展示的排序位置
tableFiledColumnSort(){
let headerSet=this.optionsSetUp.dynamicAddTable;
headerSet.map(item=>{
this.header.map(v=>{
if(item.key==v.key){
v.columnSort=item.columnSort;
}
})
if(this.headerAll && this.headerAll.length>0){
this.headerAll.map(v=>{
if(item.key==v.key){
v.columnSort=item.columnSort;
}
})
}
})
this.header.sort(this.compare('columnSort'))
this.headerAll.sort(this.compare('columnSort'))
console.log("&&&",this.header)
},
compare(property){
return function(a,b){
let value1 = a[property];
let value2 = b[property];
return value1 - value2;
}
},
/* //表格下探
pressingDialog(itemMenu,value,flg){
this.pressingValue=value;
let styleStr='width: 300px;height: 200px;min-height: 200px;overflow: hidden;'
... ... @@ -654,7 +723,7 @@ export default {
}
// this.$refs.popoverMenu.showPopper = false;
},
},*/
pressingTimes(index,idx){
this.pressingVisible=index+'-'+idx;
},
... ... @@ -675,12 +744,76 @@ export default {
okFuncTable(){
this.tableVisible=false;
}
},
//排序
changeSort(item,flg){
if(this.sortCaret==flg){
this.sortCaret='';
this.sortBy='';
}else{
this.sortCaret=flg;
this.sortBy=item.key;
}
if(this.sortCaret=='ascending'){
//正序
}else if(this.sortCaret=='ascending'){
//倒序
}else{
//不排序
}
console.log('sort',item.key)
// this.handlerDetailData('',item.key)
// this.handlerDetailDataNoPage();
},
// 每页展示多少条
handleSizeChange(val){
// 切换页码重置初始页
this.currentPage = 1
// console.log(`每页 ${val} 条`)
//props.pageSize = val;
this.pageSize = val;
this.handlerDetailDataNoPage();
},
// 切换页码
handleCurrentChange(val){
// console.log(`当前页: ${val}`)
//props.currentPage = val;
this.currentPage = val;
this.handlerDetailDataNoPage();
},
// 切换页码
prePage(val) {
// console.log(`当前页: ${val}`)
// props.currentPage = val - 1;
this.currentPage = val-1;
this.handlerDetailDataNoPage();
},
// 切换页码
nextPage(val){
// console.log(`当前页: ${val}`)
// props.currentPage = val + 1;
this.currentPage = val+1;
this.handlerDetailDataNoPage();
},
//计算弹框名称
dialogNameStyle(obj){
const tableStyleSetup=this.optionsSetUp;
let kpiName=obj.kpiName?'+'+obj.kpiName:'';
let dialogName=tableStyleSetup.tableName+kpiName;
this.dialogName=dialogName;
return dialogName;
},
}
};
</script>
<style lang="scss" scoped>
/* 本例子css */
.cursorClass{
cursor: pointer;
}
.txtScroll-top {
overflow: hidden;
position: relative;
... ... @@ -797,6 +930,11 @@ export default {
color:#0d82e9;
text-decoration: underline;
}
.pageClass{
position: absolute;
bottom:30px;
}
/*.dialog-div{
background: rgba(0, 0, 0, 0.35);
position: fixed;
... ... @@ -854,4 +992,36 @@ export default {
text-align: right;
}
}*/
.title .caret-wrapper {
display: inline-flex;
flex-direction: column;
align-items: center;
height: 14px;
width: 24px;
vertical-align: middle;
cursor: pointer;
overflow: initial;
position: relative;
}
.title .sort-caret {
width: 0;
height: 0;
border: solid 5px transparent;
position: absolute;
left: 7px;
}
.title .sort-caret.ascending {
border-bottom-color: #c0c4cc;
top: -5px;
}
.title .sort-caret.descending {
border-top-color: #c0c4cc;
bottom: -3px;
}
.title .ascending .sort-caret.ascending {
border-bottom-color: #409eff;
}
.title .descending .sort-caret.descending {
border-top-color: #409eff;
}
</style>
... ...