Browse Source

feat: 客户群分配

zhengxy 1 year ago
parent
commit
0439c152e1

+ 2 - 0
project/src/assets/config/interface_api.js

@@ -487,6 +487,8 @@ var api = {
487 487
 
488 488
   groupTransfer_configList: '/api/chatGroupTransfer/configList', // 客户群分配 - 配置列表
489 489
   groupTransfer_changeStatus: '/api/chatGroupTransfer/changeStatus', // 客户群分配 - 切换状态
490
+  groupTransfer_editConfig: '/api/chatGroupTransfer/editConfig', // 客户群分配 - 设置配置
491
+  groupTransfer_configDetail: '/api/chatGroupTransfer/configDetail', // 客户群分配 - 配置详情
490 492
 
491 493
 };
492 494
 

+ 104 - 18
project/src/components/groupTransfer/configDrawer.vue

@@ -18,7 +18,7 @@
18 18
       <div class="form-wrap" v-loading="loading">
19 19
         <div class="form-item">
20 20
           <span class="lable required">配置标题</span>
21
-          <el-input placeholder="请输入配置标题" v-model.trim="form.title" clearable size="small" />
21
+          <el-input style="width: 300px;" placeholder="请输入配置标题" v-model.trim="form.title" clearable size="small" />
22 22
         </div>
23 23
 
24 24
         <div class="form-item">
@@ -28,7 +28,7 @@
28 28
         </div>
29 29
 
30 30
         <div class="form-item">
31
-          <span class="lable required">转移类型</span>
31
+          <span class="lable required">筛选方式</span>
32 32
           <el-radio v-model="form.filter_type" :label="1">按群聊</el-radio>
33 33
           <el-radio v-model="form.filter_type" :label="2">按群主</el-radio>
34 34
         </div>
@@ -40,12 +40,12 @@
40 40
 
41 41
         <div v-show="form.filter_type == 2" class="form-item">
42 42
           <span class="lable required">群主</span>
43
-          <selfCustomerservice v-if="isShowService" source="chatGroup" title="" width="400px" placeholder="请选择群主" :reset="reset" :afferent_users="form.old_owners" @customerDefine="onChangeOldOwners" />
43
+          <selfCustomerservice v-if="isShowService" source="chatGroup" title="" width="300px" placeholder="请选择群主" :reset="reset" :afferent_users="form.old_owners" @customerDefine="onChangeOldOwners" />
44 44
         </div>
45 45
 
46 46
         <div class="form-item">
47 47
           <span class="lable required">新群主</span>
48
-          <serviceSingle v-if="isShowService" source="chatGroup" title="" width="400px" placeholder="请选择新群主" :reset="reset" :afferent_userId="form.new_owner" @customerDefine="onChangeNewOwner" />
48
+          <serviceSingle v-if="isShowService" source="chatGroup" title="" width="300px" placeholder="请选择新群主" :reset="reset" :afferent_userId="form.new_owner" @customerDefine="onChangeNewOwner" />
49 49
         </div>
50 50
 
51 51
         <div class="form-item">
@@ -56,7 +56,7 @@
56 56
 
57 57
         <div v-show="form.transfer_type == 2" class="form-item">
58 58
           <span class="lable required">执行分配时间</span>
59
-          <el-date-picker v-model="form.transfer_at" type="datetime" :picker-options="pickerOptions" clearable value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择执行分配时间" size="mini" />
59
+          <el-date-picker v-model="form.transfer_at" type="datetime" :picker-options="pickerOptions" clearable value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择执行分配时间" size="mini" style="width:300px;" />
60 60
         </div>
61 61
       </div>
62 62
 
@@ -145,11 +145,42 @@ export default {
145 145
     async handleGetDetail() {
146 146
       this.isShowService = false
147 147
       await this.$nextTick()
148
-      // const { title, user_id, old_owners } = this.configInfo
149
-      // this.form.title = title
150
-      // this.form.new_owner = new_owner
151
-      // this.form.old_owners = old_owners.split(',')
152
-      this.isShowService = true
148
+      try {
149
+        this.loading = true
150
+        const url = `${this.URL.BASEURL}${this.URL.groupTransfer_configDetail}`
151
+        const params = {
152
+          config_id: this.config_id
153
+        }
154
+        const { data: res = {} } = await this.$axios.get(url, { params })
155
+        if (res && res.errno == 0) {
156
+          console.log('res => ', res)
157
+          const { title, type, filter_type, condition = '{}', new_owner, transfer_type, transfer_at } = res.rst
158
+          this.form.title = title
159
+          this.form.type = type || 1
160
+          this.form.filter_type = filter_type || 1
161
+          if (this.form.filter_type == 1) {
162
+            this.form.chat_ids = JSON.parse(condition).chat_ids.map(c => ({ chat_id: c, name: '' }))
163
+            // 回显"群聊"数据
164
+            this.handleSetChatGroups(this.form.chat_ids)
165
+          } else if (this.form.filter_type == 2) {
166
+            this.form.old_owners = JSON.parse(condition).owner_list
167
+          }
168
+          this.form.new_owner = new_owner
169
+          this.form.transfer_type = transfer_type || 1
170
+          if (this.form.transfer_type == 2) {
171
+            this.form.transfer_at = transfer_at
172
+          }
173
+          console.log('this.form => ', JSON.parse(JSON.stringify(this.form)))
174
+          this.isShowService = true
175
+        } else if (res.errno != 4002) {
176
+          this.$message.warning(res.err || '获取失败')
177
+        }
178
+      } catch (error) {
179
+        console.log(error)
180
+      } finally {
181
+        this.loading = false
182
+      }
183
+
153 184
     },
154 185
     async onClickSave() {
155 186
       try {
@@ -162,16 +193,23 @@ export default {
162 193
       }
163 194
     },
164 195
     handleFormValidate() {
165
-      const { title, new_owner, old_owners } = this.form
196
+      console.log('this.form => ', JSON.parse(JSON.stringify(this.form)))
197
+      const { title, filter_type, chat_ids, old_owners, new_owner, transfer_type, transfer_at } = this.form
166 198
       return new Promise((resolve, reject) => {
167 199
         if (!title) {
168 200
           this.$message.warning('请输入配置标题')
169 201
           reject('表单校验未通过')
202
+        } else if (filter_type == 1 && (!chat_ids || !chat_ids.length)) {
203
+          this.$message.warning('请选择群聊')
204
+          reject('表单校验未通过')
205
+        } else if (filter_type == 2 && (!old_owners || !old_owners.length)) {
206
+          this.$message.warning('请选择群主')
207
+          reject('表单校验未通过')
170 208
         } else if (!new_owner) {
171 209
           this.$message.warning('请选择新群主')
172 210
           reject('表单校验未通过')
173
-        } else if (!old_owners || !old_owners.length) {
174
-          this.$message.warning('请选择群主')
211
+        }  else if (transfer_type == 2 && !transfer_at) {
212
+          this.$message.warning('请选择执行分配时间')
175 213
           reject('表单校验未通过')
176 214
         } else {
177 215
           resolve('表单校验通过')
@@ -179,14 +217,33 @@ export default {
179 217
       })
180 218
     },
181 219
     async handleSubmitForm() {
220
+      console.log('handleSubmitForm => ', )
182 221
       try {
183 222
         this.loading = true
184
-        const url = `${this.URL.BASEURL}${this.URL.customerShare_setConfig}`
223
+        const url = `${this.URL.BASEURL}${this.URL.groupTransfer_editConfig}`
185 224
         const params = {
186 225
           title: this.form.title,
226
+          type: this.form.type,
227
+          filter_type: this.form.filter_type,
187 228
           new_owner: this.form.new_owner,
188
-          old_owners: this.form.old_owners.join(',')
229
+          transfer_type: this.form.transfer_type,
230
+          transfer_at: this.form.transfer_type == 1 ? '' : this.form.transfer_at,
231
+        }
232
+
233
+        if (this.form.filter_type == 1) { // 按群聊参数
234
+          params.condition = JSON.stringify({
235
+            chat_ids: this.form.chat_ids.map(c => c.chat_id)
236
+          })
237
+        } else if (this.form.filter_type == 2) { // 按群主参数
238
+          params.condition = JSON.stringify({
239
+            owner_list: this.form.old_owners.map(o => o)
240
+          })
241
+        }
242
+
243
+        if (this.isEdit) {
244
+          params.config_id = this.config_id
189 245
         }
246
+
190 247
         const { data: res = {} } = await this.$axios.post(url, params)
191 248
         if (res && res.errno == 0) {
192 249
           this.$message.success('保存成功')
@@ -204,8 +261,13 @@ export default {
204 261
     async handleClearForm() {
205 262
       this.reset = !this.reset
206 263
       this.form.title = ''
264
+      this.form.type = 1
265
+      this.form.filter_type = 1
207 266
       this.form.new_owner = ''
208 267
       this.form.old_owners = []
268
+      this.form.chat_ids = []
269
+      this.form.transfer_type = 1
270
+      this.form.transfer_at = ''
209 271
       this.isShowService = false
210 272
       await this.$nextTick()
211 273
       this.isShowService = true
@@ -221,6 +283,26 @@ export default {
221 283
     // 监听"选择群聊"变化
222 284
     onChangeGlobalChatGroup(selectedChat) {
223 285
       console.log('onChangeGlobalChatGroup => selectedChat ', selectedChat)
286
+      if (selectedChat && selectedChat.length) {
287
+        this.form.chat_ids = selectedChat.map(s => ({
288
+          ...s
289
+        }))
290
+      } else {
291
+        this.form.chat_ids = []
292
+      }
293
+    },
294
+    // 详情 => 回显群聊名称
295
+    async handleSetChatGroups(chat_groups) {
296
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.groupCode_chatGroupList, {
297
+        params: { keyword: '', owner: '' }
298
+      })
299
+      if (res && res.errno == 0 && Array.isArray(res.rst)) {
300
+        chat_groups.forEach((item, idx) => {
301
+          const isFound = res.rst.find(chat => chat.chat_id === item.chat_id)
302
+          if (isFound) chat_groups[idx].name = isFound.name
303
+        })
304
+        this.form.chat_ids = [...chat_groups]
305
+      }
224 306
     },
225 307
   },
226 308
 };
@@ -229,7 +311,7 @@ export default {
229 311
 <style lang="scss" scoped>
230 312
 .content-wrap {
231 313
   .form-wrap {
232
-    padding: 30px;
314
+    padding: 30px 50px;
233 315
     .form-item {
234 316
       display: flex;
235 317
       align-items: center;
@@ -242,7 +324,7 @@ export default {
242 324
       }
243 325
       .lable {
244 326
         flex-shrink: 0;
245
-        width: 120px;
327
+        width: 95px;
246 328
         color: #333;
247 329
         font-size: 14px;
248 330
         line-height: 28px;
@@ -258,6 +340,10 @@ export default {
258 340
           }
259 341
         }
260 342
       }
343
+      .common-screen-item {
344
+        margin-bottom: 0;
345
+        margin-top: 0;
346
+      }
261 347
       .el-input {
262 348
         width: 400px;
263 349
         /deep/ &.is-disabled .el-input__inner {
@@ -322,7 +408,7 @@ export default {
322 408
     }
323 409
   }
324 410
   .button_box {
325
-    margin: 100px 134px;
411
+    margin: 40px 134px;
326 412
     display: flex;
327 413
     align-items: center;
328 414
   }

+ 4 - 4
project/src/components/groupTransfer/index.vue

@@ -51,7 +51,7 @@
51 51
     <!-- S 创建配置 -->
52 52
     <configDrawer
53 53
       v-model="configDrawerVisible"
54
-      :configInfo="currentConfigInfo"
54
+      :config_id="currentConfigId"
55 55
       @confirm="onConfirmConfig"
56 56
       @cancel="onCancelConfig"
57 57
     />
@@ -99,7 +99,7 @@ export default {
99 99
       list: [],
100 100
 
101 101
       configDrawerVisible: false,
102
-      currentConfigInfo: {},
102
+      currentConfigId: '',
103 103
     }
104 104
   },
105 105
   created () {
@@ -201,12 +201,12 @@ export default {
201 201
 
202 202
     // 监听点击“新建配置”
203 203
     onClickCreateBtn() {
204
-      this.currentConfigInfo = {}
204
+      this.currentConfigId = ''
205 205
       this.configDrawerVisible = true
206 206
     },
207 207
     onClickEditBtn(row) {
208 208
       if (row.status != 1) return this.$message.warning('当前状态不可编辑')
209
-      this.currentConfigInfo = {...row}
209
+      this.currentConfigId = row.config_id
210 210
       this.configDrawerVisible = true
211 211
     },
212 212
     onConfirmConfig({ isEdit }) {