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 =" 请选择公众号" >
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 >
6
+ <WxAccountSelect @change =" (accountId) => accountChanged(accountId)" >
7
+ <template #actions >
26
8
<el-button type =" primary" plain @click =" handleAdd" v-hasPermi =" ['mp:draft:create']" >
27
9
<Icon icon =" ep:plus" />新增
28
10
</el-button >
29
- </el-form-item >
30
- </el-form >
11
+ </template >
12
+ </WxAccountSelect >
31
13
</ContentWrap >
32
14
33
15
<!-- 列表 -->
34
16
<ContentWrap >
35
17
<div class =" waterfall" v-loading =" loading" >
36
18
<template v-for =" item in list " :key =" item .articleId " >
37
19
<div class =" waterfall-item" v-if =" item.content && item.content.newsItem" >
38
- <wx-news :articles =" item.content.newsItem" />
20
+ <WxNews :articles =" item.content.newsItem" />
39
21
<!-- 操作按钮 -->
40
22
<el-row class =" ope-row" >
41
23
<el-button
239
221
</div >
240
222
<!-- 富文本编辑器组件-->
241
223
<el-row >
242
- <wx-editor
224
+ <WxEditor
243
225
v-model =" articlesAdd[isActiveAddNews].content"
244
226
:account-id =" uploadData.accountId"
245
227
v-if =" hackResetEditor"
258
240
import WxEditor from ' @/views/mp/components/wx-editor/WxEditor.vue'
259
241
import WxNews from ' @/views/mp/components/wx-news/main.vue'
260
242
import WxMaterialSelect from ' @/views/mp/components/wx-material-select/main.vue'
243
+ import WxAccountSelect from ' @/views/mp/components/wx-account-select/main.vue'
261
244
import { getAccessToken } from ' @/utils/auth'
262
- import * as MpAccountApi from ' @/api/mp/account'
263
245
import * as MpDraftApi from ' @/api/mp/draft'
264
246
import * as MpFreePublishApi from ' @/api/mp/freePublish'
265
- const message = useMessage () // 消息
266
247
// 可以用改本地数据模拟,避免API调用超限
267
248
// import drafts from './mock'
268
249
250
+ const message = useMessage () // 消息
251
+
269
252
const loading = ref (true ) // 列表的加载中
270
253
const total = ref (0 ) // 列表的总页数
271
254
const list = ref ([]) // 列表的数据
@@ -274,8 +257,6 @@ const queryParams = reactive({
274
257
pageSize: 10 ,
275
258
accountId: undefined
276
259
})
277
- const queryFormRef = ref () // 搜索的表单
278
- const accountList = ref ([]) // 公众号账号列表
279
260
280
261
// ========== 文件上传 ==========
281
262
const materialSelectRef = ref ()
@@ -298,16 +279,11 @@ const operateMaterial = ref('add')
298
279
const articlesMediaId = ref (' ' )
299
280
const hackResetEditor = ref (false )
300
281
301
- /** 初始化 **/
302
- onMounted (async () => {
303
- accountList .value = await MpAccountApi .getSimpleAccountList ()
304
- // 选中第一个
305
- if (accountList .value .length > 0 ) {
306
- // @ts-ignore
307
- queryParams .accountId = accountList .value [0 ].id
308
- }
309
- await getList ()
310
- })
282
+ /** 侦听公众号变化 **/
283
+ const accountChanged = (accountId ) => {
284
+ setAccountId (accountId)
285
+ getList ()
286
+ }
311
287
312
288
// ======================== 列表查询 ========================
313
289
/** 设置账号编号 */
@@ -341,26 +317,6 @@ const getList = async () => {
341
317
}
342
318
}
343
319
344
- /** 搜索按钮操作 */
345
- const handleQuery = () => {
346
- queryParams .pageNo = 1
347
- // 默认选中第一个
348
- if (queryParams .accountId ) {
349
- setAccountId (queryParams .accountId )
350
- }
351
- getList ()
352
- }
353
-
354
- /** 重置按钮操作 */
355
- const resetQuery = () => {
356
- queryFormRef .value .resetFields ()
357
- // 默认选中第一个
358
- if (accountList .value .length > 0 ) {
359
- setAccountId (accountList .value [0 ].id )
360
- }
361
- handleQuery ()
362
- }
363
-
364
320
// ======================== 新增/修改草稿 ========================
365
321
/** 新增按钮操作 */
366
322
const handleAdd = () => {
0 commit comments