1
1
<template >
2
+ <!-- 搜索工作栏 -->
2
3
<content-wrap >
3
- <doc-alert title =" 公众号图文" url =" https://doc.iocoder.cn/mp/article/" />
4
-
5
- <!-- 搜索工作栏 -->
6
4
<el-form
5
+ class =" -mb-15px"
7
6
:model =" queryParams"
8
7
ref =" queryFormRef"
9
- size =" small"
10
8
:inline =" true"
11
- v-show =" showSearch"
12
9
label-width =" 68px"
13
10
>
14
11
<el-form-item label =" 公众号" prop =" accountId" >
15
- <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" >
12
+ <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" class = " !w-240px " >
16
13
<el-option
17
- v-for =" item in accounts "
18
- :key =" parseInt( item.id) "
14
+ v-for =" item in accountList "
15
+ :key =" item.id"
19
16
:label =" item.name"
20
- :value =" parseInt( item.id) "
17
+ :value =" item.id"
21
18
/>
22
19
</el-select >
23
20
</el-form-item >
24
21
<el-form-item >
25
- <el-button type = " primary " : icon =" Search " @click = " handleQuery " > 搜索</el-button >
26
- <el-button : icon =" Refresh " @click = " resetQuery " > 重置</el-button >
22
+ <el-button @click = " handleQuery " >< Icon icon =" ep:search " class = " mr-5px " /> 搜索</el-button >
23
+ <el-button @click = " resetQuery " >< Icon icon =" ep:refresh " class = " mr-5px " /> 重置</el-button >
27
24
</el-form-item >
28
25
</el-form >
26
+ </content-wrap >
29
27
30
- <!-- 列表 -->
28
+ <!-- 列表 -->
29
+ <content-wrap >
31
30
<div class =" waterfall" v-loading =" loading" >
32
31
<div
33
- v-show =" item.content && item.content.newsItem"
34
32
class =" waterfall-item"
33
+ v-show =" item.content && item.content.newsItem"
35
34
v-for =" item in list"
36
35
:key =" item.articleId"
37
36
>
40
39
<el-row justify =" center" class =" ope-row" >
41
40
<el-button
42
41
type =" danger"
43
- :icon =" Delete"
44
42
circle
45
43
@click =" handleDelete(item)"
46
44
v-hasPermi =" ['mp:free-publish:delete']"
47
- />
45
+ >
46
+ <Icon icon =" ep:delete" />
47
+ </el-button >
48
48
</el-row >
49
49
</div >
50
50
</div >
61
61
62
62
<script setup lang="ts" name="freePublish">
63
63
import { getFreePublishPage , deleteFreePublish } from ' @/api/mp/freePublish'
64
- import { getSimpleAccounts } from ' @/api/mp/account'
64
+ import * as MpAccountApi from ' @/api/mp/account'
65
65
import WxNews from ' @/views/mp/components/wx-news/main.vue'
66
- import { Delete , Search , Refresh } from ' @element-plus/icons-vue'
67
-
68
66
const message = useMessage () // 消息弹窗
69
67
68
+ const loading = ref (true ) // 列表的加载中
69
+ const total = ref (0 ) // 列表的总页数
70
+ const list = ref ([]) // 列表的数据
70
71
const queryParams = reactive ({
71
- total: 0 , // 总页数
72
72
currentPage: 1 , // 当前页数
73
73
pageNo: 1 , // 当前页数
74
- accountId: undefined , // 当前页数
75
- queryParamsSize: 10 // 每页显示多少条
74
+ accountId: undefined // 当前页数
76
75
})
77
- const loading = ref (false ) // 列表的加载中
78
- const showSearch = ref (true ) // 列表的加载中
79
- const total = ref (0 ) // 列表的总页数
80
- const list = ref ([]) // 列表的数据
81
- const accounts = ref ([]) // 列表的数据
82
76
const queryFormRef = ref () // 搜索的表单
77
+ const accountList = ref <MpAccountApi .AccountVO []>([]) // 公众号账号列表
78
+
83
79
/** 查询列表 */
84
80
const getList = async () => {
85
81
// 如果没有选中公众号账号,则进行提示。
86
82
if (! queryParams .accountId ) {
87
83
message .error (' 未选中公众号,无法查询已发表图文' )
88
84
return false
89
85
}
86
+ // TODO 改成 await 形式
90
87
loading .value = true
91
88
getFreePublishPage (queryParams )
92
89
.then ((data ) => {
@@ -106,25 +103,28 @@ const getList = async () => {
106
103
loading .value = false
107
104
})
108
105
}
106
+
109
107
/** 搜索按钮操作 */
110
- const handleQuery = async () => {
108
+ const handleQuery = () => {
111
109
queryParams .pageNo = 1
112
110
getList ()
113
111
}
114
112
115
113
/** 重置按钮操作 */
116
- const resetQuery = async () => {
114
+ const resetQuery = () => {
117
115
queryFormRef .value .resetFields ()
118
116
// 默认选中第一个
119
- if (accounts .value .length > 0 ) {
120
- queryParams .accountId = accounts [0 ].id
117
+ if (accountList .value .length > 0 ) {
118
+ // @ts-ignore
119
+ queryParams .accountId = accountList .value [0 ].id
121
120
}
122
121
handleQuery ()
123
122
}
124
123
125
124
/** 删除按钮操作 */
126
125
const handleDelete = async (item ) => {
127
126
{
127
+ // TODO 改成 await 形式
128
128
const articleId = item .articleId
129
129
const accountId = queryParams .accountId
130
130
message
@@ -140,19 +140,16 @@ const handleDelete = async (item) => {
140
140
}
141
141
}
142
142
143
- onMounted (() => {
144
- getSimpleAccounts ().then ((response ) => {
145
- accounts .value = response
146
- // 默认选中第一个
147
- if (accounts .value .length > 0 ) {
148
- queryParams .accountId = accounts .value [0 ][' id' ]
149
- }
150
- // 加载数据
151
- getList ()
152
- })
143
+ onMounted (async () => {
144
+ accountList .value = await MpAccountApi .getSimpleAccountList ()
145
+ // 选中第一个
146
+ if (accountList .value .length > 0 ) {
147
+ // @ts-ignore
148
+ queryParams .accountId = accountList .value [0 ].id
149
+ }
150
+ await getList ()
153
151
})
154
152
</script >
155
-
156
153
<style lang="scss" scoped>
157
154
.pagination {
158
155
float : right ;
@@ -182,7 +179,7 @@ onMounted(() => {
182
179
margin-left : 5px ;
183
180
}
184
181
185
- /* 新增图文*/
182
+ /* 新增图文 */
186
183
.left {
187
184
display : inline-block ;
188
185
width : 35% ;
0 commit comments