结合element完成分列分级树形折叠分级表单
合并如图展示所示:
<template>
<div id="app">
<el-table
:data="tableData"
:span-method="spanTable"
border
:row-class-name="tableRowClassName"
fit
header-align="center"
:row-style="{padding:'0px'}"
:cell-style="{padding:'0px'}"
>
<template v-for="(column,key) in columns">
<el-table-column
v-if="column.span==true"
:key="key"
:prop="column.prop"
align="center"
:label="column.label"
>
<template slot-scope="scope">
<div v-if="scope.row[column.prop] && scope.row[column.prop]!=summaryFlag && scope.row[column.prop]!=otherColumnValue ">
<el-button
type="text"
size="mini"
@click="toggleRowData(spanColumn[key],scope.row)"
><i
v-if="getRowSpan(key,scope.row).oriSpan>1"
:class="toggleStatus(spanColumn[key],scope.row[column.prop])?'el-icon-circle-plus': 'el-icon-remove'"
></i>{
{
scope.row[column.prop]
}}
</el-button>
</div>
<div v-else>
{
{
scope.row[column.prop] }}
</div>
</template>
</el-table-column>
<el-table-column
v-else
:key="key"
:prop="column.prop"
align="center"
:label="column.label"
>
</el-table-column>
</template>
</el-table>
</div>
</template>
<script>
export default {
name: 'App',
props: {
salaryList: {
type: Array,
default() {
return []
}
}
},
data() {
return {
tableData: [], // 表格数据
otherColumnValue: '-',
columns: [
{
label: '一级单元(事业部)',
prop: 'first',
span: true
},
{
label: '二级单元(部门)',
prop: 'second',
span: true
},
{
label: '三级单元',
prop: 'third',
span: true
},
{
label: '人月总数',
prop: 'personelMonthTotal',
summary: true
},
{
label: '人月数',
prop: 'personelMonthCount',
summary: true
}
],
spanColumn: [], // 展开的行
rowSpanMaps: null,
existCache: {
},
toggleMap: null,
loadData: [ // 数据格式
{
first: '第一事业部',
secend: '第一支撑室',
thrid: 'it运维部',
identificationF: 1,
identificationS: 1,
identificationT: 1,
assessType: '1'