Browse Source

feat: 客户群群发 - 选择群聊

zhengxy 1 year ago
parent
commit
e1e1a45660

+ 123 - 38
project/src/components/customOperate/chatGroup/components/chatGroupOptions.vue

@@ -15,15 +15,23 @@
15 15
         <div class="common-screen-self-icon"><i class="el-icon-arrow-down" /></div>
16 16
       </div>
17 17
 
18
+      <div class="filter-wrap">
19
+        <el-select v-model="owner" class="select-wrap" size="small" placeholder="全部群主" clearable @change="onChangeOwner">
20
+          <el-option v-for="item in ownerOptions" :key="item.user_id" :label="item.name" :value="item.user_id" />
21
+        </el-select>
22
+        <self-input :reset="reset" :hasLabel="false" label_name="群名称" width="180px" style="margin:0 4px 0 0;" @inputChange="onChangeKeyword" />
23
+        <el-date-picker v-model="times" type="datetimerange" range-separator="至" start-placeholder="创建时间" end-placeholder="创建时间" :picker-options="pickerOptions" :defaultTime="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss" size="small" class="time-wrap" @change="onChangeTimes" />
24
+      </div>
25
+
18 26
       <div class="flex" style="padding:10px" v-loading="loading">
19 27
         <div class="propoverItem">
20
-          <div class="filter-wrap">
21
-            <el-select v-model="owner" class="select-wrap" size="small" placeholder="全部群主" clearable @change="onChangeOwner">
22
-              <el-option v-for="item in ownerOptions" :key="item.user_id" :label="item.name" :value="item.user_id" />
23
-            </el-select>
24
-            <self-input :reset="reset" :hasLabel="false" label_name="群名称" width="180px" style="margin-top:0; margin-bottom:0;" @inputChange="onChangeKeyword" />
28
+          <div class="all-wrap">
29
+            <div class="allMember">全部群聊({{ chatList && chatList.length }})</div>
30
+            <div :class="['checkbox', !chatList.length ? 'disabled' : '', isSelectedAll ? 'checkbox_active' : '']" @click="onClickSelectAll">
31
+              <i class="el-icon-check" />
32
+            </div>
25 33
           </div>
26
-          <div class="allMember">全部群聊({{ chatList && chatList.length }}):</div>
34
+
27 35
           <div class="memberBoxBig self-scrollbar-3">
28 36
             <div class="memberBox" v-for="(item, idx) in chatList" :key="item.chat_id">
29 37
               <div class="meberList">
@@ -33,6 +41,7 @@
33 41
                     <div class="memberInfo">
34 42
                       <div class="name">{{ item.name }}</div>
35 43
                       <div class="other">群主:{{ item.owner_name }}</div>
44
+                      <div class="other">创建时间:{{ item.create_time }}</div>
36 45
                     </div>
37 46
                   </div>
38 47
                   <div :class="['checkbox', item.isSelected ? 'checkbox_active' : '']">
@@ -59,6 +68,7 @@
59 68
                 <div class="memberInfo">
60 69
                   <div class="name">{{ item.name }}</div>
61 70
                   <div class="other">群主:{{ item.owner_name }}</div>
71
+                  <div class="other">创建时间:{{ item.create_time }}</div>
62 72
                 </div>
63 73
               </div>
64 74
               <i class="el-icon-close" style="margin-left:10px" @click="handleDelSelectedChat(idx)" />
@@ -98,12 +108,37 @@ export default {
98 108
   },
99 109
   data() {
100 110
     return {
111
+      pickerOptions: {
112
+        shortcuts: [{
113
+          text: '最近7天',
114
+          onClick: (picker) => {
115
+            const start = `${this.$moment().subtract(6, 'days').format('YYYY-MM-DD')} 00:00:00`
116
+            const end = `${this.$moment().format('YYYY-MM-DD')} 23:59:59`
117
+            picker.$emit('pick', [start, end]);
118
+          }
119
+        }, {
120
+          text: '最近30天',
121
+          onClick: (picker) => {
122
+            const start = `${this.$moment().subtract(29, 'days').format('YYYY-MM-DD')} 00:00:00`
123
+            const end = `${this.$moment().format('YYYY-MM-DD')} 23:59:59`
124
+            picker.$emit('pick', [start, end]);
125
+          }
126
+        }, {
127
+          text: '最近90天',
128
+          onClick: (picker) => {
129
+            const start = `${this.$moment().subtract(89, 'days').format('YYYY-MM-DD')} 00:00:00`
130
+            const end = `${this.$moment().format('YYYY-MM-DD')} 23:59:59`
131
+            picker.$emit('pick', [start, end]);
132
+          }
133
+        }]
134
+      },
101 135
       reset: false,
102 136
       loading: false,
103 137
       dialogVisible: false, // 控制弹框显示
104 138
       ownerOptions: [], // 群主筛选
105 139
       owner: '', // 群主id
106 140
       keyword: '', // 关键字
141
+      times: [],
107 142
       chatList: [], // 可选择客户群列表
108 143
       chatListSelected: [], // 已选择的群列表
109 144
     }
@@ -113,6 +148,13 @@ export default {
113 148
       const arr = this.chatListResult.map(c => c.name)
114 149
       return arr.join(',')
115 150
     },
151
+    isSelectedAll() { // 是否选择全部群聊
152
+      // 左右长度相等
153
+      const isSameLength = this.chatListSelected.length && (this.chatListSelected.length === this.chatList.length)
154
+      // 左边全部已勾选
155
+      const isSameChat = this.chatList.every(c => c.isSelected)
156
+      return isSameLength && isSameChat
157
+    },
116 158
   },
117 159
   watch: {
118 160
     dialogVisible(isShow) {
@@ -122,6 +164,7 @@ export default {
122 164
       } else { // 清空搜索关键字
123 165
         this.owner = ''
124 166
         this.keyword = ''
167
+        this.times = []
125 168
         this.reset = !this.reset
126 169
       }
127 170
     },
@@ -132,7 +175,12 @@ export default {
132 175
       try {
133 176
         this.loading = true
134 177
         this.chatList = []
135
-        const params = { keyword: this.keyword, owner: this.owner }
178
+        const params = {
179
+          keyword: this.keyword,
180
+          owner: this.owner,
181
+          start_time: this.times && this.times.length ? this.times[0] : '',
182
+          end_time: this.times && this.times.length ? this.times[1] : '',
183
+        }
136 184
         if (this.isOnJobUser) {
137 185
           params.is_active = 1
138 186
         }
@@ -181,6 +229,10 @@ export default {
181 229
       this.owner = val
182 230
       this.handleGetChatList()
183 231
     },
232
+    onChangeTimes(val) {
233
+      this.times = val && val.length ? [...val] : []
234
+      this.handleGetChatList()
235
+    },
184 236
     onChangeKeyword(val) {
185 237
       this.keyword = val
186 238
       this.handleGetChatList()
@@ -242,6 +294,19 @@ export default {
242 294
       this.$emit('change', _lodash.cloneDeep(this.chatListSelected))
243 295
       this.dialogVisible = false
244 296
     },
297
+
298
+    onClickSelectAll() {
299
+      console.log('this.isSelectedAll => ', this.isSelectedAll)
300
+      if (!this.chatList || !this.chatList.length) return false
301
+      if (this.isSelectedAll) { // 当前是全选状态 => 执行清空逻辑
302
+        this.handleDelAllSelectedChat()
303
+      } else { // 当前是非全选状态 => 选择全部群聊
304
+        this.chatList.forEach(c => {
305
+          c.isSelected = true
306
+        })
307
+        this.chatListSelected = [...this.chatList]
308
+      }
309
+    },
245 310
   },
246 311
 };
247 312
 </script>
@@ -253,7 +318,13 @@ export default {
253 318
   padding-right: 4px;
254 319
   .select-wrap {
255 320
     margin-right: 4px;
256
-    flex: 1;
321
+    width: 180px;
322
+  }
323
+  /deep/ .time-wrap {
324
+    width: 350px;
325
+    &.el-date-editor .el-range-input {
326
+      width: 50%;
327
+    }
257 328
   }
258 329
 }
259 330
 
@@ -262,11 +333,17 @@ export default {
262 333
   flex: 1;
263 334
   height: 100%;
264 335
 
265
-  .allMember {
266
-    color: #666666;
267
-    font-size: 14px;
268
-    line-height: 20px;
269
-    margin-top: 17px;
336
+  .all-wrap {
337
+    display: flex;
338
+    align-items: center;
339
+    justify-content: space-between;
340
+    padding-right: 19px;
341
+    padding-bottom: 6px;
342
+    margin-top: 3px;
343
+    .allMember {
344
+      color: #666;
345
+      font-size: 14px;
346
+    }
270 347
   }
271 348
 
272 349
   .title {
@@ -330,6 +407,9 @@ export default {
330 407
 .memberBox {
331 408
   display: flex;
332 409
   margin-top: 10px;
410
+  &:first-child {
411
+    margin-top: 0;
412
+  }
333 413
 
334 414
   .el-icon-caret-bottom {
335 415
     color: #46a7ff;
@@ -358,31 +438,6 @@ export default {
358 438
         font-weight: bold;
359 439
       }
360 440
     }
361
-
362
-    .checkbox {
363
-      width: 15px;
364
-      height: 15px;
365
-      border: 1px solid #979797;
366
-      border-radius: 50%;
367
-      display: flex;
368
-      align-items: center;
369
-      justify-content: center;
370
-      font-size: 12px;
371
-      margin-left: 10px;
372
-
373
-      i {
374
-        color: transparent;
375
-      }
376
-
377
-      &.checkbox_active {
378
-        i {
379
-          color: #ffffff;
380
-        }
381
-
382
-        background: #00b38a;
383
-        border-color: #00b38a;
384
-      }
385
-    }
386 441
   }
387 442
 }
388 443
 
@@ -433,5 +488,35 @@ export default {
433 488
   text-align: right;
434 489
   padding: 20px 0 10px;
435 490
 }
491
+
492
+.checkbox {
493
+  width: 15px;
494
+  height: 15px;
495
+  border: 1px solid #979797;
496
+  border-radius: 50%;
497
+  display: flex;
498
+  align-items: center;
499
+  justify-content: center;
500
+  font-size: 12px;
501
+  margin-left: 10px;
502
+  cursor: pointer;
503
+
504
+  i {
505
+    color: transparent;
506
+  }
507
+
508
+  &.checkbox_active {
509
+    i {
510
+      color: #ffffff;
511
+    }
512
+
513
+    background: #00b38a;
514
+    border-color: #00b38a;
515
+  }
516
+
517
+  &.disabled {
518
+    cursor: not-allowed;
519
+  }
520
+}
436 521
 </style>
437 522