Skip to content

Commit f517733

Browse files
committed
Vue3 重构:REVIEW 图文发表记录
1 parent 708aef3 commit f517733

File tree

2 files changed

+49
-50
lines changed

2 files changed

+49
-50
lines changed

src/views/mp/freePublish/index.vue

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
<template>
2+
<!-- 搜索工作栏 -->
23
<content-wrap>
3-
<doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
4-
5-
<!-- 搜索工作栏 -->
64
<el-form
5+
class="-mb-15px"
76
:model="queryParams"
87
ref="queryFormRef"
9-
size="small"
108
:inline="true"
11-
v-show="showSearch"
129
label-width="68px"
1310
>
1411
<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">
1613
<el-option
17-
v-for="item in accounts"
18-
:key="parseInt(item.id)"
14+
v-for="item in accountList"
15+
:key="item.id"
1916
:label="item.name"
20-
:value="parseInt(item.id)"
17+
:value="item.id"
2118
/>
2219
</el-select>
2320
</el-form-item>
2421
<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>
2724
</el-form-item>
2825
</el-form>
26+
</content-wrap>
2927

30-
<!-- 列表 -->
28+
<!-- 列表 -->
29+
<content-wrap>
3130
<div class="waterfall" v-loading="loading">
3231
<div
33-
v-show="item.content && item.content.newsItem"
3432
class="waterfall-item"
33+
v-show="item.content && item.content.newsItem"
3534
v-for="item in list"
3635
:key="item.articleId"
3736
>
@@ -40,11 +39,12 @@
4039
<el-row justify="center" class="ope-row">
4140
<el-button
4241
type="danger"
43-
:icon="Delete"
4442
circle
4543
@click="handleDelete(item)"
4644
v-hasPermi="['mp:free-publish:delete']"
47-
/>
45+
>
46+
<Icon icon="ep:delete" />
47+
</el-button>
4848
</el-row>
4949
</div>
5050
</div>
@@ -61,32 +61,29 @@
6161

6262
<script setup lang="ts" name="freePublish">
6363
import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish'
64-
import { getSimpleAccounts } from '@/api/mp/account'
64+
import * as MpAccountApi from '@/api/mp/account'
6565
import WxNews from '@/views/mp/components/wx-news/main.vue'
66-
import { Delete, Search, Refresh } from '@element-plus/icons-vue'
67-
6866
const message = useMessage() // 消息弹窗
6967
68+
const loading = ref(true) // 列表的加载中
69+
const total = ref(0) // 列表的总页数
70+
const list = ref([]) // 列表的数据
7071
const queryParams = reactive({
71-
total: 0, // 总页数
7272
currentPage: 1, // 当前页数
7373
pageNo: 1, // 当前页数
74-
accountId: undefined, // 当前页数
75-
queryParamsSize: 10 // 每页显示多少条
74+
accountId: undefined // 当前页数
7675
})
77-
const loading = ref(false) // 列表的加载中
78-
const showSearch = ref(true) // 列表的加载中
79-
const total = ref(0) // 列表的总页数
80-
const list = ref([]) // 列表的数据
81-
const accounts = ref([]) // 列表的数据
8276
const queryFormRef = ref() // 搜索的表单
77+
const accountList = ref<MpAccountApi.AccountVO[]>([]) // 公众号账号列表
78+
8379
/** 查询列表 */
8480
const getList = async () => {
8581
// 如果没有选中公众号账号,则进行提示。
8682
if (!queryParams.accountId) {
8783
message.error('未选中公众号,无法查询已发表图文')
8884
return false
8985
}
86+
// TODO 改成 await 形式
9087
loading.value = true
9188
getFreePublishPage(queryParams)
9289
.then((data) => {
@@ -106,25 +103,28 @@ const getList = async () => {
106103
loading.value = false
107104
})
108105
}
106+
109107
/** 搜索按钮操作 */
110-
const handleQuery = async () => {
108+
const handleQuery = () => {
111109
queryParams.pageNo = 1
112110
getList()
113111
}
114112
115113
/** 重置按钮操作 */
116-
const resetQuery = async () => {
114+
const resetQuery = () => {
117115
queryFormRef.value.resetFields()
118116
// 默认选中第一个
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
121120
}
122121
handleQuery()
123122
}
124123
125124
/** 删除按钮操作 */
126125
const handleDelete = async (item) => {
127126
{
127+
// TODO 改成 await 形式
128128
const articleId = item.articleId
129129
const accountId = queryParams.accountId
130130
message
@@ -140,19 +140,16 @@ const handleDelete = async (item) => {
140140
}
141141
}
142142
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()
153151
})
154152
</script>
155-
156153
<style lang="scss" scoped>
157154
.pagination {
158155
float: right;
@@ -182,7 +179,7 @@ onMounted(() => {
182179
margin-left: 5px;
183180
}
184181
185-
/*新增图文*/
182+
/* 新增图文 */
186183
.left {
187184
display: inline-block;
188185
width: 35%;

src/views/mp/message/index.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<el-select v-model="queryParams.accountId" placeholder="请选择公众号" class="!w-240px">
1313
<el-option
1414
v-for="item in accountList"
15-
:key="parseInt(item.id)"
15+
:key="item.id"
1616
:label="item.name"
17-
:value="parseInt(item.id)"
17+
:value="item.id"
1818
/>
1919
</el-select>
2020
</el-form-item>
@@ -60,11 +60,13 @@
6060
<!-- 列表 -->
6161
<ContentWrap>
6262
<el-table v-loading="loading" :data="list">
63-
<el-table-column label="发送时间" align="center" prop="createTime" width="180">
64-
<template #default="scope">
65-
<span>{{ parseTime(scope.row.createTime) }}</span>
66-
</template>
67-
</el-table-column>
63+
<el-table-column
64+
label="发送时间"
65+
align="center"
66+
prop="createTime"
67+
width="180"
68+
:formatter="dateFormatter"
69+
/>
6870
<el-table-column label="消息类型" align="center" prop="type" width="80" />
6971
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
7072
<template #default="scope">
@@ -180,13 +182,13 @@
180182
</template>
181183
<script setup lang="ts" name="MpMessage">
182184
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
185+
import { dateFormatter } from '@/utils/formatTime'
183186
// import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
184187
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
185188
// import WxMsg from '@/views/mp/components/wx-msg/main.vue'
186189
import WxLocation from '@/views/mp/components/wx-location/main.vue'
187190
// import WxMusic from '@/views/mp/components/wx-music/main.vue'
188191
// import WxNews from '@/views/mp/components/wx-news/main.vue'
189-
import { parseTime } from '@/utils/formatTime'
190192
import * as MpAccountApi from '@/api/mp/account'
191193
import * as MpMessageApi from '@/api/mp/message'
192194
const message = useMessage() // 消息弹窗

0 commit comments

Comments
 (0)