main.vue
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!-- -->
<template>
<div>
<gl-dialog :title="userDetailTitle" :visible.sync="userDetailVisible" :before-close="handleClose">
<gl-table :table="tableParam"></gl-table>
<gl-pagination
background
v-show="flagRoleOrUser"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-size="pageSize"
layout="total, prev, pager, next"
:total="total">
</gl-pagination>
</gl-dialog>
</div>
</template>
<script>
import { selectUserRoleByRoleId } from '@/api/api'
export default {
name: 'UserDetail',
props: {
userDetailTitle: String,
userDetailVisible: Boolean,
apiParam: [Object, Function],
flagRoleOrUser: [Boolean, Function],
columnParam: Array,
consoleParam: [Array, Object]
},
watch: {
columnParam(val) {
this.tableParam.column = val
},
consoleParam(val) {
this.tableParam.console = val
},
apiParam(val) {
this.id = val.id
this.id && this.callApi()
}
},
data() {
return {
pageNum: 1,
pageSize: 5,
total: 10,
id: Number,
tableParam: {
border: true,
align: 'center',
data: [],
column: [],
console: []
}
}
},
methods: {
getRoleParams() {
return {
pageSize: this.pageSize,
pageNum: this.pageNum,
roleId: this.id
}
},
// 获取角色的相关用户详细信息
selectUser() {
const params = this.getRoleParams()
selectUserRoleByRoleId.req(params).then(res => {
this.total = res.total
this.tableParam.data = res.list
}).catch(err => {
console.log(err)
})
},
callApi() {
this.flagRoleOrUser && this.selectUser()
!this.flagRoleOrUser && (this.tableParam.data = [this.apiParam])
},
handleClose() {
this.$emit('userDetailClose')
},
handleCurrentChange(val) {
this.pageNum = val
this.callApi()
}
}
}
</script>
<style scoped>
</style>