一、Table组件
1、封装Table组件为tableList.vue
文件如下:
<template>
<!-- 主列表 -->
<el-table :data='tableData' :height='tableHeight' :show-header='showHeader' stripe @expand-change="expandSelect" :expand-row-keys="expands" @cell-click="handleCellClick" empty-text='暂无数据' class='el_tab_alage' :header-cell-style="cellHeaderStyle" :row-key='getRowKeys' @selection-change="handleSelectionChange">
<!-- 单选框 -->
<el-table-column align="center" width="50" label="" v-if="tableSelection.key === true && tableSelection.type === 'radio'">
<template slot-scope="scope">
<el-radio :label="scope.$index" v-model="radio" @change="handleTemplateRow(scope.$index, scope.row)"> </el-radio>
</template>
</el-table-column>
<!-- index索引 -->
<el-table-column label="序号" type="index" width="50" align="center" v-if="tableSelection.key === true && tableSelection.type === 'index'"></el-table-column>
<!-- 多选框 -->
<el-table-column type="selection" width="50" align="center" v-if="tableSelection.key === true && tableSelection.type === 'selection'"></el-table-column>
<!-- 列表表头-->
<el-table-column type="expand" v-if="tableSelection.key === true && tableSelection.type === 'expand'">
<template slot-scope="scope">
<el-form label-position="left" inline class="demo-table-expand">
<el-form-item :label="index.label" v-for="(index, item) in tableLabel" :key='item' v-show="index.type === 'expand'">
<span>{
{
scope.row[index.list]}}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
<template v-for="(index, item) in tableLabel">
<el-table-column fit :align='index.tableAlign ? index.tableAlign : "center"' :key='item' :sortable='index.sort' v-if="index.type !== 'expand'" :label="index.label" :width="index.width" :show-overflow-tooltip="index.overflowShow === 'hidden' ? true : false" :prop="index.list">
<template slot-scope="scope">
<!-- 图片 -->
<template v-if="index.type === 'image'">
<el-image v-if="scope.row[index.list] !== ''" style="width: 100px; height: 50px;" :src="scope.row[index.list]">
</el-image>
<div v-else></div>
</template>
<!-- 头像 -->
<template v-else-if="index.type === 'head'">
<el-image v-if="!(scope.row[index.list] === '' || scope.row[index.list] === null)" style="width: 50px; height: 50px;" :src="scope.row[index.list]">
</el-image>
<div v-else></div>
</template>
<!-- 按钮 -->
<template v-else-if="index.type === 'btn'">
<el-button type="text" @click.native.prevent="index.method(scope.row, scope)">
<u>{
{
scope.row[index.list]}}</u>
</el-b