列表数据,单列自定义显示内容

This commit is contained in:
xing 2020-06-18 11:11:35 +08:00
parent 1b7f38b5d8
commit f1cb71044c
2 changed files with 60 additions and 1 deletions

View File

@ -11,3 +11,8 @@ html,body,#app{
.el-card { .el-card {
box-shadow: 0 1px 1px rgba(0,0,0, .15) !important; box-shadow: 0 1px 1px rgba(0,0,0, .15) !important;
} }
.el-table {
margin-top: 15px;
font-size: 15px;
}

View File

@ -18,14 +18,68 @@
<el-button type="primary">添加用户</el-button> <el-button type="primary">添加用户</el-button>
</el-col> </el-col>
</el-row> </el-row>
<!--列表table-->
<el-table border stripe :data="userList" style="width: 100%">
<el-table-column label="#" type="index"></el-table-column>
<el-table-column prop="username" label="姓名" width="180"></el-table-column>
<el-table-column prop="email" label="邮箱" width="180"></el-table-column>
<el-table-column prop="mobile" label="电话" width="100"></el-table-column>
<el-table-column prop="role_name" label="角色" width="100"></el-table-column>
<el-table-column width="100" label="状态" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.mg_state" @change="changeState">
</el-switch>
</template>
</el-table-column>
<el-table-column label="操作" >
<template >
<el-button size="mini" type="primary" icon="el-icon-edit"></el-button>
<el-button size="mini" type="danger" icon="el-icon-delete"></el-button>
<el-tooltip effect="dark" content="分配角色" placement="top" :enterable="false">
<el-button size="mini" type="warning" icon="el-icon-setting"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'users' data () {
return {
queryInfo: {
query: '',
pagenum: 1,
pagesize: 10
},
userList: [],
total: 0
}
},
methods: {
changeState (state) {
console.log(state)
},
async getUserList () {
const { data: res } = await this.$http.get('users', {
params: this.queryInfo
})
if (res.meta.status !== 200) {
return this.$message.error(res.meta.msg)
}
this.userList = res.data.users
this.total = res.data.total
}
},
created () {
this.getUserList()
}
} }
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>