Browse Source

feat: 企微助手 - 智能推送 - 推动记录&前端页面

zhengxy 2 years ago
parent
commit
6f0378c509

+ 190 - 0
project/src/components/smartPush/pushRecords.vue

@@ -0,0 +1,190 @@
1
+<template>
2
+  <div v-loading="loading">
3
+    <div class="screenBox" style="align-items: center;padding-right:16px">
4
+      <div class="flex-align-center" style="flex:1">
5
+        <!-- S 返回 -->
6
+        <div @click="$router.go(-1)">
7
+          <i class="el-icon-back" />
8
+        </div>
9
+        <!-- E 返回 -->
10
+        <datePicker title="发送时间" :reset="resetFlag" @changeTime="onChangeTime" />
11
+      </div>
12
+    </div>
13
+    <div class="tableInfo">
14
+      <div>
15
+        <div class="flex">
16
+          <div class="totalCustom">共有<span>{{total}}</span>条群发内容</div>
17
+        </div>
18
+      </div>
19
+      <div class="flex">
20
+        <el-button type="primary" plain size="mini" @click="init(1,'export')">导出Excel</el-button>
21
+      </div>
22
+    </div>
23
+    <!-- table -->
24
+    <el-table ref="multipleTable" :height="height" :data="tableData" tooltip-effect="dark" style="width: 100%">
25
+      <el-table-column prop="name" label="标题" show-overflow-tooltip align="center" min-width="120" />
26
+      <el-table-column label="创建人" align="center" min-width="120">
27
+        <template slot-scope="scope">
28
+          <div class="customerServiceTagBox">
29
+            <div class="customerServiceTag"><i class="el-icon-user-solid"></i> {{ scope.row.creator }}</div>
30
+          </div>
31
+        </template>
32
+      </el-table-column>
33
+      <el-table-column prop="name" label="规则" align="center" min-width="200" />
34
+      <el-table-column label="发送时间" prop="created_at" min-width="120" show-overflow-tooltip align="center" />
35
+      <el-table-column prop="send_success" label="送达客户数" show-overflow-tooltip align="center" min-width="120" />
36
+      <el-table-column prop="send_fail" label="失败客户数" show-overflow-tooltip align="center" min-width="120" />
37
+      <el-table-column label="操作" align="center" fixed="right" width="120">
38
+        <template slot-scope="scope">
39
+          <div class="flex" style="justify-content:center">
40
+            <div class="c-00B38A pointer table_button" @click="onClickDetail(scope.row)">详情</div>
41
+          </div>
42
+        </template>
43
+      </el-table-column>
44
+    </el-table>
45
+    <div class="pagination" v-show="total>0">
46
+      <el-pagination background :current-page="page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pages)'>
47
+      </el-pagination>
48
+    </div>
49
+    <!-- S 详情 -->
50
+    <el-drawer size="1200px" :visible.sync="detialFlag" :with-header="false">
51
+      <massMsgDetail v-if="detialFlag" title="智能推送详情" :rule_id='detail_rule_id' @close="detailClose" />
52
+    </el-drawer>
53
+    <!-- E 详情 -->
54
+  </div>
55
+</template>
56
+<script>
57
+import datePicker from '@/components/assembly/screen/datePicker.vue'
58
+import massMsgDetail from './massMsgDetail/index.vue'
59
+export default {
60
+  components: { datePicker, massMsgDetail, },
61
+  data () {
62
+    return {
63
+      detialFlag: false,
64
+      loading: false,
65
+      page: 1,
66
+      pages: 0,
67
+      total: 0,
68
+      page_size: 20,
69
+      tableData: [],
70
+      add_date_start: '',//添加日期 起始
71
+      add_date_end: '',//添加日期 截止
72
+      resetFlag: false,//重置
73
+      height: '',
74
+      detail_rule_id: '',
75
+      sort_field: 'send_time',
76
+
77
+      rule_id: '',
78
+    }
79
+  },
80
+  created () {
81
+    this.height = document.documentElement.clientHeight - 260 > 400 ? document.documentElement.clientHeight - 260 : 400
82
+    const { rule_id } = this.$route.query
83
+    this.rule_id = rule_id
84
+    this.init(1)
85
+  },
86
+  methods: {
87
+    detailClose (val) {
88
+      if (val == 'update') {//编辑
89
+        this.init(this.page)
90
+      } else if (val == 'update_new') {//复制或者新建
91
+        this.sort_field = 'created_at'
92
+        this.init(1)
93
+        this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
94
+      }
95
+      this.detialFlag = false
96
+    },
97
+    // 监听点击"详情"
98
+    onClickDetail (data) {
99
+      this.detail_rule_id = data.rule_id;
100
+      this.detialFlag = true
101
+    },
102
+    //筛选时间变化
103
+    onChangeTime(time) {
104
+      if (!time || time && time.length == 0) {
105
+        this.add_date_start = '';
106
+        this.add_date_end = '';
107
+      } else {
108
+        this.add_date_start = time[0]
109
+        this.add_date_end = time[1]
110
+      }
111
+      this.init(1)
112
+    },
113
+    // 获取列表数据
114
+    init (page, type) {
115
+      if (type != 'export') {
116
+        this.page = page ? page : this.page;
117
+      } else {
118
+        if (this.total == 0) {
119
+          this.$message({
120
+            message: '暂无数据可导出',
121
+            type: "warning"
122
+          })
123
+          return
124
+        }
125
+      }
126
+      this.loading = true
127
+      const params = {
128
+        send_time_start: this.add_date_start ? this.add_date_start + ' 00:00:00' : '',
129
+        send_time_end: this.add_date_end ? this.$day_format(this.$date_compatible(this.add_date_end + ' 24:00:00')) : '',
130
+        page: type == 'export' ? 1 : this.page,
131
+        page_size: type == 'export' ? this.$store.state.exportNumber : this.page_size,
132
+        sort_column: this.sort_field,
133
+      }
134
+      this.$axios.get(this.URL.BASEURL + this.URL.massMsg_lists, {
135
+        params
136
+      }).then((res) => {
137
+        var res = res.data
138
+        this.loading = false
139
+        if (res && res.errno == 0) {
140
+          if (type == 'export') {
141
+            this.exportEvent(res.rst.data)
142
+          } else {
143
+            this.tableData = res.rst.data;
144
+            this.total = res.rst.pageInfo.total;
145
+            this.pages = res.rst.pageInfo.pages;
146
+          }
147
+        } else if (res.errno != 4002) {
148
+          this.$message({
149
+            message: res.err,
150
+            type: "warning"
151
+          })
152
+        }
153
+      }).catch((err) => {
154
+        this.loading = false
155
+      });
156
+    },
157
+    handleCurrentChange (val) {
158
+      this.init(val)
159
+    },
160
+    exportEvent (data) {
161
+      let list = data;
162
+      let tHeader = ['企业ID', '群发标题', '发送类型', '发送时间', '消息文本内容', '附件信息', '发送状态', '消息内容总数', '创建人', '消息送达数', '消息发送失败数', '总发送数']
163
+      let filterVal = ['corpid', 'name', 'send_type_name', 'send_time', 'content', 'attachments', 'enable_name', 'msg_count', 'creator', 'send_success', 'send_fail', 'send_total']
164
+      list.forEach((item) => {
165
+        item.send_type_name = item.send_type == 1 ? '立即发送' : item.send_type == 2 ? '定时发送' : '';
166
+        item.enable_name = item.enable == -2 ? '已删除' : item.enable == -1 ? '发送失败' : item.enable == 1 ? '待发送' : item.enable == 2 ? '正在发送中' : item.enable == 3 ? '发送完成' : ''
167
+      })
168
+      let excelDatas = [
169
+        {
170
+          tHeader: tHeader, // sheet表一头部
171
+          filterVal: filterVal, // 表一的数据字段
172
+          tableDatas: list, // 表一的整体json数据
173
+          sheetName: ''// 表一的sheet名字
174
+        }
175
+      ]
176
+      this.$exportOrder({ excelDatas, name: `员工群发消息(导出时间:${this.$getDay(0)})` })
177
+    }
178
+  }
179
+}
180
+</script>
181
+<style lang="scss" scoped>
182
+@import "@/style/list.scss";
183
+.tableInfo {
184
+  height: 50px;
185
+}
186
+.table_button {
187
+  margin: 0 4px;
188
+  min-width: 26px;
189
+}
190
+</style>

+ 9 - 8
project/src/components/smartPush/ruleList.vue

@@ -38,7 +38,7 @@
38 38
         <template slot-scope="scope">
39 39
           <div class="flex" style="justify-content:center">
40 40
             <div class="c-00B38A pointer table_button" @click="onClickEditRule(scope.row)">编辑</div>
41
-            <div class="c-00B38A pointer table_button" @click="onClickEditRule(scope.row)">推送记录</div>
41
+            <div class="c-00B38A pointer table_button" @click="onClickPushRecords(scope.row)">推送记录</div>
42 42
           </div>
43 43
         </template>
44 44
       </el-table-column>
@@ -57,21 +57,16 @@
57 57
         @close="detailClose"
58 58
       />
59 59
     </el-drawer>
60
-    <el-drawer size="1200px" :visible.sync="detialFlag" :with-header="false">
61
-      <massMsgDetail v-if="detialFlag" title="群发详情" :rule_id='detail_rule_id' @close="detailClose"></massMsgDetail>
62
-    </el-drawer>
63 60
   </div>
64 61
 </template>
65 62
 <script>
66 63
 import datePicker from '@/components/assembly/screen/datePicker.vue'
67 64
 import selfChannel from '@/components/assembly/screen/channel.vue'
68 65
 import createMassMsg from './createMassMsg.vue'
69
-import massMsgDetail from './massMsgDetail/index.vue'
70 66
 export default {
71
-  components: { datePicker, selfChannel, createMassMsg, massMsgDetail, },
67
+  components: { datePicker, selfChannel, createMassMsg, },
72 68
   data () {
73 69
     return {
74
-      detialFlag: false,
75 70
       massMsgFlag: false,
76 71
       loading: false,
77 72
       page: 1,
@@ -102,7 +97,6 @@ export default {
102 97
         this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
103 98
       }
104 99
       this.massMsgFlag = false
105
-      this.detialFlag = false
106 100
     },
107 101
     // 监听点击"新建智能推送"规则
108 102
     onClickCreatedRule () {
@@ -114,6 +108,13 @@ export default {
114 108
       this.detail_rule_id = data.rule_id;
115 109
       this.massMsgFlag = true
116 110
     },
111
+    // 监听点击"推送记录"
112
+    onClickPushRecords (data) {
113
+      this.$router.push({
114
+        path: '/pushRecords',
115
+        query: { rule_id: data.rule_id }
116
+      })
117
+    },
117 118
     // 开启状态
118 119
     welcomeMsg_del (item) {
119 120
       if (item.enable != 1 && item.enable != 0) {

+ 11 - 0
project/src/router/allRouter.js

@@ -8,6 +8,7 @@ const homeData = () => import(/* webpackChunkName: 'homeData' */'@/components/Ho
8 8
 const customManage = () => import(/* webpackChunkName: 'customManage' */ '@/components/customManage/manage.vue')
9 9
 const employee_bulk_messaging_log = () => import(/* webpackChunkName: 'employee_bulk_messaging_log' */ '@/components/customOperate/employee_bulk_messaging_log.vue')
10 10
 const smartPush = () => import(/* webpackChunkName: 'smartPush' */ '@/components/smartPush/ruleList.vue')
11
+const pushRecords = () => import(/* webpackChunkName: 'pushRecords' */ '@/components/smartPush/pushRecords.vue')
11 12
 const sop = () => import(/* webpackChunkName: 'sop' */ '@/components/sop/index.vue')
12 13
 const createSop = () => import(/* webpackChunkName: 'createSop' */ '@/components/sop/createSop.vue')
13 14
 const chatGroup = () => import(/* webpackChunkName: 'chatGroup' */ '@/components/customOperate/chatGroup/index.vue')
@@ -305,6 +306,16 @@ export var allRouter = [
305 306
         }
306 307
       },
307 308
       {
309
+        path: 'pushRecords',
310
+        name: 'smartPush',
311
+        component: pushRecords,
312
+        meta: {
313
+          keepAlive: false,
314
+          isLogin: true,
315
+          title: '推送记录'
316
+        }
317
+      },
318
+      {
308 319
         path: 'sop',
309 320
         name: 'sop',
310 321
         component: sop,