3
3
4
4
<!-- 搜索工作栏 -->
5
5
<ContentWrap >
6
- <el-form
7
- class =" -mb-15px"
8
- :model =" queryParams"
9
- ref =" queryFormRef"
10
- :inline =" true"
11
- label-width =" 68px"
12
- >
13
- <el-form-item label =" 公众号" prop =" accountId" >
14
- <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" class =" !w-240px" >
15
- <el-option
16
- v-for =" item in accountList"
17
- :key =" item.id"
18
- :label =" item.name"
19
- :value =" item.id"
20
- />
21
- </el-select >
22
- </el-form-item >
23
- <el-form-item >
24
- <el-button @click =" handleQuery" ><Icon icon =" ep:search" />搜索</el-button >
25
- <el-button @click =" resetQuery" ><Icon icon =" ep:refresh" />重置</el-button >
26
- </el-form-item >
27
- </el-form >
6
+ <WxAccountSelect @change =" (accountId) => accountChanged(accountId)" />
28
7
</ContentWrap >
29
8
30
9
<!-- tab 切换 -->
181
160
</ContentWrap >
182
161
</template >
183
162
<script setup name="MpAutoReply">
184
- import { ref , reactive , onMounted , nextTick } from ' vue'
185
163
import WxVideoPlayer from ' @/views/mp/components/wx-video-play/main.vue'
186
164
import WxVoicePlayer from ' @/views/mp/components/wx-voice-play/main.vue'
187
165
import WxMusic from ' @/views/mp/components/wx-music/main.vue'
188
166
import WxNews from ' @/views/mp/components/wx-news/main.vue'
189
167
import WxReplySelect from ' @/views/mp/components/wx-reply/main.vue'
190
- import { getSimpleAccountList } from ' @/api/mp/account'
191
- import {
192
- createAutoReply ,
193
- deleteAutoReply ,
194
- getAutoReply ,
195
- getAutoReplyPage ,
196
- updateAutoReply
197
- } from ' @/api/mp/autoReply'
168
+ import WxAccountSelect from ' @/views/mp/components/wx-account-select/main.vue'
169
+ import * as MpAutoReplyApi from ' @/api/mp/autoReply'
198
170
199
171
import { DICT_TYPE , getDictOptions } from ' @/utils/dict'
200
172
import { dateFormatter } from ' @/utils/formatTime'
201
173
import { ContentWrap } from ' @/components/ContentWrap'
202
174
203
175
const message = useMessage ()
204
176
205
- const queryFormRef = ref ()
177
+ // const queryFormRef = ref()
206
178
const formRef = ref ()
207
179
208
180
// tab 类型(1、关注时回复;2、消息回复;3、关键词回复)
@@ -240,43 +212,27 @@ const rules = {
240
212
requestMatch: [{ required: true , message: ' 请求的关键字的匹配不能为空' , trigger: ' blur' }]
241
213
}
242
214
243
- const hackResetWxReplySelect = ref (false ) // 重置 WxReplySelect 组件,解决无法清除的问题
215
+ // 重置 WxReplySelect 组件,解决无法清除的问题
216
+ const hackResetWxReplySelect = ref (false )
244
217
245
- // 公众号账号列表
246
- const accountList = ref ([])
247
-
248
- onMounted (() => {
249
- getSimpleAccountList ().then ((data ) => {
250
- accountList .value = data
251
- // 默认选中第一个
252
- if (accountList .value .length > 0 ) {
253
- queryParams .accountId = accountList .value [0 ].id
254
- }
255
- // 加载数据
256
- getList ()
257
- })
258
- })
218
+ const accountChanged = (accountId ) => {
219
+ queryParams .accountId = accountId
220
+ getList ()
221
+ }
259
222
260
223
/** 查询列表 */
261
224
const getList = async () => {
262
- // 如果没有选中公众号账号,则进行提示。
263
- if (! queryParams .accountId ) {
264
- message .error (' 未选中公众号,无法查询自动回复' )
265
- return false
266
- }
267
-
268
225
loading .value = false
269
- // 处理查询参数
270
- let params = {
271
- ... queryParams,
272
- type: type .value
273
- }
274
- // 执行查询
275
- getAutoReplyPage (params).then ((data ) => {
226
+ try {
227
+ const data = await MpAutoReplyApi .getAutoReplyPage ({
228
+ ... queryParams,
229
+ type: type .value
230
+ })
276
231
list .value = data .list
277
232
total .value = data .total
233
+ } finally {
278
234
loading .value = false
279
- })
235
+ }
280
236
}
281
237
282
238
/** 搜索按钮操作 */
@@ -285,16 +241,6 @@ const handleQuery = () => {
285
241
getList ()
286
242
}
287
243
288
- /** 重置按钮操作 */
289
- const resetQuery = () => {
290
- queryFormRef .value ? .resetFields ()
291
- // 默认选中第一个
292
- if (accountList .value .length > 0 ) {
293
- queryParams .accountId = accountList .value [0 ].id
294
- }
295
- handleQuery ()
296
- }
297
-
298
244
const handleTabChange = (tabName ) => {
299
245
type .value = tabName
300
246
handleQuery ()
@@ -319,7 +265,7 @@ const handleUpdate = (row) => {
319
265
resetEditor ()
320
266
console .log (row)
321
267
322
- getAutoReply (row .id ).then ((data ) => {
268
+ MpAutoReplyApi . getAutoReply (row .id ).then ((data ) => {
323
269
// 设置属性
324
270
form .value = { ... data }
325
271
delete form .value [' responseMessageType' ]
@@ -370,13 +316,13 @@ const handleSubmit = () => {
370
316
form .responseHqMusicUrl = objData .value .hqMusicUrl
371
317
372
318
if (form .value .id !== undefined ) {
373
- updateAutoReply (form).then (() => {
319
+ MpAutoReplyApi . updateAutoReply (form).then (() => {
374
320
message .success (' 修改成功' )
375
321
open .value = false
376
322
getList ()
377
323
})
378
324
} else {
379
- createAutoReply (form).then (() => {
325
+ MpAutoReplyApi . createAutoReply (form).then (() => {
380
326
message .success (' 新增成功' )
381
327
open .value = false
382
328
getList ()
@@ -414,7 +360,7 @@ const resetEditor = () => {
414
360
415
361
const handleDelete = async (row ) => {
416
362
await message .confirm (' 是否确认删除此数据?' )
417
- await deleteAutoReply (row .id )
363
+ await MpAutoReplyApi . deleteAutoReply (row .id )
418
364
await getList ()
419
365
message .success (' 删除成功' )
420
366
}
0 commit comments