member.vue
6.62 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
<div>
<qg-search-form :data="searchConfig"/>
<section class="opt-bar">
<el-button type="primary" @click="handleAdd">新增</el-button>
<el-button @click="handleBatchDelete">删除</el-button>
</section>
<qg-table
ref="listTable"
:columns="tableColumns"
:param="listQuery"
:request="listRequest"
/>
<qg-user-selector
ref="userSelector"
title="授权人员"
:uc-ajax-prefix="ucAjaxPrefix"
:headers="headers"
:params="{
funId:entity.id,
funCode:'userRoleRel',
route:'userRoleRel',
appCode : CTX.UC.replace(/\//g,''), // appCode
optType : 'USER'
}"
@close="handleUserClose"
/>
</div>
</template>
<script>
import {userRoleRelPage, delUserRoleRel} from '@/api/moudles/uc/userRoleRel';
import {getToken} from '@/utils/auth';
import {CTX} from '@/api/config';
export default {
name: 'RoleMember',
components: {},
props: {
entity: {
type: Object,
default: null
}
},
data() {
const tableColumns = [
{
type: 'checkbox'
},
{
field: 'name',
text: '姓名',
minWidth: 100
},
{
field: 'loginName',
text: '用户名',
minWidth: 120
},
{
type: 'mobile',
field: 'mobile',
text: '手机号码',
minWidth: 120
},
{
field: 'opt',
fixed: 'right',
text: '操作',
width: 110,
render: (h, param) => {
if (param.row.code === 'admin') {
return '';
}
const optArr = [];
const delBtn = h('QgButton', {
props: {
toolTip: '删除',
type: 'text',
icon: 'el-icon-delete'
},
on: {
click: () => {
this.handleDelete(param.row);
}
}
});
optArr.push(delBtn);
return h('div', optArr, '');
}
}
];
return {
listRequest: userRoleRelPage,
tableColumns: tableColumns,
listQuery: {
roleIds: this.entity.id,
keyword: ''
},
CTX,
dgpDialogVisible: false,
headers: {Authorization: getToken()},
ucAjaxPrefix: process.env.VUE_APP_BASE_API + CTX.UC
};
},
watch: {
entity(val) {
if (!val) {
return;
}
this.listQuery.roleIds = val.id;
this.$refs.listTable.load(this.listQuery);
}
},
created() {
// 搜索表单配置
this.searchConfig = {
list: [
{
type: 'input',
label: '关键字',
model: 'keyword',
options: {
placeholder: '用户名/姓名/手机号码'
}
}
],
config: {
onSearch: data => {
this.handleSubmit();
},
model: this.listQuery
}
};
},
methods: {
handleDelete(row) {
this.delete('确认删除改用户吗?', {userIds: [row.id], roleId: this.entity.id});
},
delete(tips, param) {
// TODO confirm 再简化点
this.$confirm(tips, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delUserRoleRel(param).then(res => {
if (res.success) {
this.$message.success('删除成功');
this.$refs.listTable.load(this.listQuery);
} else {
this.$message.error('删除成功');
}
});
}).catch(() => {
});
},
handleSubmit() {
this.$refs.listTable.load(this.listQuery);
},
handleAdd() {
this.$refs.userSelector.open();
},
handleBatchDelete() {
console.log(ids, rows);
const {ids, rows} = this.$refs.listTable.getSelections();
if (!ids || ids.length === 0) {
this.$message.warning('请先选择操作对象');
return;
}
this.delete('确认删除改用户吗?', {userIds: ids, roleId: this.entity.id});
},
handleImport() {
this.$refs.importDialog.open();
},
handleExport() {
this.$notify.info({
title: '系统提示',
message: '导出任务正在后台执行,您可以离开本页面进行其他操作,稍后再回来下载。参考时间:5千人约5分钟;1万人约10分钟;2万人约20分钟。'
});
},
handleImportOk(result) {
console.log(result);
},
nodeClick(data) {
this.listQuery.orgId = data.id;
this.$refs.listTable.load(this.listQuery);
},
includeChildChange(flag) {
this.listQuery.includeChild = flag;
this.$refs.listTable.load(this.listQuery);
},
handleUserClose() {
this.$refs.listTable.load(this.listQuery);
}
}
};
</script>