19
19
</el-select >
20
20
</el-form-item >
21
21
<el-form-item >
22
- <el-button @click =" handleQuery" >
23
- <Icon icon =" ep:search" class =" mr-5px" />
24
- 搜索
25
- </el-button >
26
- <el-button @click =" resetQuery" >
27
- <Icon icon =" ep:refresh" class =" mr-5px" />
28
- 重置
29
- </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 >
30
24
</el-form-item >
31
25
</el-form >
32
26
</content-wrap >
41
35
:key =" item.articleId"
42
36
>
43
37
<wx-news :articles =" item.content.newsItem" />
44
- <!-- 操作 -->
45
38
<el-row justify =" center" class =" ope-row" >
46
39
<el-button
47
40
type =" danger"
54
47
</el-row >
55
48
</div >
56
49
</div >
57
- <!-- 分页组件 -->
58
- <pagination
59
- v-show =" total > 0"
50
+ <!-- 分页 -->
51
+ <Pagination
60
52
:total =" total"
61
53
v-model:page =" queryParams.pageNo"
62
54
v-model:limit =" queryParams.pageSize"
66
58
</template >
67
59
68
60
<script setup lang="ts" name="freePublish">
69
- import { getFreePublishPage , deleteFreePublish } from ' @/api/mp/freePublish'
61
+ import * as FreePublishApi from ' @/api/mp/freePublish'
70
62
import * as MpAccountApi from ' @/api/mp/account'
71
63
import WxNews from ' @/views/mp/components/wx-news/main.vue'
72
-
73
64
const message = useMessage () // 消息弹窗
65
+ const { t } = useI18n () // 国际化
74
66
75
67
const loading = ref (true ) // 列表的加载中
76
68
const total = ref (0 ) // 列表的总页数
77
69
const list = ref ([]) // 列表的数据
78
- interface QueryParams {
79
- currentPage: number | undefined | string
80
- pageNo: number | undefined | string
81
- accountId: number | undefined | string
82
- }
83
-
84
- const queryParams: QueryParams = reactive ({
85
- currentPage: 1 , // 当前页数
86
- pageNo: 1 , // 当前页数
70
+ const queryParams = reactive ({
71
+ pageNo: 1 ,
72
+ pageSize: 10 ,
87
73
accountId: undefined // 当前页数
88
74
})
89
75
const queryFormRef = ref () // 搜索的表单
@@ -96,25 +82,14 @@ const getList = async () => {
96
82
message .error (' 未选中公众号,无法查询已发表图文' )
97
83
return false
98
84
}
99
- // TODO 改成 await 形式
100
- loading .value = true
101
- getFreePublishPage (queryParams )
102
- .then ((data ) => {
103
- console .log (data )
104
- // 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
105
- data .list .forEach ((item ) => {
106
- console .log (item )
107
- const newsItem = item .content .newsItem
108
- newsItem .forEach ((article ) => {
109
- article .picUrl = article .thumbUrl
110
- })
111
- })
112
- list .value = data .list
113
- total .value = data .total
114
- })
115
- .finally (() => {
116
- loading .value = false
117
- })
85
+ try {
86
+ loading .value = true
87
+ const data = await FreePublishApi .getFreePublishPage (queryParams )
88
+ list .value = data .list
89
+ total .value = data .total
90
+ } finally {
91
+ loading .value = false
92
+ }
118
93
}
119
94
120
95
/** 搜索按钮操作 */
@@ -135,21 +110,15 @@ const resetQuery = () => {
135
110
136
111
/** 删除按钮操作 */
137
112
const handleDelete = async (item ) => {
138
- {
139
- // TODO 改成 await 形式
140
- const articleId = item .articleId
141
- const accountId = queryParams .accountId
142
- message
143
- .confirm (' 删除后用户将无法访问此页面,确定删除?' )
144
- .then (function () {
145
- return deleteFreePublish (accountId , articleId )
146
- })
147
- .then (() => {
148
- getList ()
149
- message .success (' 删除成功' )
150
- })
151
- .catch (() => {})
152
- }
113
+ try {
114
+ // 删除的二次确认
115
+ await message .delConfirm (' 删除后用户将无法访问此页面,确定删除?' )
116
+ // 发起删除
117
+ await FreePublishApi .deleteFreePublish (queryParams .accountId , item .articleId )
118
+ message .success (t (' common.delSuccess' ))
119
+ // 刷新列表
120
+ await getList ()
121
+ } catch {}
153
122
}
154
123
155
124
onMounted (async () => {
@@ -162,15 +131,6 @@ onMounted(async () => {
162
131
})
163
132
</script >
164
133
<style lang="scss" scoped>
165
- .pagination {
166
- float : right ;
167
- margin-right : 25px ;
168
- }
169
-
170
- .add_but {
171
- padding : 10px ;
172
- }
173
-
174
134
.ope-row {
175
135
margin-top : 5px ;
176
136
text-align : center ;
0 commit comments