Browse Source

feat: 智能推送 - 推送模板分组

zhengxy 1 year ago
parent
commit
160ba6b4c6

+ 37 - 6
project/src/components/smartPushV3/createMassMsg.vue

@@ -13,7 +13,12 @@
13 13
       <div class="regulations" style="margin-bottom:20px;">
14 14
         <label>选择模板</label>
15 15
         <div>
16
-          <el-select v-model="selectedTempId" class="select-cls" style="width:300px;" size="small" placeholder="请选择" filterable @change="onChangeTempId">
16
+          <el-select v-model="tempGroupId" class="select-cls" style="width:200px;" size="small" placeholder="请选择模板分组" filterable @change="onChangeTempGroupId">
17
+            <el-option v-for="tempGroup in tempGroupOptions" :key="tempGroup.group_id" :label="tempGroup.title" :value="tempGroup.group_id" />
18
+          </el-select>
19
+        </div>
20
+        <div style="margin-left:10px;">
21
+          <el-select v-model="selectedTempId" class="select-cls" style="width:200px;" size="small" placeholder="请选择模板" filterable @change="onChangeTempId">
17 22
             <el-option v-for="temp in templateOptions" :key="temp.template_id" :label="temp.title" :value="temp.template_id" />
18 23
           </el-select>
19 24
         </div>
@@ -179,7 +184,7 @@ import { getIntegerNumber, isJSON } from '@/assets/js/common'
179 184
 
180 185
 export default {
181 186
   components: { selfChannel, selfCustomerservice, customerServiceCorpV2, datePicker, enterpriseTag, editCon, screenPay, pushGroupDialog },
182
-  props: ['title', 'rule_id', 'isCopy', 'createTemplateId'],
187
+  props: ['title', 'rule_id', 'isCopy', 'createTempGroupId', 'createTemplateId'],
183 188
   data () {
184 189
     return {
185 190
       loading: true,
@@ -217,8 +222,10 @@ export default {
217 222
       oldParams: {}, // 复制对象的参数 => 用于新旧参数比较 判断用户是否做出修改
218 223
       detailFromApi: Object.freeze({}), // 后端返回的详情完整数据
219 224
 
220
-      selectedTempId: '',
221
-      templateOptions: [],
225
+      tempGroupId: '', // 模板分组id
226
+      tempGroupOptions: [], // 模板分组选项
227
+      selectedTempId: '', // 已选模板id
228
+      templateOptions: [], // 模板选项
222 229
 
223 230
       group_id: '',
224 231
       groupOptions: [],
@@ -237,7 +244,7 @@ export default {
237 244
     },
238 245
   },
239 246
   created () {
240
-    this.handleGetTemplateOptions()
247
+    this.handleGetTempGroupOptions()
241 248
     this.handleGetGroupOptions()
242 249
 
243 250
     if (this.rule_id) {//详情
@@ -247,6 +254,10 @@ export default {
247 254
       this.isShowEditCon = true;
248 255
     }
249 256
 
257
+    if (this.createTempGroupId || String(this.createTempGroupId) === '0') {
258
+      this.tempGroupId = this.createTempGroupId
259
+      this.handleGetTemplateOptions()
260
+    }
250 261
     if (this.createTemplateId) { // 根据指定模板创建
251 262
       this.onChangeTempId(this.createTemplateId)
252 263
     }
@@ -707,8 +718,28 @@ export default {
707 718
       this.pushGroupVisible = false
708 719
     },
709 720
 
721
+    async handleGetTempGroupOptions() {
722
+      const params = { status: 1, page: 1, page_size: 1000 }
723
+      const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.smartPushV3_tempGroupList, params)
724
+      if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
725
+        this.tempGroupOptions = [
726
+          { group_id: 0, title: '未分组' },
727
+          ...res.rst.data
728
+        ]
729
+      } else if (res.errno != 4002) {
730
+        this.$message.warning(res.err)
731
+        this.tempGroupOptions = [];
732
+      }
733
+    },
734
+    onChangeTempGroupId(tempGroupId) {
735
+      this.selectedTempId = ''
736
+      this.templateOptions = []
737
+      this.tempGroupId = tempGroupId
738
+      this.handleGetTemplateOptions()
739
+    },
740
+
710 741
     async handleGetTemplateOptions() {
711
-      const params = { group_id: this.$route.query.group_id, status: 1, page: 1, page_size: 1000 }
742
+      const params = { group_id: this.tempGroupId, status: 1, page: 1, page_size: 1000 }
712 743
       const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.smartPushV3_templateList, { params })
713 744
       if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
714 745
         this.templateOptions = res.rst.data;

+ 9 - 1
project/src/components/smartPushV3/detailList.vue

@@ -2,7 +2,7 @@
2 2
   <div v-loading="loading">
3 3
     <div class="screenBox" style="align-items: center;padding-right:16px">
4 4
       <div class="flex-align-center" style="flex:1">
5
-        <div @click="$router.go(-1)">
5
+        <div @click="onClickBack">
6 6
           <i class="el-icon-back" />
7 7
         </div>
8 8
         <div v-if="groupName" style="margin:10px;">分组【{{ groupName }}】详情</div>
@@ -153,6 +153,14 @@ export default {
153 153
     }
154 154
   },
155 155
   methods: {
156
+    onClickBack() {
157
+      this.$router.replace({
158
+        path: 'smartPushV3',
159
+        query: {
160
+          tag: 1
161
+        }
162
+      })
163
+    },
156 164
     detailClose (val) {
157 165
       if (val == 'update') {//编辑
158 166
         this.init(this.page)

+ 1 - 1
project/src/components/smartPushV3/index.vue

@@ -19,7 +19,7 @@ export default {
19 19
   components: { pushGroupList, templateGroupList, },
20 20
   data() {
21 21
     return {
22
-      tagType: 1
22
+      tagType: this.$route.query.tag || 1,
23 23
     }
24 24
   },
25 25
   methods:{

+ 14 - 2
project/src/components/smartPushV3/templateList.vue

@@ -2,7 +2,7 @@
2 2
   <div v-loading="loading">
3 3
     <div class="screenBox" style="align-items: center;padding-right:16px">
4 4
       <div class="flex-align-center" style="flex:1">
5
-        <div @click="$router.go(-1)">
5
+        <div @click="onClickBack">
6 6
           <i class="el-icon-back" />
7 7
         </div>
8 8
         <div v-if="groupName" style="margin:10px;">模板分组【{{ groupName }}】详情</div>
@@ -70,6 +70,7 @@
70 70
       <createMassMsg
71 71
         v-if="createMassMsgFlag"
72 72
         ref="createMassMsg"
73
+        :createTempGroupId="detail_template_group_id"
73 74
         :createTemplateId="detail_template_id"
74 75
         title="新建智能推送"
75 76
         @close="createMassMsgClose"
@@ -110,6 +111,7 @@ export default {
110 111
       create_time_end: '',//创建时间 截止
111 112
       resetFlag: false,//重置
112 113
       height: '',
114
+      detail_template_group_id: '',
113 115
       detail_template_id: '',
114 116
       title: '',
115 117
 
@@ -125,6 +127,14 @@ export default {
125 127
     this.init(1)
126 128
   },
127 129
   methods: {
130
+    onClickBack() {
131
+      this.$router.replace({
132
+        path: 'smartPushV3',
133
+        query: {
134
+          tag: 2
135
+        }
136
+      })
137
+    },
128 138
     detailClose (val) {
129 139
       if (val == 'update') {//编辑
130 140
         this.init(this.page)
@@ -178,12 +188,14 @@ export default {
178 188
         this.$loading(this.$loadingConfig).close();
179 189
       }
180 190
     },
181
-    // 监听点击"推送记录"
191
+    // 监听点击"创建智能推送"
182 192
     onClickCreateSmartPush (data) {
193
+      this.detail_template_group_id = data.group_id
183 194
       this.detail_template_id = data.template_id
184 195
       this.createMassMsgFlag = true
185 196
     },
186 197
     createMassMsgClose() {
198
+      this.detail_template_group_id = ''
187 199
       this.detail_template_id = ''
188 200
       this.createMassMsgFlag = false
189 201
       this.$refs.multipleTable.bodyWrapper.scrollTop = 0;