Browse Source

feat: 系统消息 - 支持导出

zhengxy 1 year ago
parent
commit
2d7c7685f1

+ 20 - 0
project/src/components/assembly/screen/chatGroupOptions.vue

@@ -258,6 +258,26 @@ export default {
258 258
 
259 259
       this.dialogVisible = false
260 260
     },
261
+
262
+    // 详情 => 回显群聊名称
263
+    async handleSetChatGroupsName(chat_groups) {
264
+      try {
265
+        const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.groupCode_chatGroupList, {
266
+          params: { keyword: '', owner: '' }
267
+        })
268
+        if (res && res.errno == 0 && Array.isArray(res.rst)) {
269
+          chat_groups.forEach((item, idx) => {
270
+            const isFound = res.rst.find(chat => chat.chat_id === item.chat_id)
271
+            if (isFound) chat_groups[idx].name = isFound.name
272
+          })
273
+          return Promise.resolve([...chat_groups])
274
+        } else {
275
+          return Promise.resolve([...chat_groups])
276
+        }
277
+      } catch (error) {
278
+        return Promise.resolve([...chat_groups])
279
+      }
280
+    },
261 281
   },
262 282
 };
263 283
 </script>

+ 10 - 22
project/src/components/groupTransfer/configDrawer.vue

@@ -35,7 +35,7 @@
35 35
 
36 36
         <div v-show="form.filter_type == 1" class="form-item">
37 37
           <span class="lable required">群聊</span>
38
-          <selfChatGroupOptions v-if="isShowService" ref="chatGroupOptionsMain" width="300px" :isHasRoomId="true" :chatListResult="form.chat_ids" @change="onChangeGlobalChatGroup" />
38
+          <selfChatGroupOptions v-if="isShowService" ref="selfChatGroupOptions" width="300px" :isHasRoomId="true" :chatListResult="form.chat_ids" @change="onChangeGlobalChatGroup" />
39 39
         </div>
40 40
 
41 41
         <div v-show="form.filter_type == 2" class="form-item">
@@ -157,19 +157,21 @@ export default {
157 157
           this.form.title = title
158 158
           this.form.type = type || 1
159 159
           this.form.filter_type = filter_type || 1
160
-          if (this.form.filter_type == 1) {
161
-            this.form.chat_ids = JSON.parse(condition).chat_ids.map(c => ({ chat_id: c, name: '' }))
162
-            // 回显"群聊"数据
163
-            this.handleSetChatGroups(this.form.chat_ids)
164
-          } else if (this.form.filter_type == 2) {
165
-            this.form.old_owners = JSON.parse(condition).owner_list
166
-          }
167 160
           this.form.new_owner = new_owner
168 161
           this.form.transfer_type = transfer_type || 1
169 162
           if (this.form.transfer_type == 2) {
170 163
             this.form.transfer_at = transfer_at
171 164
           }
165
+          if (this.form.filter_type == 2) {
166
+            this.form.old_owners = JSON.parse(condition).owner_list
167
+          }
168
+          if (this.form.filter_type == 1) {
169
+            // 回显"群聊"数据
170
+            this.form.chat_ids = JSON.parse(condition).chat_ids.map(c => ({ chat_id: c, name: '' }))
171
+          }
172 172
           this.isShowService = true
173
+          await this.$nextTick()
174
+          this.form.chat_ids = await this.$refs.selfChatGroupOptions.handleSetChatGroupsName([...this.form.chat_ids]) // 调用组件方法回显群聊名称
173 175
         } else if (res.errno != 4002) {
174 176
           this.$message.warning(res.err || '获取失败')
175 177
         }
@@ -178,7 +180,6 @@ export default {
178 180
       } finally {
179 181
         this.loading = false
180 182
       }
181
-
182 183
     },
183 184
     async onClickSave() {
184 185
       try {
@@ -284,19 +285,6 @@ export default {
284 285
         this.form.chat_ids = []
285 286
       }
286 287
     },
287
-    // 详情 => 回显群聊名称
288
-    async handleSetChatGroups(chat_groups) {
289
-      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.groupCode_chatGroupList, {
290
-        params: { keyword: '', owner: '' }
291
-      })
292
-      if (res && res.errno == 0 && Array.isArray(res.rst)) {
293
-        chat_groups.forEach((item, idx) => {
294
-          const isFound = res.rst.find(chat => chat.chat_id === item.chat_id)
295
-          if (isFound) chat_groups[idx].name = isFound.name
296
-        })
297
-        this.form.chat_ids = [...chat_groups]
298
-      }
299
-    },
300 288
   },
301 289
 };
302 290
 </script>

+ 177 - 1
project/src/components/manage/systemMsg.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div class="customerStaff-wrap" v-loading="pageLoading">
3 3
     <!-- S 筛选区 -->
4
-    <div class="screenBox" style="padding-right: 100px;">
4
+    <div class="screenBox" style="padding-right: 100px;min-height: 85px;">
5 5
       <!-- 日期 -->
6 6
       <datePicker :reset="reset" title="自定义" :quickFlag="true" :afferent_time="default_time" :clearFlag="false" @changeTime="onChangeTime" />
7 7
       <!-- 企微主体 -->
@@ -10,6 +10,7 @@
10 10
       <selfInputV2 style="margin-left: -20px;"  :labelWidth="true" v-model="filter.user_name" label_name="成员" placeholder="请输入" @change="onChangeUserName" />
11 11
       <selfChannelV2 v-model="filter.msg_type" title="消息类型" type="msgType" labelWidth :clearable="false" @change="onChangeMsgType" />
12 12
       <div class="reset" @click="onClickReset">重置</div>
13
+      <el-button class="export-btn" type="primary" size="mini" @click="onClickExport">导出Excel</el-button>
13 14
     </div>
14 15
     <!-- E 筛选区 -->
15 16
     <!-- S 明细表 detailsTable -->
@@ -71,6 +72,38 @@
71 72
         <detailRuleKHPYQ v-if="isShowRuleKHPYQ" :is_copy='false' title="朋友圈详情" :rule_id='currentRuleId' :sysMsgCorpid="currentCorpid" @close="detailClose" />
72 73
       </el-drawer>
73 74
       <!-- E 详情 - 客户朋友圈 -->
75
+
76
+      <el-dialog
77
+        :visible.sync="msgExport.visible"
78
+        :before-close="handleCancelExport"
79
+        class="export-dialog"
80
+        title="系统消息导出"
81
+        width="530px"
82
+        :close-on-click-modal="false"
83
+      >
84
+        <div class="form-wrap" v-loading="msgExport.loading">
85
+          <div class="form-item">
86
+            <span class="tips">注:根据当前消息列表筛选条件导出,日期范围最多可选2天</span>
87
+          </div>
88
+          <div class="form-item">
89
+            <span class="lable required">导出日期:</span>
90
+            <el-date-picker
91
+              v-model="msgExport.time"
92
+              type="daterange"
93
+              range-separator="至"
94
+              start-placeholder="开始日期"
95
+              end-placeholder="结束日期"
96
+              size="mini"
97
+              style="width: 350px;"
98
+              :picker-options="msgExport.pickerOptions"
99
+            />
100
+          </div>
101
+        </div>
102
+        <div slot="footer" class="dialog-footer">
103
+          <el-button size="mini" @click="handleCancelExport" :disabled="msgExport.loading">取 消</el-button>
104
+          <el-button size="mini" type="primary" @click="handleConfirmExport" :disabled="msgExport.loading">确 定</el-button>
105
+        </div>
106
+      </el-dialog>
74 107
     </div>
75 108
     <!-- E 明细表 detailsTable -->
76 109
   </div>
@@ -92,6 +125,7 @@ import detailRuleZNQF from '@/components/smartPushV3/createMassMsg.vue' // 智
92 125
 
93 126
 import detailRuleKHPYQ from '@/components/customOperate/createFriendsCircle.vue' // 客户朋友圈-规则详情
94 127
 
128
+
95 129
 export default {
96 130
   components: {
97 131
     selfInputV2,
@@ -136,6 +170,17 @@ export default {
136 170
         msg_type: 1,
137 171
       },
138 172
 
173
+      msgExport: {
174
+        loading: false,
175
+        visible: false,
176
+        time: [],
177
+        pickerOptions: {
178
+          disabledDate (time) {
179
+            return time > Date.now()
180
+          }
181
+        },
182
+      },
183
+
139 184
       currentCorpid: '',
140 185
       currentRuleId: '',
141 186
       currentGroupId: '',
@@ -219,6 +264,86 @@ export default {
219 264
       this.pagination.page = 1
220 265
       this.handleGetData()
221 266
     },
267
+
268
+    // 监听点击"导出"按钮
269
+    async onClickExport() {
270
+      this.msgExport.visible = true
271
+    },
272
+    handleExport(list) {
273
+      console.log('list => ', list)
274
+      let tHeader = []
275
+      let filterVal = []
276
+      let tableDatas = []
277
+
278
+      const col = this.detailsTableCol.filter(c => c.column !== 'handler')
279
+
280
+      tHeader = [
281
+        ...col.map(d => `${d.name}`),
282
+      ]
283
+
284
+      filterVal = [
285
+        ...col.map(d => `${d.column}`),
286
+      ]
287
+
288
+      tableDatas = [
289
+        ...list,
290
+      ]
291
+
292
+      const excelDatas = [
293
+        {
294
+          tHeader, // sheet表一头部
295
+          filterVal, // 表一的数据字段
296
+          tableDatas, // 表一的整体json数据
297
+          sheetName: ''// 表一的sheet名字
298
+        }
299
+      ]
300
+      this.$exportOrder({ excelDatas, name: `系统消息(导出时间:${this.$getDay(0)})` })
301
+    },
302
+    handleGetDays() {
303
+      const st = this.$moment(this.msgExport.time[0])
304
+      const et = this.$moment(this.msgExport.time[1])
305
+      return et.diff(st, 'days')
306
+    },
307
+    async handleConfirmExport() {
308
+      if (!this.msgExport.time || !this.msgExport.time.length) {
309
+        return this.$message.warning('请选择导出日期')
310
+      }
311
+      const days = this.handleGetDays()
312
+      if (days > 1) {
313
+        return this.$message.warning('日期范围最多可选2天')
314
+      }
315
+
316
+      this.msgExport.loading = true
317
+      try {
318
+        const params = {
319
+          sys_group_id: this.filter.sys_group_id,
320
+          start_date: this.msgExport.time[0],
321
+          end_date: this.msgExport.time[1],
322
+          corp_id: this.filter.corpid,
323
+          user_name: this.filter.user_name,
324
+          msg_type: this.filter.msg_type,
325
+          page: 1,
326
+          page_size: -1, // -1 后端不限制条数
327
+        }
328
+        const url = `${this.URL.BASEURL}${this.URL.system_sendNoticeListNew}`
329
+        const { data: res = {} } = await this.$axios.get(url, { params })
330
+        if (res && res.errno == 0) {
331
+          this.handleExport(res.rst.data)
332
+          this.msgExport.visible = false
333
+          this.msgExport.time = []
334
+        } else if (res.errno != 4002) {
335
+          this.$message.warning(res.err)
336
+        }
337
+      } catch (error) {
338
+        console.log('error => ', error)
339
+      } finally {
340
+        this.msgExport.loading = false
341
+      }
342
+    },
343
+    handleCancelExport() {
344
+      this.msgExport.visible = false
345
+    },
346
+
222 347
     // 监听点击"重置"按钮
223 348
     onClickReset() {
224 349
       this.reset = !this.reset
@@ -287,12 +412,61 @@ export default {
287 412
       this.isShowDetailZNQF = false
288 413
       this.isShowRuleKHPYQ = false
289 414
     },
415
+
416
+
290 417
   },
291 418
 }
292 419
 </script>
293 420
 
294 421
 <style lang="scss" scoped>
295 422
 @import "@/style/list.scss";
423
+.export-dialog {
424
+  /deep/ .el-dialog__body {
425
+    max-height: 380px;
426
+    overflow-y: auto;
427
+  }
428
+  .form-wrap {
429
+    padding-right: 20px;
430
+    .form-item {
431
+      display: flex;
432
+      align-items: center;
433
+      margin-top: 20px;
434
+      &.flex-align-start {
435
+        align-items: flex-start;
436
+      }
437
+      &:first-child {
438
+        margin-top: 0;
439
+      }
440
+      .tips {
441
+        font-size: 13px;
442
+        color: #FFB055;
443
+        margin-left: 10px;
444
+      }
445
+      .lable {
446
+        width: 80px;
447
+        font-weight: 500;
448
+        flex-shrink: 0;
449
+        text-align: right;
450
+        margin-right: 20px;
451
+
452
+        &.required {
453
+          &::before {
454
+            position: relative;
455
+            right: 2px;
456
+            content: "*";
457
+            color: #f56c6c;
458
+          }
459
+        }
460
+      }
461
+      .el-select {
462
+        width: 430px;
463
+      }
464
+    }
465
+  }
466
+  .dialog-footer {
467
+    text-align: center;
468
+  }
469
+}
296 470
 .customerStaff-wrap {
297 471
   position: relative;
298 472
   min-height: calc(100vh - 70px);
@@ -306,6 +480,7 @@ export default {
306 480
     background: #fff;
307 481
     padding: 5px 20px 10px;
308 482
     position: relative;
483
+    align-items: flex-start;
309 484
     .common-screen-item {
310 485
       width: auto;
311 486
     }
@@ -365,5 +540,6 @@ export default {
365 540
       }
366 541
     }
367 542
   }
543
+
368 544
 }
369 545
 </style>

+ 1 - 1
project/src/router/allRouter.js

@@ -37,7 +37,7 @@ const warningListInstall = () => import(/* webpackChunkName: 'warningListInstall
37 37
 const permissionManage = () => import(/* webpackChunkName: 'permissionManage' */ '@/components/manage/permissionManage.vue')
38 38
 const roleManage = () => import(/* webpackChunkName: 'roleManage' */ '@/components/manage/roleManage.vue')
39 39
 const menuManage = () => import(/* webpackChunkName: 'menuManage' */ '@/components/manage/menuManage.vue')
40
-const systemMsg = () => import(/* webpackChunkName: 'systemMsg' */ '@/components/manage/systemMsg.vue')
40
+const systemMsg = () => import(/* webpackChunkName: 'systemMsg' */ '@/components/manage/systemMsg/index.vue')
41 41
 const feedback = () => import(/* webpackChunkName: 'feedback' */ '@/components/feedback/index.vue')
42 42
 const orderPercent = () => import(/* webpackChunkName: 'orderPercent' */ '@/components/manage/orderPercent/index.vue')
43 43
 const thePublic = () => import(/* webpackChunkName: 'thePublic' */ '@/components/dataBoard/thePublic.vue')