roleslistdiglog.vue
3.23 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
<template>
<Dialog
:title="title"
class="tableClass"
:show.sync="visible"
:width="'715px'"
@close="close()"
>
<template slot="content">
<lb-table
ref="multipleTable"
:pagination="false"
:column="tableData.column"
:data="tableData.data"
@selection-change="handleSelectionChange"
>
</lb-table>
</template>
<template slot="footer">
<el-button type="primary" class="save" @click="handleSaveMember()"
>保存</el-button
>
<el-button class="cancel-button" @click="close()">取消</el-button>
</template>
</Dialog>
</template>
<script>
import Dialog from "@/components/Dialog/";
import { updateUser } from "@/api/Rolemanagement";
export default {
name: "",
components: { Dialog },
data() {
return {
title: "人员配置",
visible: false,
hasSelectList: [
// {
// name: "管理员",
// loginName: "admin1",
// departmentName: "研发部",
// jobLevel: null,
// },
// {
// name: "测试账号",
// loginName: "admin2",
// departmentName: "研发部",
// jobLevel: null,
// },
], //已经选择的id组成的数组
tableData: {
column: [
{
type: "selection",
},
{
prop: "name",
label: "姓名",
},
{
prop: "loginName",
label: "用户名",
},
{
prop: "departmentName",
label: "部门",
},
{
prop: "jobLevel",
label: "职务",
},
],
data: [],
// 角色id
roleId: "",
},
multipleSelection: [],
};
},
computed: {},
created() {},
mounted() {},
methods: {
// 人员配置根据selectStatus字段确定已选人员
adds(a, rid) {
this.roleId = rid;
this.visible = true;
console.log("a", a);
this.tableData.data = a;
this.tableData.data.forEach((item, index) => {
if (item.selectStatus === 0) {
this.$nextTick(() => {
this.$refs.multipleTable.toggleRowSelection(
this.tableData.data[index],
true
);
});
}
});
},
close() {
this.visible = false;
},
// 保存
handleSaveMember() {
const idList = this.multipleSelection.map((item) => {
return item.id;
});
console.log("this.roleId",this.roleId,idList);
updateUser(this.roleId, idList).then((res) => {
console.log("res",res);
if (res.status === 1) {
this.$message.success({ message: "保存成功", showClose: true });
this.visible = false;
// this.$emit("setUsers", this.roleId);
// this.resetMemberConfig();
} else this.$message.error({ message: res.message, showClose: true });
});
},
handleSelectionChange(val) {
console.log("val", val);
this.multipleSelection = val;
},
},
};
</script>
<style scoped lang="scss">
/deep/.el-dialog__header {
text-align: center;
margin-bottom: 10px;
.el-dialog__title {
color: white;
}
}
</style>