Browse Source

feat: 下拉选择组件 - 支持多选&交互逻辑

zhengxy 1 year ago
parent
commit
45a1888860

+ 141 - 178
project/src/components/assembly/screen/channelV2.vue

@@ -11,6 +11,9 @@
11 11
       :clearable="clearable"
12 12
       filterable
13 13
       :disabled="disabled"
14
+      :multiple="multiple"
15
+      :collapse-tags="collapseTags"
16
+      :multiple-limit="multipleLimit"
14 17
       @change="onChangeResultVal"
15 18
     >
16 19
       <el-option v-for="item in options" :key="item.key" :label="item.val" :value="item.key" />
@@ -28,7 +31,7 @@ import {
28 31
 export default {
29 32
   props: {
30 33
     value: {
31
-      type: String | Number,
34
+      type: String | Number | Array,
32 35
       default: () => '',
33 36
     },
34 37
     clearable: {
@@ -62,6 +65,18 @@ export default {
62 65
       type: String,
63 66
       default: () => ''
64 67
     },
68
+    multiple: {
69
+      type: Boolean,
70
+      default: () => false,
71
+    },
72
+    collapseTags: {
73
+      type: Boolean,
74
+      default: () => false,
75
+    },
76
+    multipleLimit: {
77
+      type: Number,
78
+      default: () => 0
79
+    },
65 80
   },
66 81
   data () {
67 82
     return {
@@ -143,218 +158,166 @@ export default {
143 158
         });
144 159
       }
145 160
     },
146
-    getMpAccountHSList() { // 花生平台 MP账号
147
-      this.$axios.get(this.URL.BASEURL + this.URL.dataBoardHS_wxAccountList, {
161
+    async getMpAccountHSList() { // 花生平台 MP账号
162
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.dataBoardHS_wxAccountList, {
148 163
         params: {
149 164
           is_select: 1
150 165
         }
151
-      }).then((res) => {
152
-        var res = res.data
153
-        if (res && res.errno == 0) {
154
-          this.options = res.rst
155
-          this.options.forEach((item) => {
156
-            item.val = item.account_name
157
-            item.key = item.wechat_account_id
158
-          });
159
-        } else if (res.errno != 4002) {
160
-        }
161
-      }).catch((err) => {
162
-      });
166
+      })
167
+      if (res && res.errno == 0) {
168
+        this.options = res.rst
169
+        this.options.forEach((item) => {
170
+          item.val = item.account_name
171
+          item.key = item.wechat_account_id
172
+        });
173
+      }
163 174
     },
164
-    getPlatformList() { // 平台选项
165
-      this.$axios.post(this.URL.BASEURL + this.URL.getPlatformOptions, {}).then((res) => {
166
-        var res = res.data
167
-        if (res && res.errno == 0) {
168
-          this.options = res.rst
169
-          this.options.forEach((item) => {
170
-            item.val = item.platform_name
171
-            item.key = item.platform_id
172
-          });
173
-          this.$emit('platformList', res.rst)
174
-        } else if (res.errno != 4002) {
175
-        }
176
-      }).catch((err) => {
177
-      });
175
+    async getPlatformList() { // 平台选项
176
+      const { data: res = {} } = await this.$axios.post(this.URL.BASEURL + this.URL.getPlatformOptions, {})
177
+      if (res && res.errno == 0) {
178
+        this.options = res.rst
179
+        this.options.forEach((item) => {
180
+          item.val = item.platform_name
181
+          item.key = item.platform_id
182
+        });
183
+        this.$emit('platformList', res.rst)
184
+      }
178 185
     },
179
-    getAdqAccountList() { // ADQ账号选项
180
-      this.$axios.get(this.URL.BASEURL + this.URL.adqAccount_list, {
186
+    async getAdqAccountList() { // ADQ账号选项
187
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.adqAccount_list, {
181 188
         params: {
182 189
           is_select: 1
183 190
         }
184
-      }).then((res) => {
185
-        var res = res.data
186
-        if (res && res.errno == 0) {
187
-          this.options = res.rst
188
-          this.options.forEach((item) => {
189
-            item.val = item.account_id
190
-            item.key = item.account_id
191
-          });
192
-        } else if (res.errno != 4002) {
193
-        }
194
-      }).catch((err) => {
195
-      });
191
+      })
192
+      if (res && res.errno == 0) {
193
+        this.options = res.rst
194
+        this.options.forEach((item) => {
195
+          item.val = item.account_id
196
+          item.key = item.account_id
197
+        });
198
+      }
196 199
     },
197
-    getAllAccountList() { // 总表账号选项
198
-      this.$axios.get(this.URL.BASEURL + this.URL.dataBoard_allAccountOptions, {
200
+    async getAllAccountList() { // 总表账号选项
201
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.dataBoard_allAccountOptions, {
199 202
         params: {
200 203
           keyword: ''
201 204
         }
202
-      }).then((res) => {
203
-        var res = res.data
204
-        if (res && res.errno == 0) {
205
-          this.options = res.rst
206
-          this.options.forEach((item) => {
207
-            item.val = item.account_name
208
-            item.key = item.account_id
209
-          });
210
-        } else if (res.errno != 4002) {
211
-        }
212
-      }).catch((err) => {
213
-      });
205
+      })
206
+      if (res && res.errno == 0) {
207
+        this.options = res.rst
208
+        this.options.forEach((item) => {
209
+          item.val = item.account_name
210
+          item.key = item.account_id
211
+        });
212
+      }
214 213
     },
215
-    getsysUserList () {
216
-      this.$axios.get(this.URL.BASEURL + this.URL.getsysUserList, {
214
+    async getsysUserList () {
215
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.getsysUserList, {
217 216
         params: {
218 217
           ...this.afferent_params
219 218
         }
220
-      }).then((res) => {
221
-        var res = res.data
222
-        if (res && res.errno == 0) {
223
-          this.options = res.rst
224
-          this.options.forEach((item) => {
225
-            item.val = item.name;
226
-            item.key = item.admin_id
227
-          });
228
-        } else if (res.errno != 4002) {
229
-        }
230
-      }).catch((err) => {
231
-      });
219
+      })
220
+      if (res && res.errno == 0) {
221
+        this.options = res.rst
222
+        this.options.forEach((item) => {
223
+          item.val = item.name;
224
+          item.key = item.admin_id
225
+        });
226
+      }
232 227
     },
233
-    init () {
234
-      this.$axios.get(this.URL.BASEURL + this.URL.addWayList, {}).then((res) => {
235
-        var res = res.data
236
-        if (res && res.errno == 0) {
237
-          this.options = res.rst
238
-        } else if (res.errno != 4002) {
239
-        }
240
-      }).catch((err) => {
241
-      });
228
+    async init () {
229
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.addWayList, {})
230
+      if (res && res.errno == 0) {
231
+        this.options = res.rst
232
+      }
242 233
     },
243
-    thePublic_init () {
244
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_wxAccountList, {
234
+    async thePublic_init () {
235
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_wxAccountList, {
245 236
         params: {
246 237
           is_select: 1,
247 238
         }
248
-      }).then((res) => {
249
-        var res = res.data
250
-        if (res && res.errno == 0) {
251
-          this.options = res.rst
252
-          this.options.forEach((item) => {
253
-            item.val = item.account_name;
254
-            item.key = item.wechat_account_id
255
-          });
256
-        } else if (res.errno != 4002) {
257
-        }
258
-      }).catch((err) => {
259
-      });
239
+      })
240
+      if (res && res.errno == 0) {
241
+        this.options = res.rst
242
+        this.options.forEach((item) => {
243
+          item.val = item.account_name;
244
+          item.key = item.wechat_account_id
245
+        });
246
+      }
260 247
     },
261
-    getOfficialAccount () {
262
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_officialAccountsList, {
248
+    async getOfficialAccount () {
249
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_officialAccountsList, {
263 250
         params: {
264 251
           is_select: 1,
265 252
         }
266
-      }).then((res) => {
267
-        var res = res.data
268
-        if (res && res.errno == 0) {
269
-          this.options = res.rst
270
-          this.options.forEach((item) => {
271
-            item.val = item.account_name;
272
-            item.key = item.wechat_account_id
273
-          });
274
-        } else if (res.errno != 4002) {
275
-        }
276
-      }).catch((err) => {
277
-      });
253
+      })
254
+      if (res && res.errno == 0) {
255
+        this.options = res.rst
256
+        this.options.forEach((item) => {
257
+          item.val = item.account_name;
258
+          item.key = item.wechat_account_id
259
+        });
260
+      }
278 261
     },
279
-    dramaList_init () {
280
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_dramaList, {
262
+    async dramaList_init () {
263
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_dramaList, {
281 264
         params: {
282 265
           is_select: 1
283 266
         }
284
-      }).then((res) => {
285
-        var res = res.data
286
-        if (res && res.errno == 0) {
287
-          this.options = res.rst
288
-          this.options.forEach((item) => {
289
-            item.val = item.name;
290
-            item.key = item.id
291
-          });
292
-        } else if (res.errno != 4002) {
293
-        }
294
-      }).catch((err) => {
295
-      });
267
+      })
268
+      if (res && res.errno == 0) {
269
+        this.options = res.rst
270
+        this.options.forEach((item) => {
271
+          item.val = item.name;
272
+          item.key = item.id
273
+        });
274
+      }
296 275
     },
297
-    popularizCompanys_init () {
298
-      this.$axios.get(this.URL.BASEURL + this.URL.stat_popularizCompanys, {
276
+    async popularizCompanys_init () {
277
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.stat_popularizCompanys, {
299 278
         params: this.afferent_params
300
-      }).then((res) => {
301
-        var res = res.data
302
-        if (res && res.errno == 0) {
303
-          this.options = res.rst
304
-          this.options.forEach((item) => {
305
-            item.val = item.principalName;
306
-            item.key = item.principalName
307
-          });
308
-        } else if (res.errno != 4002) {
309
-        }
310
-      }).catch((err) => {
311
-      });
279
+      })
280
+      if (res && res.errno == 0) {
281
+        this.options = res.rst
282
+        this.options.forEach((item) => {
283
+          item.val = item.principalName;
284
+          item.key = item.principalName
285
+        });
286
+      }
312 287
     },
313
-    pitcher_init () {
314
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_pitcherList, {
288
+    async pitcher_init () {
289
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_pitcherList, {
315 290
         params: this.afferent_params
316
-      }).then((res) => {
317
-        var res = res.data
318
-        if (res && res.errno == 0) {
319
-          this.options = res.rst
320
-          this.options.forEach((item) => {
321
-            item.val = item.name;
322
-            item.key = item.id
323
-          });
324
-        } else if (res.errno != 4002) {
325
-        }
326
-      }).catch((err) => {
327
-      });
291
+      })
292
+      if (res && res.errno == 0) {
293
+        this.options = res.rst
294
+        this.options.forEach((item) => {
295
+          item.val = item.name;
296
+          item.key = item.id
297
+        });
298
+      }
328 299
     },
329
-    reportRule_init () {
330
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_reportRuleList, {
331
-      }).then((res) => {
332
-        var res = res.data
333
-        if (res && res.errno == 0) {
334
-          this.options = res.rst
335
-          this.options.forEach((item) => {
336
-            item.val = item.name;
337
-            item.key = item.id
338
-          });
339
-        } else if (res.errno != 4002) {
340
-        }
341
-      }).catch((err) => {
342
-      });
300
+    async reportRule_init () {
301
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_reportRuleList, {
302
+      })
303
+      if (res && res.errno == 0) {
304
+        this.options = res.rst
305
+        this.options.forEach((item) => {
306
+          item.val = item.name;
307
+          item.key = item.id
308
+        });
309
+      }
343 310
     },
344
-    getCorpIdList () {
345
-      this.$axios.get(this.URL.BASEURL + this.URL.pitcher_getCorpIdList, {
346
-      }).then((res) => {
347
-        var res = res.data
348
-        if (res && res.errno == 0) {
349
-          this.options = res.rst
350
-          this.options.forEach((item) => {
351
-            item.val = item.corp_name;
352
-            item.key = item.corpid
353
-          });
354
-        } else if (res.errno != 4002) {
355
-        }
356
-      }).catch((err) => {
357
-      });
311
+    async getCorpIdList () {
312
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.pitcher_getCorpIdList, {
313
+      })
314
+      if (res && res.errno == 0) {
315
+        this.options = res.rst
316
+        this.options.forEach((item) => {
317
+          item.val = item.corp_name;
318
+          item.key = item.corpid
319
+        });
320
+      }
358 321
     },
359 322
     handleGetOptions() {
360 323
       if (this.type == 'assignment_status') {

+ 13 - 3
project/src/components/manage/systemMsg.vue

@@ -8,7 +8,7 @@
8 8
       <selfSelectCorp style="margin-right: 30px;" v-model="filter.corpid" @change="onChangeCorpid" />
9 9
       <!-- 成员 -->
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.platform_id" title="平台" type="platform" labelWidth multiple collapseTags :multipleLimit="3" @change="onChangePlatform" /> -->
12 12
       <div class="reset" @click="onClickReset">重置</div>
13 13
     </div>
14 14
     <!-- E 筛选区 -->
@@ -38,17 +38,17 @@
38 38
 </template>
39 39
 
40 40
 <script>
41
-import selfChannel from '@/components/assembly/screen/channel.vue'
42 41
 import selfInputV2 from '@/components/assembly/screen/inputV2.vue'
43 42
 import selfSelectCorp from '@/components/assembly/screen/selectCorp.vue'
44 43
 import datePicker from '@/components/assembly/screen/datePicker.vue'
44
+// import selfChannelV2 from '@/components/assembly/screen/channelV2.vue'
45 45
 
46 46
 export default {
47 47
   components: {
48
-    selfChannel,
49 48
     selfInputV2,
50 49
     selfSelectCorp,
51 50
     datePicker,
51
+    // selfChannelV2,
52 52
   },
53 53
   data() {
54 54
     const DEFAULT_TIME = [this.$getDay(-30, false), this.$getDay(0, false)]
@@ -75,6 +75,7 @@ export default {
75 75
         time: DEFAULT_TIME, // 自定义日期
76 76
         corpid: '', // 企微主体
77 77
         user_name: '', // 成员
78
+        // platform_id: [], // 平台
78 79
       },
79 80
     }
80 81
   },
@@ -96,6 +97,7 @@ export default {
96 97
           end_date: this.filter.time[1],
97 98
           corp_id: this.filter.corpid,
98 99
           user_name: this.filter.user_name,
100
+          // platform_id: this.filter.platform_id,
99 101
           page: this.pagination.page,
100 102
           page_size: this.pagination.page_size,
101 103
         }
@@ -143,12 +145,20 @@ export default {
143 145
       this.pagination.page = 1
144 146
       this.handleGetData()
145 147
     },
148
+    // // 监听平台选择变化
149
+    // onChangePlatform(val) {
150
+    //   console.log('onChangePlatform => ', val)
151
+    //   this.filter.platform_id = val
152
+    //   this.pagination.page = 1
153
+    //   this.handleGetData()
154
+    // },
146 155
     // 监听点击"重置"按钮
147 156
     onClickReset() {
148 157
       this.reset = !this.reset
149 158
       this.filter.time = this.default_time
150 159
       this.filter.corpid = ''
151 160
       this.filter.user_name = ''
161
+      // this.filter.platform_id = []
152 162
       this.pagination.page = 1
153 163
       this.handleGetData()
154 164
     },