|
@@ -1,20 +1,20 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="common-screen-item">
|
3
|
3
|
<label class="common-screen-label" v-if="title&&title!=''">{{title}}</label>
|
4
|
|
- <el-popover placement="bottom" trigger="click" v-model="visible">
|
5
|
|
- <div :style="width?'width:'+width:''" :class="['common-screen-self-box','common-input-select',final_result&&final_result.length!=0&&clearable?'common-input-select-hover':'']" slot="reference">
|
6
|
|
- <div :class="['common-screen-self-con',!final_result||final_result.length==0?'common-screen-self-placeholder':'']">
|
7
|
|
- <span v-if="!final_result||final_result.length==0">请选择</span>
|
8
|
|
- <template v-else>
|
9
|
|
- <span v-for="(item,index) in final_result" :key="index">{{item.name}}{{index==final_result.length-1?'':','}}</span>
|
10
|
|
- </template>
|
11
|
|
- </div>
|
12
|
|
- <div class="common-screen-self-icon" @click.stop="clear">
|
13
|
|
- <i class="el-icon-arrow-down default-icon"></i>
|
14
|
|
- <i class="el-icon-circle-close other-icon"></i>
|
15
|
|
- </div>
|
|
4
|
+ <div :style="width?'width:'+width:''" :class="['common-screen-self-box','common-input-select',selectUser&&selectUser.user_id&&clearable?'common-input-select-hover':'']" @click="screenClick">
|
|
5
|
+ <div :class="['common-screen-self-con',!selectUser||!selectUser.user_id||selectUser.user_id==''?'common-screen-self-placeholder':'']">
|
|
6
|
+ <span v-if="!selectUser||!selectUser.user_id||selectUser.user_id==''">请选择</span>
|
|
7
|
+ <template v-else>
|
|
8
|
+ <span>{{selectUser.name}}</span>
|
|
9
|
+ </template>
|
|
10
|
+ </div>
|
|
11
|
+ <div class="common-screen-self-icon" @click.stop="clear">
|
|
12
|
+ <i class="el-icon-arrow-down default-icon"></i>
|
|
13
|
+ <i class="el-icon-circle-close other-icon"></i>
|
16
|
14
|
</div>
|
17
|
|
- <div class="flex" style="padding:10px" v-loading="loading">
|
|
15
|
+ </div>
|
|
16
|
+ <el-dialog title="" :visible.sync="visible" :close-on-click-modal="false" width="400px" center top="15vh">
|
|
17
|
+ <div v-loading="loading">
|
18
|
18
|
<div class="propoverItem">
|
19
|
19
|
<!-- <self-input :hasLabel="false" width="270px" style="margin-top:0"></self-input> -->
|
20
|
20
|
<div class="allMember">全部成员({{userTotal}}):</div>
|
|
@@ -23,14 +23,13 @@
|
23
|
23
|
<div class="memberBox self-scrollbar-3" :key="index + 'userList' + item.department_id">
|
24
|
24
|
<i :class="['el-icon-caret-bottom',item.is_open?'reversalAnimation':'']" @click="openEvent(index)"></i>
|
25
|
25
|
<div class="meberList">
|
26
|
|
- <div class="department" @click="selectUserEvent('all',index)">
|
|
26
|
+ <div class="department">
|
27
|
27
|
<div class="flex">
|
28
|
28
|
<i class="el-icon-s-cooperation"></i>
|
29
|
29
|
<span>{{item.department_name?item.department_name:'部门'+(index+1)}}</span>
|
30
|
30
|
</div>
|
31
|
|
- <div :class="['checkbox',item.is_select?'checkbox_active':'']"><i class="el-icon-check"></i></div>
|
32
|
31
|
</div>
|
33
|
|
- <div class="memberItem" :style="item.is_open?'display:none':''" v-for="(item1,user_index) in item.user_list" :key="item1.user_id" @click="selectUserEvent('user',index,user_index)">
|
|
32
|
+ <div class="memberItem" :style="item.is_open?'display:none':''" v-for="(item1) in item.user_list" :key="item1.user_id" @click="selectUserEvent('user',item1.user_id)">
|
34
|
33
|
<div class="flex">
|
35
|
34
|
<img class="memberImg" :src="item1.avatar" alt="">
|
36
|
35
|
<div class="memberInfo">
|
|
@@ -38,39 +37,19 @@
|
38
|
37
|
<div class="other">部门:{{item1.department}}</div>
|
39
|
38
|
</div>
|
40
|
39
|
</div>
|
41
|
|
- <div :class="['checkbox',item1.is_select?'checkbox_active':'']"><i class="el-icon-check"></i></div>
|
|
40
|
+ <div :class="['checkbox',selectUserId==item1.user_id?'checkbox_active':'']"><i class="el-icon-check"></i></div>
|
42
|
41
|
</div>
|
43
|
42
|
</div>
|
44
|
43
|
</div>
|
45
|
44
|
</template>
|
46
|
45
|
</div>
|
47
|
46
|
</div>
|
48
|
|
- <div class="line"></div>
|
49
|
|
- <div class="propoverItem" style="padding-left:20px">
|
50
|
|
- <div class="title">已选择的成员</div>
|
51
|
|
- <div class="choice_result_top">
|
52
|
|
- <div class="clear" @click="closeUser(-1)">全部清空</div>
|
53
|
|
- <div class="result_num">已选择<span>{{selectUser&&selectUser.length}}</span>人</div>
|
54
|
|
- </div>
|
55
|
|
- <div class="member_result self-scrollbar-3">
|
56
|
|
- <div class="memberItem" v-for="(item,index) in selectUser" :key="index">
|
57
|
|
- <div class="flex">
|
58
|
|
- <img class="memberImg" :src="item.avatar" alt="">
|
59
|
|
- <div class="memberInfo">
|
60
|
|
- <div class="name">{{item.name}}</div>
|
61
|
|
- <div class="other">部门:{{item.department}}</div>
|
62
|
|
- </div>
|
63
|
|
- </div>
|
64
|
|
- <i class="el-icon-close" @click="closeUser(index)"></i>
|
65
|
|
- </div>
|
66
|
|
- </div>
|
67
|
|
- <div class="buttons">
|
68
|
|
- <el-button type="primary" plain size="mini" @click="visible = false">取消</el-button>
|
69
|
|
- <el-button type="primary" size="mini" @click="defineEvent">确定</el-button>
|
70
|
|
- </div>
|
|
47
|
+ <div class="buttons">
|
|
48
|
+ <el-button type="primary" plain size="mini" @click="visible = false">取消</el-button>
|
|
49
|
+ <el-button type="primary" size="mini" @click="defineEvent">确定</el-button>
|
71
|
50
|
</div>
|
72
|
51
|
</div>
|
73
|
|
- </el-popover>
|
|
52
|
+ </el-dialog>
|
74
|
53
|
</div>
|
75
|
54
|
</template>
|
76
|
55
|
<script>
|
|
@@ -99,9 +78,8 @@ export default {
|
99
|
78
|
},
|
100
|
79
|
watch: {
|
101
|
80
|
reset () {
|
102
|
|
- this.selectUser = [];
|
103
|
|
- this.final_result = [];
|
104
|
|
- this.changeSelect()
|
|
81
|
+ this.selectUserId = '';
|
|
82
|
+ this.selectUser = {};
|
105
|
83
|
}
|
106
|
84
|
},
|
107
|
85
|
data () {
|
|
@@ -110,60 +88,50 @@ export default {
|
110
|
88
|
loading: false,
|
111
|
89
|
userList: [],
|
112
|
90
|
userTotal: 0,
|
113
|
|
- selectUser: [],
|
114
|
|
- final_result: []
|
|
91
|
+ selectUserId: '',
|
|
92
|
+ selectUser: {},
|
115
|
93
|
}
|
116
|
94
|
},
|
117
|
|
- created () {
|
118
|
|
- if (this.userList.length == 0) {
|
119
|
|
- this.init()
|
120
|
|
- } else {
|
121
|
|
- this.selectUser = JSON.parse(JSON.stringify(this.final_result));
|
122
|
|
- this.changeSelect()
|
123
|
|
- this.afferent_init()
|
124
|
|
- }
|
|
95
|
+ mounted () {
|
|
96
|
+ console.log(this.selectUser)
|
125
|
97
|
},
|
126
|
98
|
methods: {
|
127
|
|
- afferent_init () {//从外面传入
|
128
|
|
- let selectUser = [];
|
129
|
|
- if (this.afferent_users && this.afferent_users.length > 0) {
|
130
|
|
- this.userList.forEach((item1) => {
|
131
|
|
- item1.user_list.forEach((item) => {
|
132
|
|
- if (this.afferent_users.indexOf(item.user_id) != -1) {
|
133
|
|
- selectUser.push(item)
|
134
|
|
- }
|
135
|
|
- })
|
|
99
|
+ screenClick () {
|
|
100
|
+ this.visible = true;
|
|
101
|
+ if (this.userList.length == 0) {
|
|
102
|
+ this.init()
|
|
103
|
+ } else {
|
|
104
|
+ this.serviceInit()
|
|
105
|
+ }
|
|
106
|
+ },
|
|
107
|
+ serviceInit (type) {
|
|
108
|
+ this.userList.forEach((item) => {
|
|
109
|
+ item.is_open = false//是否折叠
|
|
110
|
+ item.user_list.forEach((item1, index) => {
|
|
111
|
+ if (item1.user_id == this.selectUserId) {
|
|
112
|
+ this.selectUser = item1
|
|
113
|
+ }
|
136
|
114
|
})
|
137
|
|
- this.selectUser = selectUser;
|
138
|
|
- this.final_result = JSON.parse(JSON.stringify(selectUser))
|
139
|
|
- this.changeSelect()
|
|
115
|
+ });
|
|
116
|
+ if (type == 'define') {
|
|
117
|
+ this.$emit('customerDefine', this.selectUser)
|
140
|
118
|
}
|
141
|
119
|
},
|
142
|
120
|
clear () {
|
143
|
|
- if (!this.selectUser || this.selectUser.length == 0) {
|
144
|
|
- this.visible = !this.visible
|
145
|
|
- return
|
146
|
|
- } else {
|
147
|
|
- this.selectUser = [];
|
148
|
|
- this.final_result = []
|
149
|
|
- this.changeSelect()
|
150
|
|
- this.$emit('customerDefine', [])
|
151
|
|
- }
|
|
121
|
+ this.selectUserId = '';
|
|
122
|
+ this.selectUser = {};
|
|
123
|
+ this.$emit('customerDefine', '')
|
152
|
124
|
},
|
153
|
125
|
defineEvent () {
|
154
|
|
- this.final_result = JSON.parse(JSON.stringify(this.selectUser))
|
155
|
|
- let arr = this.selectUser.map((v) => {
|
156
|
|
- return v.user_id
|
157
|
|
- })
|
158
|
|
- if (arr.length == 0) {
|
|
126
|
+ if (this.selectUserId == '') {
|
159
|
127
|
this.$message({
|
160
|
128
|
message: '请选择客服',
|
161
|
129
|
type: "warning"
|
162
|
130
|
})
|
163
|
131
|
return
|
164
|
132
|
}
|
|
133
|
+ this.serviceInit('define')
|
165
|
134
|
this.visible = false
|
166
|
|
- this.$emit('customerDefine', arr)
|
167
|
135
|
},
|
168
|
136
|
init () {
|
169
|
137
|
this.loading = true
|
|
@@ -172,16 +140,7 @@ export default {
|
172
|
140
|
this.loading = false
|
173
|
141
|
if (res && res.errno == 0) {
|
174
|
142
|
this.userList = res.rst.list;
|
175
|
|
- this.userList.forEach((item) => {
|
176
|
|
- item.is_open = false//是否折叠
|
177
|
|
- item.is_select = false//是否选中
|
178
|
|
- item.user_list.forEach((item1) => {
|
179
|
|
- item1.is_select = false
|
180
|
|
- })
|
181
|
|
- });
|
182
|
|
- this.selectUser = JSON.parse(JSON.stringify(this.final_result));
|
183
|
|
- this.changeSelect()
|
184
|
|
- this.afferent_init()
|
|
143
|
+ this.serviceInit()
|
185
|
144
|
this.userTotal = res.rst.count
|
186
|
145
|
} else if (res.errno != 4002) {
|
187
|
146
|
this.$message({
|
|
@@ -198,83 +157,15 @@ export default {
|
198
|
157
|
arr.is_open = !arr.is_open
|
199
|
158
|
this.$set(this.userList, index, arr)
|
200
|
159
|
},
|
201
|
|
- selectUserEvent (type, main_index, user_index) {
|
202
|
|
- let selectUser = this.selectUser
|
203
|
|
- let user_arr = this.userList[main_index];
|
204
|
|
- if (type == 'all') {//点击部门全选时
|
205
|
|
- if (!user_arr.is_select) {
|
206
|
|
- selectUser = selectUser.concat(user_arr.user_list)
|
207
|
|
- } else {
|
208
|
|
- let arr = user_arr.user_list.map((v) => {
|
209
|
|
- return v.user_id
|
210
|
|
- })
|
211
|
|
- selectUser = selectUser.filter((v) => {
|
212
|
|
- return arr.indexOf(v.user_id) == -1
|
213
|
|
- })
|
214
|
|
- }
|
215
|
|
- } else {//点击单个客服时
|
216
|
|
- let brr = user_arr.user_list[user_index]
|
217
|
|
- if (brr.is_select) {
|
218
|
|
- selectUser = selectUser.filter((v) => {
|
219
|
|
- return v.user_id != brr.user_id
|
220
|
|
- })
|
221
|
|
- } else {
|
222
|
|
- selectUser.push(brr)
|
223
|
|
- }
|
224
|
|
- }
|
225
|
|
- this.$set(this.userList, main_index, user_arr)
|
226
|
|
- // 去重
|
227
|
|
- let tmp = {};
|
228
|
|
- selectUser = selectUser.reduce((list, item) => {
|
229
|
|
- tmp[item.user_id] ? '' : (tmp[item.user_id] = list.push(item));
|
230
|
|
- return list
|
231
|
|
- }, []);
|
232
|
|
- this.selectUser = selectUser
|
233
|
|
- this.changeSelect()
|
|
160
|
+ selectUserEvent (type, user_id) {
|
|
161
|
+ this.selectUserId = user_id
|
234
|
162
|
},
|
235
|
|
- changeSelect () {//客服选择发生变化时,部门全选跟着相应的改变
|
236
|
|
- let self_userList = JSON.parse(JSON.stringify(this.userList))
|
237
|
|
- let arr_selectUser = this.selectUser.map((v) => { return v.user_id })
|
238
|
|
- // 全选的改变
|
239
|
|
- self_userList.forEach((item) => {
|
240
|
|
- item.user_list = item.user_list.filter((v) => {
|
241
|
|
- return arr_selectUser.indexOf(v.user_id) != -1
|
242
|
|
- })
|
243
|
|
- this.userList.forEach((main) => {
|
244
|
|
- if (main.department_id == item.department_id) {
|
245
|
|
- if (item.user_list.length == main.user_list.length) {
|
246
|
|
- main.is_select = true
|
247
|
|
- } else {
|
248
|
|
- main.is_select = false
|
249
|
|
- }
|
250
|
|
- }
|
251
|
|
- })
|
252
|
|
- })
|
253
|
|
- // 单个用户的改变
|
254
|
|
- this.userList.forEach((item) => {
|
255
|
|
- item.user_list.forEach((item1) => {
|
256
|
|
- if (arr_selectUser.indexOf(item1.user_id) == -1) {
|
257
|
|
- item1.is_select = false
|
258
|
|
- } else {
|
259
|
|
- item1.is_select = true
|
260
|
|
- }
|
261
|
|
- })
|
262
|
|
- })
|
263
|
|
- },
|
264
|
|
- closeUser (index) {
|
265
|
|
- if (index == -1) {
|
266
|
|
- this.selectUser = []
|
267
|
|
- } else {
|
268
|
|
- this.selectUser.splice(index, 1)
|
269
|
|
- }
|
270
|
|
- this.changeSelect()
|
271
|
|
- }
|
272
|
163
|
}
|
273
|
164
|
}
|
274
|
165
|
</script>
|
275
|
166
|
<style lang="scss" scoped>
|
276
|
167
|
.propoverItem {
|
277
|
|
- width: 300px;
|
|
168
|
+ width: 100%;
|
278
|
169
|
flex: 1;
|
279
|
170
|
height: 100%;
|
280
|
171
|
.allMember {
|
|
@@ -323,10 +214,10 @@ export default {
|
323
|
214
|
}
|
324
|
215
|
.propoverItem,
|
325
|
216
|
.line {
|
326
|
|
- height: 478px;
|
|
217
|
+ max-height: 478px;
|
327
|
218
|
}
|
328
|
219
|
.memberBoxBig {
|
329
|
|
- height: 400px;
|
|
220
|
+ max-height: 400px;
|
330
|
221
|
overflow-y: auto;
|
331
|
222
|
}
|
332
|
223
|
.memberBox {
|