|
@@ -0,0 +1,314 @@
|
|
1
|
+<template>
|
|
2
|
+ <el-dialog
|
|
3
|
+ :visible.sync="dialogVisible"
|
|
4
|
+ :before-close="handleCancel"
|
|
5
|
+ class="operatorGroup-dialog"
|
|
6
|
+ :title="title"
|
|
7
|
+ width="590px"
|
|
8
|
+ :close-on-click-modal="false"
|
|
9
|
+ >
|
|
10
|
+ <div class="form-wrap" v-loading="loading">
|
|
11
|
+ <div class="form-item">
|
|
12
|
+ <span class="lable required">名称:</span>
|
|
13
|
+ <el-input v-model="form.group_name" size="small" placeholder="请输入名称" clearable />
|
|
14
|
+ </div>
|
|
15
|
+ <div class="form-item">
|
|
16
|
+ <span class="lable required">运营:</span>
|
|
17
|
+ <selfChannel v-if="isShowOperatorOptions" title="" type="circleCreate" placeholder="请选择" :labelWidth="true" width="440px" :reset="reset" :afferent_params="{ type: 1, operator_id: form.operator_id || '' }" :afferent_value="form.operator_id" @channelDefine="onChangeOperatorId" />
|
|
18
|
+ </div>
|
|
19
|
+ <div class="form-item" style="margin-top:10px;">
|
|
20
|
+ <span class="lable required">成员:</span>
|
|
21
|
+ <customerServiceCorpV2 ref="customerServiceCorpV2" title="" width="440px" :afferent_users="form.afferent_corp_user_list" @customerDefine="onChangeCorpUserList" />
|
|
22
|
+ </div>
|
|
23
|
+ </div>
|
|
24
|
+ <div slot="footer" class="dialog-footer">
|
|
25
|
+ <el-button size="mini" @click="handleCancel" :disabled="loading">取 消</el-button>
|
|
26
|
+ <el-button size="mini" type="primary" @click="handleConfirm" :disabled="loading">确 定</el-button>
|
|
27
|
+ </div>
|
|
28
|
+ </el-dialog>
|
|
29
|
+</template>
|
|
30
|
+
|
|
31
|
+<script>
|
|
32
|
+import _lodash from 'lodash'
|
|
33
|
+import selfChannel from '@/components/assembly/screen/channel.vue'
|
|
34
|
+import customerServiceCorpV2 from '@/components/assembly/screen/customerServiceCorpV2.vue'
|
|
35
|
+
|
|
36
|
+export default {
|
|
37
|
+ name: "operatorGroupDialog",
|
|
38
|
+ components: {
|
|
39
|
+ selfChannel,
|
|
40
|
+ customerServiceCorpV2,
|
|
41
|
+ },
|
|
42
|
+ props: {
|
|
43
|
+ // 控制弹框是否显示
|
|
44
|
+ dialogVisible: {
|
|
45
|
+ type: Boolean,
|
|
46
|
+ default: () => false
|
|
47
|
+ },
|
|
48
|
+ // 运营组ID
|
|
49
|
+ groupId: {
|
|
50
|
+ type: [String, Number],
|
|
51
|
+ default: () => ''
|
|
52
|
+ },
|
|
53
|
+ },
|
|
54
|
+ data() {
|
|
55
|
+ return {
|
|
56
|
+ loading: false,
|
|
57
|
+ reset: false,
|
|
58
|
+ isShowOperatorOptions: false,
|
|
59
|
+ form: {
|
|
60
|
+ group_name: '', // 名称
|
|
61
|
+ operator_id: '', // 运营
|
|
62
|
+ afferent_corp_user_list: [], // 多主体运营组成员 [{ user_id: 888, corpid: 666 }]
|
|
63
|
+ corp_user_list: [], // 多主体运营组成员
|
|
64
|
+ }
|
|
65
|
+ }
|
|
66
|
+ },
|
|
67
|
+ computed: {
|
|
68
|
+ isEdit() {
|
|
69
|
+ return !!this.groupId
|
|
70
|
+ },
|
|
71
|
+ title() {
|
|
72
|
+ return `${this.isEdit ? '编辑' : '新建'}运营组`
|
|
73
|
+ },
|
|
74
|
+ },
|
|
75
|
+ watch: {
|
|
76
|
+ dialogVisible(isShow) {
|
|
77
|
+ if (isShow) {
|
|
78
|
+ // 获取表单数据
|
|
79
|
+ this.handleGetFormData()
|
|
80
|
+ }
|
|
81
|
+ },
|
|
82
|
+ },
|
|
83
|
+ methods: {
|
|
84
|
+ onChangeCorpUserList({ res_format_1 }) {
|
|
85
|
+ if (res_format_1 && res_format_1.length) {
|
|
86
|
+ this.form.corp_user_list = res_format_1.map(r => ({
|
|
87
|
+ corpid: r.corpid,
|
|
88
|
+ user_id: r.user_id,
|
|
89
|
+ }))
|
|
90
|
+ } else {
|
|
91
|
+ this.form.corp_user_list = []
|
|
92
|
+ }
|
|
93
|
+ },
|
|
94
|
+ // 监听"运营"筛选变化
|
|
95
|
+ onChangeOperatorId(val) {
|
|
96
|
+ this.form.operator_id = val
|
|
97
|
+ },
|
|
98
|
+ // 确定
|
|
99
|
+ async handleConfirm() {
|
|
100
|
+ try {
|
|
101
|
+ // 表单校验
|
|
102
|
+ await this.handleFormValidate()
|
|
103
|
+ const url = `${this.URL.BASEURL}${this.URL.operatorGroup_setConfig}`
|
|
104
|
+ const params = this.handleGetParams()
|
|
105
|
+ this.loading = true
|
|
106
|
+ const { data: res = {} } = await this.$axios.post(url, params)
|
|
107
|
+ if (res && res.errno == 0) {
|
|
108
|
+ this.$message.success('操作成功')
|
|
109
|
+ this.handleClearFormData()
|
|
110
|
+ this.$emit('confirm', { isEdit: this.isEdit })
|
|
111
|
+ } else if (res.errno != 4002) {
|
|
112
|
+ this.$message.warning(res.err || '操作失败')
|
|
113
|
+ }
|
|
114
|
+ } catch (error) {
|
|
115
|
+ console.log('error => ', error)
|
|
116
|
+ } finally {
|
|
117
|
+ this.loading = false
|
|
118
|
+ }
|
|
119
|
+ },
|
|
120
|
+ // 取消
|
|
121
|
+ handleCancel() {
|
|
122
|
+ this.handleClearFormData()
|
|
123
|
+ this.$emit('cancel')
|
|
124
|
+ },
|
|
125
|
+ // 执行表单校验
|
|
126
|
+ handleFormValidate() {
|
|
127
|
+ return new Promise((resolve, reject) => {
|
|
128
|
+ const { group_name, operator_id, corp_user_list } = this.form
|
|
129
|
+ if (group_name === '') {
|
|
130
|
+ this.$message.warning('请输入名称')
|
|
131
|
+ reject('表单校验未通过')
|
|
132
|
+ } else if (!operator_id) {
|
|
133
|
+ this.$message.warning('请选择运营')
|
|
134
|
+ reject('表单校验未通过')
|
|
135
|
+ } else if (!corp_user_list || !corp_user_list.length) {
|
|
136
|
+ this.$message.warning('请选择成员')
|
|
137
|
+ reject('表单校验未通过')
|
|
138
|
+ } else {
|
|
139
|
+ resolve('表单校验通过')
|
|
140
|
+ }
|
|
141
|
+ })
|
|
142
|
+ },
|
|
143
|
+ // 整理请求参数
|
|
144
|
+ handleGetParams() {
|
|
145
|
+ const params = {
|
|
146
|
+ group_name: this.form.group_name,
|
|
147
|
+ operator_id: this.form.operator_id,
|
|
148
|
+ corp_user_list: JSON.stringify(this.form.corp_user_list),
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ if (this.isEdit) {
|
|
152
|
+ params.group_id = this.groupId
|
|
153
|
+ }
|
|
154
|
+
|
|
155
|
+ return {...params}
|
|
156
|
+ },
|
|
157
|
+ // 获取表单数据
|
|
158
|
+ async handleGetFormData() {
|
|
159
|
+ this.handleClearFormData()
|
|
160
|
+ await this.$nextTick()
|
|
161
|
+ if (this.isEdit) { // 编辑 => 获取运营组详情 => 回显表单数据
|
|
162
|
+ this.handleGetGroupDetail()
|
|
163
|
+ } else { // 新建
|
|
164
|
+ this.handleShowOperatorOpt()
|
|
165
|
+ }
|
|
166
|
+ },
|
|
167
|
+ // 获取运营组详情
|
|
168
|
+ async handleGetGroupDetail() {
|
|
169
|
+ try {
|
|
170
|
+ const url = `${this.URL.BASEURL}${this.URL.operatorGroup_groupDetail}`
|
|
171
|
+ const params = {
|
|
172
|
+ group_id: this.groupId,
|
|
173
|
+ }
|
|
174
|
+ this.loading = true
|
|
175
|
+ const { data: res = {} } = await this.$axios.get(url, { params })
|
|
176
|
+ if (res && res.errno == 0) {
|
|
177
|
+ const detailInfo = res.rst
|
|
178
|
+ this.form.group_name = detailInfo.group_name
|
|
179
|
+ this.form.operator_id = detailInfo.operator_id
|
|
180
|
+
|
|
181
|
+ this.handleShowOperatorOpt() // 回显
|
|
182
|
+
|
|
183
|
+ if (detailInfo.corp_user_list && detailInfo.corp_user_list.length) {
|
|
184
|
+ const userListRes = []
|
|
185
|
+ detailInfo.corp_user_list.forEach(c => {
|
|
186
|
+ if (c && c.user_list && Array.isArray(c.user_list)) {
|
|
187
|
+ c.user_list.forEach(userId => {
|
|
188
|
+ userListRes.push({
|
|
189
|
+ user_id: userId,
|
|
190
|
+ corpid: c.app_id,
|
|
191
|
+ })
|
|
192
|
+ })
|
|
193
|
+ }
|
|
194
|
+ })
|
|
195
|
+ this.form.afferent_corp_user_list = [...userListRes]
|
|
196
|
+ this.form.corp_user_list = _lodash.cloneDeep(this.form.afferent_corp_user_list)
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ } else if (res.errno != 4002) {
|
|
200
|
+ this.$message.warning(res.err || '操作失败')
|
|
201
|
+ }
|
|
202
|
+ } catch (error) {
|
|
203
|
+ console.log('error => ', error)
|
|
204
|
+ } finally {
|
|
205
|
+ this.loading = false
|
|
206
|
+ }
|
|
207
|
+ },
|
|
208
|
+ // 清空弹框表单数据
|
|
209
|
+ handleClearFormData() {
|
|
210
|
+ this.form.group_name = ''
|
|
211
|
+ this.form.operator_id = ''
|
|
212
|
+ this.form.afferent_corp_user_list = []
|
|
213
|
+ this.form.corp_user_list = []
|
|
214
|
+ this.$refs.customerServiceCorpV2 && this.$refs.customerServiceCorpV2.handleCloseAllOpen()
|
|
215
|
+ this.reset = !this.reset
|
|
216
|
+ this.isShowOperatorOptions = false
|
|
217
|
+ },
|
|
218
|
+
|
|
219
|
+ // 显示运营选项
|
|
220
|
+ handleShowOperatorOpt() {
|
|
221
|
+ this.isShowOperatorOptions = true
|
|
222
|
+ },
|
|
223
|
+ },
|
|
224
|
+};
|
|
225
|
+</script>
|
|
226
|
+
|
|
227
|
+<style lang="scss" scoped>
|
|
228
|
+.operatorGroup-dialog {
|
|
229
|
+ /deep/ .el-dialog__body {
|
|
230
|
+ max-height: 380px;
|
|
231
|
+ overflow-y: auto;
|
|
232
|
+ }
|
|
233
|
+ .form-wrap {
|
|
234
|
+ padding-right: 20px;
|
|
235
|
+ .form-item {
|
|
236
|
+ display: flex;
|
|
237
|
+ align-items: center;
|
|
238
|
+ margin-top: 20px;
|
|
239
|
+ &.flex-align-start {
|
|
240
|
+ align-items: flex-start;
|
|
241
|
+ }
|
|
242
|
+ &:first-child {
|
|
243
|
+ margin-top: 0;
|
|
244
|
+ }
|
|
245
|
+ .lable {
|
|
246
|
+ width: 80px;
|
|
247
|
+ font-weight: 500;
|
|
248
|
+ flex-shrink: 0;
|
|
249
|
+ text-align: right;
|
|
250
|
+ margin-right: 10px;
|
|
251
|
+
|
|
252
|
+ &.required {
|
|
253
|
+ &::before {
|
|
254
|
+ position: relative;
|
|
255
|
+ right: 2px;
|
|
256
|
+ content: "*";
|
|
257
|
+ color: #f56c6c;
|
|
258
|
+ }
|
|
259
|
+ }
|
|
260
|
+ }
|
|
261
|
+ .el-select {
|
|
262
|
+ width: 430px;
|
|
263
|
+ }
|
|
264
|
+ .rules-wrap {
|
|
265
|
+ box-sizing: border-box;
|
|
266
|
+ background-color: #F2F2F2;
|
|
267
|
+ padding: 14px;
|
|
268
|
+ width: 430px;
|
|
269
|
+ .rules-item {
|
|
270
|
+ display: flex;
|
|
271
|
+ align-items: center;
|
|
272
|
+ flex-shrink: 0;
|
|
273
|
+ margin-bottom: 10px;
|
|
274
|
+ .el-input {
|
|
275
|
+ width: 70px;
|
|
276
|
+ margin-right: 6px;
|
|
277
|
+ /deep/ .el-input__inner {
|
|
278
|
+ padding: 0 24px 0 8px;
|
|
279
|
+ }
|
|
280
|
+ }
|
|
281
|
+ .el-select {
|
|
282
|
+ width: 100px;
|
|
283
|
+ margin-right: 6px;
|
|
284
|
+ }
|
|
285
|
+ .text {
|
|
286
|
+ margin-right: 6px;
|
|
287
|
+ font-size: 13px;
|
|
288
|
+ }
|
|
289
|
+ .el-icon-error {
|
|
290
|
+ color: #F56C6C;
|
|
291
|
+ font-size: 14px;
|
|
292
|
+ cursor: pointer;
|
|
293
|
+ }
|
|
294
|
+ }
|
|
295
|
+ .add-wrap {
|
|
296
|
+ margin-top: 16px;
|
|
297
|
+ display: flex;
|
|
298
|
+ align-items: center;
|
|
299
|
+ color: #00B38A;
|
|
300
|
+ font-size: 13px;
|
|
301
|
+ cursor: pointer;
|
|
302
|
+ i {
|
|
303
|
+ font-weight: 600;
|
|
304
|
+ margin-right: 2px;
|
|
305
|
+ }
|
|
306
|
+ }
|
|
307
|
+ }
|
|
308
|
+ }
|
|
309
|
+ }
|
|
310
|
+ .dialog-footer {
|
|
311
|
+ text-align: center;
|
|
312
|
+ }
|
|
313
|
+}
|
|
314
|
+</style>
|