TenantAuthManager.vue
4.75 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<template>
<ht-sidebar-dialog
title="分配租户管理员"
:visible="dialogVisible"
width="1040px"
:before-close="handleClose"
close-on-click-modal
>
<ht-table
v-if="dialogVisible"
@load="loadData"
:data="data"
:pageResult="pageResult"
:selection="true"
:show-export="false"
:show-custom-column="false"
:default-querys="defualtQuerys"
:quick-search-props="[
{prop: 'u.fullname_', label: '姓名'},
{prop: 'u.account_', label: '账号'}
]"
ref="tenantAuthTable"
@selection-change="handleSelectionChange"
>
<template v-slot:toolbar>
<el-button-group>
<el-button
size="small"
type="primary"
@click="showUserDialog()"
icon="el-icon-plus"
>加入用户</el-button
>
<ht-delete-button
:url="roleDeleteUrl"
:htTable="$refs.tenantAuthTable"
pk="userId"
parameter="userIds"
:ignore-tenant="true"
:disabled="isDisabled"
>删除</ht-delete-button
>
</el-button-group>
</template>
<template>
<ht-table-column type="index" width="50" align="center" label="序号" />
<ht-table-column prop="id" label="主键" :sortable="true" hidden />
<ht-table-column
prop="userName"
label="用户名称"
width="300"
:sortable="true"
:show-overflow-tooltip="true"
/>
<ht-table-column prop="account" label="账号" :sortable="true" />
</template>
</ht-table>
<ht-user-dialog
ref="eipUserDialog"
@on-confirm="userDialogOnConfirm"
append-to-body
/>
</ht-sidebar-dialog>
</template>
<script>
import uc from '@/api/uc.js'
import EipUserDialog from '@/components/dialog/EipUserDialog.vue'
export default {
props: {},
components: {
EipUserDialog
},
computed: {
roleDeleteUrl: function() {
return `${window.context.uc}/uc/tenantAuth/v1/deleteTenantAuth?typeId=${this.tenantTypeId}`
}
},
data() {
return {
dialogVisible: false,
isSubmit: true,
data: [],
pageResult: {
page: 1,
pageSize: 50,
total: 0
},
defualtQuerys: [],
tenantTypeId: '',
tenantId: '',
selectedList: [],
isDisabled: true
}
},
watch: {
selectedList: {
handler(val) {
this.isDisabled = val.length < 1 ? true : false
},
deep: true
}
},
created() {},
methods: {
handleClose() {
this.dialogVisible = false
},
showDialog(tenantTypeId, tenantId) {
this.$store.dispatch('tenant/actionTenantId', null)
this.defualtQuerys = []
this.tenantTypeId = tenantTypeId
this.defualtQuerys.push({property: 'auth.TYPE_ID_', value: tenantTypeId})
if (tenantId) {
this.tenantId = tenantId
this.defualtQuerys.push({property: 'auth.TENANT_ID_', value: tenantId})
}
this.dialogVisible = true
},
dialogCancle() {
this.dialogVisible = false
},
loadData(param, cb) {
this.$http
.post('${uc}/uc/tenantAuth/v1/queryByTypeOrTenant', param)
.then(
resp => {
let response = resp.data
this.data = response.rows
this.pageResult = {
page: response.page,
pageSize: response.pageSize,
total: response.total
}
},
error => {
reject(error)
}
)
.finally(() => cb())
},
showUserDialog() {
this.$refs.eipUserDialog.showDialog()
},
userDialogOnConfirm(selection) {
if (!selection || selection.length == 0) {
this.$message.error('请至少选择一个用户')
return
}
let accounts = []
for (let user of selection) {
accounts.push(user.account)
}
let param = {}
param.typeId = this.tenantTypeId
param.tenantId = this.tenantId
param.accounts = accounts.join(',')
this.$http
.post('${uc}/uc/tenantAuth/v1/saveTenantAuth', param)
.then(result => {
if (result.data.state) {
this.$message({
message: result.data.message,
type: 'success',
showClose: true
})
this.$refs.tenantAuthTable.load()
return
}
this.$message.error(result.data.message || '设置管理员失败')
})
},
handleSelectionChange(selection) {
this.selectedList = selection
}
}
}
</script>
<style scoped>
div[aria-invalid='true'] >>> .el-input__inner,
div[aria-invalid='true'] >>> .el-input__inner:focus {
border-color: #f56c6c;
}
</style>