董国庆
2025-05-09 1224f7cc2c2f42a8b70466d14b15d443da1e27fd
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<template>
    <el-dialog @open="openDialog" class="select-member" :visible.sync="visible" width="53.33%"
        :close-on-click-modal="false" :show-close="false">
        <template #title>
            <div>选择参与人员</div>
        </template>
        <div class="select-member-content">
            <el-row :gutter="16">
                <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
                    <div class="select-member-content-left">
                        <div class="select-member-content-left-search">
                            <div class="select-member-content-left-search-input">
                                <img src="@/assets/public/search-outline@2x.png" />
                                <el-input v-model="search" placeholder="请输入" />
                                <div class="select-member-content-left-search-input-close">
                                    <img @click.stop="searchRole" v-if="search"
                                        src="@/assets/public/close-circle-fill@2x.png" />
                                </div>
                            </div>
                            <el-button type="primary">搜索</el-button>
                        </div>
                        <div class="select-member-content-left-list">
                            <div class="select-member-content-left-list-title">角色列表</div>
                            <div class="select-member-content-left-list-itemBox">
                                <div @click="searchUserList(item.roleId)" v-for="item in roleList" :key="item.roleId"
                                    class="select-member-content-left-list-itemBox-item"
                                    :class="roleId == item.roleId && 'active'">
                                    {{ item.roleName }}
                                </div>
                            </div>
                        </div>
                    </div>
                </el-col>
                <el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
                    <div class="select-member-content-right">
                        <div class="select-member-content-right-header">
                            <div class="select-member-content-right-header-text">人员列表</div>
                            <div class="select-member-content-right-header-search">
                                <el-input clearable v-model="nickNameOrPhone" placeholder="请输入姓名/手机号" />
                                <el-button type="primary">搜索</el-button>
                            </div>
                        </div>
                        <Table ref="memberTable" :height="null" :row-key="row => row.userId" :data="tableData"
                            :total="0" @selection-change="handleSelectionChange" :row-class-name="tableRowClassName">
                            <el-table-column type="selection" width="55" />
                            <el-table-column label="角色" prop="roleName" />
                            <el-table-column label="姓名" prop="nickName" />
                            <el-table-column label="创建时间" prop="createTime" />
                        </Table>
                    </div>
                </el-col>
            </el-row>
        </div>
        <div class="select-member-footer">
            <el-button @click="close" type="default">关闭</el-button>
            <el-button type="primary" @click="submit">确认选择</el-button>
        </div>
    </el-dialog>
</template>
 
<script>
import { getRoleList, getUserList } from './service'
export default {
    data() {
        return {
            visible: false,
            search: '',
            nickNameOrPhone: '',
            tableData: [],
            selectData: [],
            roleList: [],
            roleId: null,
        }
    },
    methods: {
        setSelection(selected) {
            this.selectData = selected
            this.$nextTick(() => {
                // 设置新选中
                this.tableData.forEach(row => {
                    if (selected.some(i => i.userId === row.userId)) {
                        this.$refs.memberTable.toggleRowSelection(row, true)
                    }
                })
            })
        },
        openDialog() {
            getRoleList().then(res => {
                this.roleList = res;
            })
            this.searchUserList(null);
        },
        handleSelectionChange(val) {
            this.selectData = val
        },
        async searchUserList(roleId) {
            this.roleId = roleId
            const res = await getUserList({ roleIds: roleId ? [roleId] : [], nickNameOrPhone: this.searchName, pageSize: 9999, pageNum: 1 })
            this.tableData = res.records
            // 数据加载完成后重新应用选中状态
            this.setSelection(this.selectData)
        },
        searchRole() {
            this.search = ''
        },
        open() {
            this.visible = true
        },
        close() {
            this.visible = false
        },
        submit() {
            this.$emit('submit', this.selectData)
        },
        tableRowClassName({ row, rowIndex }) {
            if (this.selectData.findIndex(item => item.userId === row.userId) != -1) {
                return 'select-row';
            }
            return '';
        }
    }
}
</script>
 
<style scoped lang="less">
.select-member-content {
    .select-member-content-left {
        box-shadow: 0px 4px 12px 4px rgba(0, 0, 0, 0.08);
        border-radius: 10px;
        margin-bottom: 31px;
 
        &-search {
            padding: 6px 7px 6px 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(238, 238, 238, 1);
 
            &-input {
                display: flex;
                align-items: center;
                background: rgba(0, 0, 0, 0.04);
                border-radius: 4px;
                margin-right: 10px;
                flex: 1;
 
                ::v-deep .el-input__inner {
                    background-color: transparent;
                    border: none;
                    height: 36px;
                    line-height: 36px;
                    padding: 0;
                    width: 100%;
                }
 
                img {
                    flex-shrink: 0;
                    width: 19px;
                    height: 20px;
                    margin: 0 5px;
                }
 
                &-close {
                    width: 19px;
                    height: 20px;
                    margin: 0 9px;
                    flex-shrink: 0;
 
                    img {
                        cursor: pointer;
                    }
                }
            }
        }
 
        &-list {
            padding: 15px 13px;
 
            &-title {
                font-weight: 500;
                font-size: 16px;
                line-height: 16px;
                color: #222222;
                font-family: 'SourceHanSansCN-Medium';
                margin-bottom: 8px;
            }
 
            &-itemBox {
                height: 451px;
                background: #F4F6F8;
                border-radius: 10px;
                padding: 12px 10px;
                overflow-y: auto;
 
                &-item {
                    cursor: pointer;
                    font-weight: 400;
                    font-size: 14px;
                    line-height: 22px;
                    color: rgba(0, 0, 0, 0.88);
                    font-family: 'PingFangSCRegular';
                    background: #FFFFFF;
                    border-radius: 4px;
                    padding: 9px 15px;
                    margin-bottom: 10px;
 
                    &:last-child {
                        margin-bottom: 0;
                    }
 
                    &:hover,
                    &.active {
                        background: rgba(4, 156, 154, 0.1);
                        color: #049C9A;
                    }
                }
            }
        }
    }
 
    .select-member-content-right {
        margin-bottom: 31px;
 
        &-header {
            display: flex;
            align-items: center;
            margin-top: 5px;
            justify-content: space-between;
            margin-bottom: 21px;
 
            &-text {
                flex-shrink: 0;
                font-weight: 500;
                font-size: 16px;
                line-height: 16px;
                color: #222222;
                font-family: 'SourceHanSansCN-Medium';
                margin-right: 20px;
            }
 
            &-search {
                display: flex;
                align-items: center;
 
                ::v-deep .el-input {
                    margin-right: 12px;
                }
            }
        }
    }
}
</style>