效果图:
点击
显示
前端代码
<el-table v-loading="loading" :data="clientList" @selection-change="handleSelectionChange"
:default-sort="{prop: 'createTime', order: 'descending'}">
<el-table-column type="selection" width="55" align="center" show-overflow-tooltip/>
<el-table-column :label="columns[0].label" align="center" prop="id" v-if="columns[0].visible" show-overflow-tooltip/>
<el-table-column :label="columns[1].label" align="center" prop="clientName" v-if="columns[1].visible" show-overflow-tooltip/>
<el-table-column :label="columns[2].label" align="center" prop="clientAge"v-if="columns[2].visible" show-overflow-tooltip/>
<el-table-column :label="columns[3].label" align="center" prop="clientSex" v-if="columns[3].visible"show-overflow-tooltip>
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_user_sex" :value="scope.row.clientSex"/>
</template>
</el-table-column>
<el-table-column :label="columns[4].label" align="center" prop="clientPhone" v-if="columns[4].visible" show-overflow-tooltip/>
<el-table-column :label="columns[5].label" align="center" prop="clientHeadPortrait" v-if="columns[5].visible" show-overflow-tooltip>
<template slot-scope="scope">
<image-preview :src="scope.row.clientHeadPortrait" :width="50" :height="50"></image-preview>
</template>
</el-table-column>
<el-table-column :label="columns[6].label" align="center" prop="createTime" v-if="columns[6].visible" sortable show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['personnel:client:edit']"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['personnel:client:remove']"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
js 的 data 中
// 列信息
columns: [
{key: 0, label: `编号`, visible: true},
{key: 1, label: `姓名`, visible: true},
{key: 2, label: `年龄`, visible: true},
{key: 3, label: `性别`, visible: true},
{key: 4, label: `手机号`, visible: true},
{key: 5, label: `头像`, visible: false},
{key: 6, label: `创建时间`, visible: true},
],