admin-fe/src/views/users/index.vue

68 lines
1.5 KiB
Vue
Raw Normal View History

2019-02-22 18:06:48 +00:00
<template>
<div class="users-container">
2019-02-24 22:31:05 +00:00
<h1>Users</h1>
<el-table
v-loading="loading"
:data="users"
style="width: 100%">
<el-table-column
prop="id"
label="ID"
width="100" />
<el-table-column
2019-02-26 19:50:25 +00:00
prop="nickname"
2019-02-24 22:31:05 +00:00
label="Name" />
2019-02-26 19:50:25 +00:00
<el-table-column
label="Status">
<template slot-scope="scope">
<el-tag :type="scope.row.deactivated ? 'danger' : 'success'">
{{ scope.row.deactivated ? 'deactivated' : 'active' }}
</el-tag>
</template>
</el-table-column>
2019-02-24 22:31:05 +00:00
<el-table-column
fixed="right"
2019-02-26 19:50:25 +00:00
label="Actions">
<template slot-scope="scope">
<el-button v-if="scope.row.deactivated" type="text" size="small" @click="handleDeactivate(scope.row)">Activate</el-button>
<el-button v-else type="text" size="small" @click="handleDeactivate(scope.row)">Deactivate</el-button>
2019-02-24 22:31:05 +00:00
</template>
</el-table-column>
</el-table>
2019-02-22 18:06:48 +00:00
</div>
</template>
<script>
2019-02-23 21:40:26 +00:00
2019-02-22 18:06:48 +00:00
export default {
name: 'Users',
2019-02-24 22:31:05 +00:00
computed: {
loading() {
return this.$store.state.users.loading
},
users() {
return this.$store.state.users.fetchedUsers
2019-02-22 18:06:48 +00:00
}
2019-02-23 21:40:26 +00:00
},
mounted: function() {
this.$store.dispatch('FetchUsers')
2019-02-24 22:31:05 +00:00
},
methods: {
2019-02-26 19:50:25 +00:00
handleDeactivate({ nickname }) {
this.$store.dispatch('ToggleUserActivation', nickname)
2019-02-24 22:31:05 +00:00
}
2019-02-22 18:06:48 +00:00
}
}
2019-02-23 21:40:26 +00:00
2019-02-22 18:06:48 +00:00
</script>
2019-02-24 22:31:05 +00:00
<style rel="stylesheet/scss" lang="scss" scoped>
.users-container {
h1 {
margin-left: 15px;
}
}
</style>