console
new Vue({
el: '#app',
data: {
show: !false,
tableData: [],
expandKeys: ['0', '1']
},
computed: {
calcDisable() {
return (obj, child) => {
return obj.childCheckedNum === 1 && child.checked;
};
}
},
watch: {},
mounted() {
// console.log('mounted!');
this.fetchTableData();
},
methods: {
// 获取表格数据
fetchTableData() {
let res = [{ "orgNo": "21102", "orgName": "国网辽宁电力", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21401", "orgName": "国网沈阳供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21402", "orgName": "国网鞍山供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21404", "orgName": "国网抚顺供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21405", "orgName": "国网本溪供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21406", "orgName": "国网营口供电公司 ", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21407", "orgName": "国网阜新供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21409", "orgName": "国网朝阳供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21410", "orgName": "国网丹东供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21411", "orgName": "国网铁岭供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }, { "orgNo": "21412", "orgName": "国网辽阳供电公司", "operId": null, "operName": null, "tgNo": null, "tgName": null, "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0, "list": [{ "idxNo": "JYGK21102030200000006", "idxName": "采集异常工单超期", "warningThreshold": null, "supThreshold": null, "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102030200000007", "idxName": "计量异常工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }, { "idxNo": "JYGK21102040200000001", "idxName": "线损督办工单超期", "warningThreshold": "距离完成期限:15日", "supThreshold": "完成期限:5日", "warningTotal": 0, "warningNum": 0, "releasedNum": 0, "comSupNum": 0, "supTotal": 0, "underSupNum": 0, "processedNum": 0 }] }];
res.forEach((item, index) => {
item.index = index === 0 ? 'back' : index;
item.id = '' + index;
item.isOrg = true;
item.list.forEach((it, idx) => {
it.pid = item.id;
it.id = '' + index + 1 + idx;
it.orgName = it.idxName;
if (index === 0) {
it.isHeaderChild = true;
}
});
item.children = item.list;
});
// console.log('res: ', res);
this.tableData = res;
// console.log('---->', this.tableData);
}
}
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<p>element 树形表格默认控制展开折叠的按钮在第一列。通过为 <el-table-column type="undefined"> 添加`type="undefined"`,可以控制展开折叠按钮所在列。</p>
<p>效果:</p>
<div class="main-box">
<div class="mycard">
<div class="table-box">
<div class="tree-head">
<el-table :data="tableData" style="width: 100%; margin-bottom: 20px" row-key="id" :expand-row-keys="expandKeys" border stripe
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column label="序号" prop="index" type="undefined" align="center">
<template slot-scope="scope">
<span>{{scope.row.index}}</span>
</template>
</el-table-column>
<el-table-column label="供电公司" width="320" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.isOrg && scope.row.index !== 'back' && !scope.row.tgNo" class="link">{{ scope.row.orgName }}</span>
<template v-else>
<span v-if="scope.row.children && scope.row.children.length">{{ scope.row.orgName }}</span>
<span v-else-if="scope.row.isHeaderChild" style="margin-left: -24px">{{ scope.row.orgName }}</span>
<span v-else>{{ scope.row.orgName }}</span>
</template>
</template>
</el-table-column>
<el-table-column label="预警阈值" width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{scope.row.warningThreshold || '-'}}</span>
</template>
</el-table-column>
<el-table-column label="督办阈值" width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{scope.row.supThreshold || '-'}}</span>
</template>
</el-table-column>
<el-table-column label="预警工单数">
<el-table-column label="总数" prop="warningTotal"></el-table-column>
<el-table-column label="预警中" prop="warningNum"></el-table-column>
<el-table-column label="已解除" prop="releasedNum"></el-table-column>
<el-table-column label="已督办" prop="comSupNum"></el-table-column>
</el-table-column>
<el-table-column label="督办工单数">
<el-table-column label="总数" prop="supTotal"></el-table-column>
<el-table-column label="督办中" prop="underSupNum"></el-table-column>
<el-table-column label="已处理" prop="processedNum"></el-table-column>
</el-table-column>
</el-table>
</div>
</div>
</div>
</div>
<p>
<a href="https://jsrun.net/2iUKp/edit">查看代码</a>
</p>
</div>
</body>
</html>
body {
background: rgba(200, 200, 200, .1);
}
.flex-row-bw {
display: flex;
justify-content: space-between;
align-content: center;
}
.panel {
height: auto;
height: 100vh;
}
.main-box {
display: flex;
}
.main-box .left {
width: 260px;
padding: 10px 12px;
/* border: 1px solid red; */
}
.main-box .right {
width: calc(100% - 260px - 12px);
}
.table-box {
padding: 24px 12px;
}
.tree-table {
min-height: 500px;
/* height: 500px; */
}
.el-table .el-table__body .el-table__row td:nth-child(2) {
padding-left: 24px;
}
.el-table .el-table__body .el-table__row:first-child td:nth-child(2) {
padding-left: 0;
}
.link {
cursor: pointer;
text-decoration: underline;
}