Skip to content

Commit 87a5ddf

Browse files
committed
REVIEW 图文发表记录
1 parent a56a2f6 commit 87a5ddf

File tree

2 files changed

+34
-83
lines changed

2 files changed

+34
-83
lines changed

src/views/mp/freePublish/index.vue

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@
1919
</el-select>
2020
</el-form-item>
2121
<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>
3024
</el-form-item>
3125
</el-form>
3226
</content-wrap>
@@ -41,7 +35,6 @@
4135
:key="item.articleId"
4236
>
4337
<wx-news :articles="item.content.newsItem" />
44-
<!-- 操作 -->
4538
<el-row justify="center" class="ope-row">
4639
<el-button
4740
type="danger"
@@ -54,9 +47,8 @@
5447
</el-row>
5548
</div>
5649
</div>
57-
<!-- 分页组件 -->
58-
<pagination
59-
v-show="total > 0"
50+
<!-- 分页 -->
51+
<Pagination
6052
:total="total"
6153
v-model:page="queryParams.pageNo"
6254
v-model:limit="queryParams.pageSize"
@@ -66,24 +58,18 @@
6658
</template>
6759

6860
<script setup lang="ts" name="freePublish">
69-
import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish'
61+
import * as FreePublishApi from '@/api/mp/freePublish'
7062
import * as MpAccountApi from '@/api/mp/account'
7163
import WxNews from '@/views/mp/components/wx-news/main.vue'
72-
7364
const message = useMessage() // 消息弹窗
65+
const { t } = useI18n() // 国际化
7466
7567
const loading = ref(true) // 列表的加载中
7668
const total = ref(0) // 列表的总页数
7769
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,
8773
accountId: undefined // 当前页数
8874
})
8975
const queryFormRef = ref() // 搜索的表单
@@ -96,25 +82,14 @@ const getList = async () => {
9682
message.error('未选中公众号,无法查询已发表图文')
9783
return false
9884
}
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+
}
11893
}
11994
12095
/** 搜索按钮操作 */
@@ -135,21 +110,15 @@ const resetQuery = () => {
135110
136111
/** 删除按钮操作 */
137112
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 {}
153122
}
154123
155124
onMounted(async () => {
@@ -162,15 +131,6 @@ onMounted(async () => {
162131
})
163132
</script>
164133
<style lang="scss" scoped>
165-
.pagination {
166-
float: right;
167-
margin-right: 25px;
168-
}
169-
170-
.add_but {
171-
padding: 10px;
172-
}
173-
174134
.ope-row {
175135
margin-top: 5px;
176136
text-align: center;

src/views/mp/tag/index.vue

Lines changed: 8 additions & 17 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>
@@ -28,21 +28,15 @@
2828
/>
2929
</el-form-item>
3030
<el-form-item>
31-
<el-button @click="handleQuery">
32-
<Icon icon="ep:search" class="mr-5px" />
33-
搜索
34-
</el-button>
35-
<el-button @click="resetQuery">
36-
<Icon icon="ep:refresh" class="mr-5px" />
37-
重置
38-
</el-button>
31+
<el-form-item>
32+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
33+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
34+
</el-form-item>
3935
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['mp:tag:create']">
40-
<Icon icon="ep:plus" class="mr-5px" />
41-
新增
36+
<Icon icon="ep:plus" class="mr-5px" /> 新增
4237
</el-button>
4338
<el-button type="success" plain @click="handleSync" v-hasPermi="['mp:tag:sync']">
44-
<Icon icon="ep:refresh" class="mr-5px" />
45-
同步
39+
<Icon icon="ep:refresh" class="mr-5px" /> 同步
4640
</el-button>
4741
</el-form-item>
4842
</el-form>
@@ -99,7 +93,6 @@ import { dateFormatter } from '@/utils/formatTime'
9993
import * as MpTagApi from '@/api/mp/tag'
10094
import * as MpAccountApi from '@/api/mp/account'
10195
import TagForm from './TagForm.vue'
102-
10396
const message = useMessage() // 消息弹窗
10497
const { t } = useI18n() // 国际化
10598
@@ -143,7 +136,6 @@ const resetQuery = () => {
143136
queryFormRef.value.resetFields()
144137
// 默认选中第一个
145138
if (accountList.value.length > 0) {
146-
// @ts-ignore
147139
queryParams.accountId = accountList.value[0].id
148140
}
149141
handleQuery()
@@ -184,7 +176,6 @@ onMounted(async () => {
184176
accountList.value = await MpAccountApi.getSimpleAccountList()
185177
// 选中第一个
186178
if (accountList.value.length > 0) {
187-
// @ts-ignore
188179
queryParams.accountId = accountList.value[0].id
189180
}
190181
await getList()

0 commit comments

Comments
 (0)