Browse Source

feat: 智能推送 - 批量分组

zhengxy 1 year ago
parent
commit
a369c6c540

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

@@ -384,6 +384,7 @@ var api = {
384 384
   smartPushV3_groupList: "/api/PeriodMassMsg/groupList", // 企微助手 - 智能推送V3 - 分组列表
385 385
   smartPushV3_changeGroupStatus: "/api/PeriodMassMsg/changeGroupStatus", // 企微助手 - 智能推送V3 - 分组状态
386 386
   smartPushV3_editGroup: "/api/PeriodMassMsg/editGroup", // 企微助手 - 智能推送V3 - 新建/编辑模板
387
+  smartPushV3_changeGroupBatch: "/api/PeriodMassMsg/changeGroupBatch", // 企微助手 - 智能推送V3 - 批量设置分组
387 388
 
388 389
   dataBoardHS_adqAccountList: "/api/provisionalStat/adqAccountList", // 花生平台 - adq账号授权列表
389 390
   dataBoardHS_wxAccountList: "/api/provisionalStat/wxAccountList", // 花生平台 - mp账号授权列表

+ 219 - 0
project/src/components/smartPushV3/batchGroupDialog.vue

@@ -0,0 +1,219 @@
1
+<template>
2
+  <el-dialog
3
+    :visible.sync="dialogVisible"
4
+    :before-close="handleCancel"
5
+    class="bind-dialog"
6
+    :title="dialogTitle"
7
+    width="500px"
8
+    :close-on-click-modal="false"
9
+    :append-to-body="true"
10
+  >
11
+    <div class="form-wrap" v-loading="loading">
12
+      <div class="form-item">
13
+        <span class="lable required">分组</span>
14
+        <div>
15
+          <el-select v-model="form.group_id" class="select-cls" style="width:280px;" size="small" placeholder="请选择" filterable clearable @change="onChangeGroupId">
16
+            <el-option v-for="group in groupOptions" :key="group.group_id" :label="group.title" :value="group.group_id" />
17
+          </el-select>
18
+        </div>
19
+        <div class="newGroupCss" @click="onClickCreateGroup">新建分组</div>
20
+      </div>
21
+    </div>
22
+    <div slot="footer" class="dialog-footer">
23
+      <el-button size="mini" @click="handleCancel">取 消</el-button>
24
+      <el-button size="mini" type="primary" @click="handleConfirm">确 定</el-button>
25
+    </div>
26
+
27
+    <!-- S 编辑分组弹框 -->
28
+    <pushGroupDialog
29
+      :dialogVisible="pushGroupVisible"
30
+      @confirm="onConfirmGroup"
31
+      @cancel="onCancelGroup"
32
+    />
33
+    <!-- E 编辑分组弹框 -->
34
+  </el-dialog>
35
+</template>
36
+
37
+<script>
38
+import pushGroupDialog from './pushGroupDialog.vue'
39
+
40
+export default {
41
+  name: "batchGroupDialog",
42
+  components: { pushGroupDialog },
43
+  props: {
44
+    // 控制弹框是否显示
45
+    dialogVisible: {
46
+      type: Boolean,
47
+      default: () => false
48
+    },
49
+    rule_ids: {
50
+      type: String,
51
+      default: () => ''
52
+    },
53
+  },
54
+  data() {
55
+    return {
56
+      loading: false,
57
+      form: {
58
+        group_id: '',
59
+      },
60
+      groupOptions: [],
61
+      pushGroupVisible: false,
62
+    }
63
+  },
64
+  computed: {
65
+    dialogTitle() {
66
+      return '批量设置分组'
67
+    },
68
+  },
69
+  watch: {
70
+    dialogVisible(isShow) {
71
+      if (isShow) {
72
+        this.handleGetGroupOptions()
73
+        // 获取表单数据
74
+        // this.handleGetFormData()
75
+      }
76
+    },
77
+  },
78
+  methods: {
79
+    async handleConfirm() {
80
+      try {
81
+        // 表单校验
82
+        await this.handleFormValidate()
83
+        const url = `${this.URL.BASEURL}${this.URL.smartPushV3_changeGroupBatch}`
84
+        const params = {
85
+          group_id: this.form.group_id,
86
+          rule_ids: this.rule_ids,
87
+        }
88
+        this.loading = true
89
+        const { data: res = {} } = await this.$axios.post(url, params)
90
+        if (res && res.errno == 0) {
91
+          this.$message.success('操作成功')
92
+          this.handleClearFormData()
93
+          this.$emit('confirm')
94
+        } else if (res.errno != 4002) {
95
+          this.$message.warning(res.err || '操作失败')
96
+        }
97
+      } catch (error) {
98
+        console.log('error => ', error)
99
+      } finally {
100
+        this.loading = false
101
+      }
102
+    },
103
+    handleCancel() {
104
+      this.handleClearFormData()
105
+      this.$emit('cancel')
106
+    },
107
+    // 执行表单校验
108
+    handleFormValidate() {
109
+      return new Promise((resolve, reject) => {
110
+        if (!this.form.group_id) {
111
+          this.$message.warning('请选择分组')
112
+          reject('表单校验未通过')
113
+        } else {
114
+          resolve('表单校验通过')
115
+        }
116
+      })
117
+    },
118
+    // 获取表单数据
119
+    // handleGetFormData() {
120
+    //   this.form.title = title
121
+    // },
122
+    // 清空弹框表单数据
123
+    handleClearFormData() {
124
+      this.form.group_id = ''
125
+    },
126
+
127
+    async handleGetGroupOptions() {
128
+      const params = { status: 1, page: 1, page_size: 1000 }
129
+      const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.smartPushV3_groupList, params)
130
+      if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
131
+        this.groupOptions = res.rst.data;
132
+      } else if (res.errno != 4002) {
133
+        this.$message.warning(res.err)
134
+        this.groupOptions = [];
135
+      }
136
+    },
137
+    onChangeGroupId(groupId) {
138
+      this.group_id = groupId || ''
139
+    },
140
+    onClickCreateGroup() {
141
+      this.pushGroupVisible = true
142
+    },
143
+    onConfirmGroup() {
144
+      this.handleGetGroupOptions()
145
+      this.pushGroupVisible = false
146
+    },
147
+    onCancelGroup() {
148
+      this.pushGroupVisible = false
149
+    },
150
+  },
151
+};
152
+</script>
153
+
154
+<style lang="scss" scoped>
155
+.bind-dialog {
156
+  .form-wrap {
157
+    padding: 0 10px;
158
+    .form-item {
159
+      display: flex;
160
+      align-items: center;
161
+      margin-top: 16px;
162
+      &:first-child {
163
+        margin-top: 0;
164
+      }
165
+      .lable {
166
+        width: 60px;
167
+        font-weight: 500;
168
+        flex-shrink: 0;
169
+
170
+        &.required {
171
+          position: relative;
172
+          &::before {
173
+            position: absolute;
174
+            left: -8px;
175
+            top: 0;
176
+            content: "*";
177
+            color: #f56c6c;
178
+          }
179
+        }
180
+      }
181
+      .el-select {
182
+        width: 100%;
183
+      }
184
+    }
185
+    .form-tips {
186
+      margin: 5px 0 0 80px;
187
+      font-size: 13px;
188
+      color: #999;
189
+    }
190
+  }
191
+  .dialog-footer {
192
+    text-align: center;
193
+  }
194
+}
195
+
196
+.select-cls {
197
+  /deep/ &.el-select .el-input.is-focus .el-input__inner,
198
+  /deep/ &.el-select .el-input__inner:focus {
199
+    border-color: #DCDFE6;
200
+  }
201
+  /deep/ .el-input__suffix {
202
+    border-top-right-radius: 4px;
203
+    border-bottom-right-radius: 4px;
204
+    border: 1px solid #DCDFE6;
205
+    right: 0;
206
+    width: 30px;
207
+    background-color: #F1F1F1;
208
+    .el-input__icon {
209
+      color: #909399;
210
+    }
211
+  }
212
+}
213
+.newGroupCss{
214
+  color: #00b38a;
215
+  font-size: 14px;
216
+  margin-left: 10px;
217
+  cursor: pointer;
218
+}
219
+</style>

+ 52 - 5
project/src/components/smartPushV3/detailList.vue

@@ -18,15 +18,18 @@
18 18
     <div class="tableInfo">
19 19
       <div>
20 20
         <div class="flex">
21
-          <div class="totalCustom">共有<span>{{total}}</span>条群发内容</div>
21
+          <div class="totalCustom">共有<span>{{total}}</span>条群发规则</div>
22
+          <div v-if="multipleSelection && multipleSelection.length" class="totalCustom" style="margin-left:20px;">已选择<span>{{ multipleSelection.length }}</span>条</div>
22 23
         </div>
23 24
       </div>
24 25
       <div class="flex">
26
+        <el-button type="primary" plain size="mini" @click="onClickBatchGroup">批量设置分组</el-button>
25 27
         <el-button type="primary" plain size="mini" @click="init(1,'export')">导出Excel</el-button>
26 28
       </div>
27 29
     </div>
28 30
     <!-- table -->
29
-    <el-table ref="multipleTable" :height="height" :data="tableData" tooltip-effect="dark" style="width: 100%">
31
+    <el-table ref="multipleTable" :height="height" :data="tableData" tooltip-effect="dark" style="width: 100%" row-key="rule_id" @selection-change="handleSelectionChange">
32
+      <el-table-column type="selection" reserve-selection width="55" />
30 33
       <el-table-column prop="name" label="标题" show-overflow-tooltip align="center" min-width="120" />
31 34
       <el-table-column label="创建人" align="center" min-width="120">
32 35
         <template slot-scope="scope">
@@ -77,6 +80,16 @@
77 80
         @close="detailClose"
78 81
       />
79 82
     </el-drawer>
83
+
84
+    <!-- S 批量分组 -->
85
+    <batchGroupDialog
86
+      :dialogVisible="batchGroupVisible"
87
+      :rule_ids="currentSelectedRules"
88
+      @confirm="onConfirmBatchGroup"
89
+      @cancel="onCancelBatchGroup"
90
+    />
91
+    <!-- E 批量分组 -->
92
+
80 93
   </div>
81 94
 </template>
82 95
 <script>
@@ -84,8 +97,9 @@ import datePicker from '@/components/assembly/screen/datePicker.vue'
84 97
 import selfChannel from '@/components/assembly/screen/channel.vue'
85 98
 import selfInputV2 from '@/components/assembly/screen/inputV2.vue'
86 99
 import createMassMsg from './createMassMsg.vue'
100
+import batchGroupDialog from './batchGroupDialog.vue'
87 101
 export default {
88
-  components: { datePicker, selfChannel, selfInputV2, createMassMsg, },
102
+  components: { datePicker, selfChannel, selfInputV2, createMassMsg, batchGroupDialog, },
89 103
   data () {
90 104
     return {
91 105
       massMsgFlag: false,
@@ -105,6 +119,10 @@ export default {
105 119
       keyword: '',
106 120
 
107 121
       groupName: '',
122
+
123
+      multipleSelection: [],
124
+      currentSelectedRules: '',
125
+      batchGroupVisible: false,
108 126
     }
109 127
   },
110 128
   created () {
@@ -115,17 +133,24 @@ export default {
115 133
   beforeRouteEnter(to, from, next) {
116 134
     if (from.path === '/pushRecordsV3') { // 当 from 的路由为详情页面时 => 保留筛选条件(keepAlive) => 获取列表数据
117 135
       next(vm => {
136
+        vm.tableData = []
118 137
         vm.init()
119 138
       });
120 139
     } else { // 初始化筛选条件 => 获取列表数据
121 140
       next((vm) => {
141
+        vm.tableData = []
122 142
         vm.keyword = ''
123 143
         vm.creator_id = ''
124 144
         vm.create_time_start = ''
125 145
         vm.create_time_end = ''
126 146
         vm.page = 1
127 147
         vm.resetFlag = !vm.resetFlag
128
-        vm.init(1)
148
+        vm.multipleSelection = []
149
+        vm.currentSelectedRules = ''
150
+        vm.$nextTick(() => {
151
+          vm.$refs.multipleTable && vm.$refs.multipleTable.clearSelection()
152
+          vm.init(1)
153
+        })
129 154
       })
130 155
     }
131 156
   },
@@ -296,7 +321,29 @@ export default {
296 321
         }
297 322
       ]
298 323
       this.$exportOrder({ excelDatas, name: `智能推送-规则列表(导出时间:${this.$getDay(0)})` })
299
-    }
324
+    },
325
+
326
+    handleSelectionChange(val) {
327
+      this.multipleSelection = val;
328
+    },
329
+    onClickBatchGroup() {
330
+      if (!this.multipleSelection || !this.multipleSelection.length) {
331
+        this.$message.warning('请选择推送规则')
332
+        return false
333
+      }
334
+      this.currentSelectedRules = this.multipleSelection.map(m => m.rule_id).join(',')
335
+      this.batchGroupVisible = true
336
+      console.log('this.currentSelectedRules => ', this.currentSelectedRules)
337
+    },
338
+    onConfirmBatchGroup() {
339
+      this.$refs.multipleTable.clearSelection();
340
+      this.currentSelectedRules = ''
341
+      this.init(1)
342
+      this.batchGroupVisible = false
343
+    },
344
+    onCancelBatchGroup() {
345
+      this.batchGroupVisible = false
346
+    },
300 347
   }
301 348
 }
302 349
 </script>